forked from github/verilator
01a54d6960
Prep for adding more CI targets. Building dbg and opt in the same job (as standard) simplifies caching, debugging and artifact handling. With ccache it should not take much longer either. Also removes the need to re-configure in the test job.
153 lines
4.1 KiB
YAML
153 lines
4.1 KiB
YAML
# DESCRIPTION: Github actions config
|
|
# This name is key to badges in README.rst, so we use the name build
|
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
|
|
|
name: build
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: '0 0 * * 0' # weekly
|
|
|
|
env:
|
|
CI_OS_NAME: linux
|
|
CI_COMMIT: ${{ github.sha }}
|
|
CCACHE_COMPRESS: 1
|
|
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
|
CCACHE_LIMIT_MULTIPLE: 0.95
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: repo
|
|
|
|
jobs:
|
|
|
|
|
|
Matrix:
|
|
runs-on: ubuntu-latest
|
|
name: Generate Build matrix
|
|
outputs:
|
|
matrix: ${{ steps.generate.outputs.matrix }}
|
|
steps:
|
|
- id: generate
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
if [ '${{ github.event_name }}' = 'pull_request' ]; then
|
|
matrix='[ "ubuntu-20.04" ]'
|
|
else
|
|
matrix='[ "ubuntu-20.04", "ubuntu-18.04", "ubuntu-16.04" ]'
|
|
fi
|
|
echo "::set-output name=matrix::$matrix"
|
|
|
|
|
|
Build:
|
|
needs: Matrix
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: ${{ fromJson(needs.Matrix.outputs.matrix) }}
|
|
compiler:
|
|
- { cc: clang, cxx: clang++ }
|
|
- { cc: gcc, cxx: g++ }
|
|
runs-on: ${{ matrix.os }}
|
|
name: Build | ${{ matrix.os }} | ${{ matrix.compiler.cc }}
|
|
env:
|
|
CI_BUILD_STAGE_NAME: build
|
|
CI_RUNS_ON: ${{ matrix.os }}
|
|
CC: ${{ matrix.compiler.cc }}
|
|
CXX: ${{ matrix.compiler.cxx }}
|
|
CACHE_BASE_KEY: build-${{ matrix.os }}-${{ matrix.compiler.cc }}
|
|
CCACHE_MAXSIZE: 250M # Per build matrix entry (1500M in total)
|
|
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz
|
|
steps:
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
path: repo
|
|
|
|
- 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: ./ci/ci-script.bash
|
|
|
|
- name: Tar up repository
|
|
working-directory: ${{ github.workspace }}
|
|
run: tar --posix -c -z -f ${{ env.VERILATOR_ARCHIVE }} repo
|
|
|
|
- name: Upload tar archive
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
path: ${{ github.workspace }}/${{ env.VERILATOR_ARCHIVE }}
|
|
name: ${{ 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: 64M # Per build matrix entry (1920M in total)
|
|
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz
|
|
steps:
|
|
|
|
- name: Download tar archive
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: ${{ env.VERILATOR_ARCHIVE }}
|
|
path: ${{ github.workspace }}
|
|
|
|
- name: Unpack tar archive
|
|
working-directory: ${{ github.workspace }}
|
|
run: tar -x -z -f ${{ env.VERILATOR_ARCHIVE }}
|
|
|
|
- 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 test dependencies
|
|
run: ./ci/ci-install.bash
|
|
|
|
- name: Test
|
|
env:
|
|
TESTS: ${{ matrix.suite }}
|
|
run: ./ci/ci-script.bash
|