verilator/.github/workflows/build.yml

160 lines
4.3 KiB
YAML
Raw Normal View History

2020-12-04 22:11:00 +00:00
# DESCRIPTION: Github actions config
# This name is key to badges in README.rst, so we use the name build
2020-12-10 02:10:34 +00:00
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
2020-12-04 22:39:53 +00:00
2020-12-04 22:11:00 +00:00
name: build
2020-12-10 01:30:18 +00:00
on:
2020-12-04 22:11:00 +00:00
push:
pull_request:
2020-12-10 01:30:18 +00:00
workflow_dispatch:
2020-12-04 22:11:00 +00:00
schedule:
2020-12-04 22:39:53 +00:00
- cron: '0 0 * * 0' # weekly
env:
CI_OS_NAME: linux
CI_COMMIT: ${{ github.sha }}
CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
jobs:
2020-12-10 17:33:26 +00:00
Matrix:
runs-on: ubuntu-latest
name: Generate Build matrix
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: generate
name: Run 'generate_matrix.sh'
run: |
if [ '${{ github.event_name }}' = 'pull_request' ]; then
matrix='[ "ubuntu-20.04" ]'
else
matrix='[ "ubuntu-16.04", "ubuntu-18.04", "ubuntu-20.04" ]'
fi
echo "::set-output name=matrix::$matrix"
Build:
needs: Matrix
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.Matrix.outputs.matrix) }}
debug: [ opt, dbg ]
compiler:
2020-12-10 17:33:26 +00:00
- { cc: clang, cxx: clang++ }
- { cc: gcc, cxx: g++ }
runs-on: ${{ matrix.os }}
name: Build | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.debug }}
2020-12-04 22:39:53 +00:00
env:
CI_BUILD_STAGE_NAME: build
CI_RUNS_ON: ${{ matrix.os }}
CI_MAKE_SRC_TARGET: ${{ matrix.debug }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
CACHE_BASE_KEY: build-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.debug }}
CCACHE_MAXSIZE: 128Mi # Per build matrix entry (1Gi in total)
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.debug }}.tar.gz
2020-12-04 22:39:53 +00:00
steps:
2020-12-10 17:33:26 +00:00
- name: Checkout
uses: actions/checkout@v2
- name: Cache $CCACHE_DIR
uses: actions/cache@v2
env:
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CACHE_KEY }}-${{ github.sha }}
restore-keys: |
${{ env.CACHE_KEY }}-
- name: Install packages for build
run: ./ci/ci-install.bash
- name: Build
run: |
ccache -z
./ci/ci-script.bash
ccache -s
tar cvzf ${{ env.VERILATOR_ARCHIVE }} bin
- name: Upload Verilator artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.VERILATOR_ARCHIVE }}
path: ${{ env.VERILATOR_ARCHIVE }}
Test:
needs: [ Matrix, Build ]
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.Matrix.outputs.matrix) }}
compiler:
- { cc: clang, cxx: clang++ }
- { cc: gcc, cxx: g++ }
suite:
- dist-vlt-0
- dist-vlt-1
- dist-vlt-2
- vltmt-0
- vltmt-1
runs-on: ${{ matrix.os }}
name: Test | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.suite }}
env:
CI_BUILD_STAGE_NAME: test
CI_RUNS_ON: ${{ matrix.os }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
CACHE_BASE_KEY: test-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.suite }}
CCACHE_MAXSIZE: 32Mi # Per build matrix entry (960Mi in total)
VERILATOR_ARCHIVE_BASE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache $CCACHE_DIR
uses: actions/cache@v2
env:
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CACHE_KEY }}-${{ github.sha }}
restore-keys: |
${{ env.CACHE_KEY }}-
- name: Download Verilator artifact (opt)
uses: actions/download-artifact@v2
with:
name: ${{ env.VERILATOR_ARCHIVE_BASE }}-opt.tar.gz
- name: Download Verilator artifact (dbg)
uses: actions/download-artifact@v2
with:
name: ${{ env.VERILATOR_ARCHIVE_BASE }}-dbg.tar.gz
- name: Unpack Verilator artifacts
run: |
tar xvzf ${{ env.VERILATOR_ARCHIVE_BASE }}-opt.tar.gz
tar xvzf ${{ env.VERILATOR_ARCHIVE_BASE }}-dbg.tar.gz
- name: Install test dependencies
run: |
./ci/ci-install.bash
- name: Test
env:
TESTS: ${{ matrix.suite }}
run: |
ccache -z
./ci/ci-script.bash
ccache -s