CI: Build opt and dbg together, archive whole source tree

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.
This commit is contained in:
Geza Lore 2021-06-13 17:32:49 +01:00
parent 23fc08bdf9
commit 01a54d6960
5 changed files with 58 additions and 64 deletions

View File

@ -18,6 +18,11 @@ env:
CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_LIMIT_MULTIPLE: 0.95 CCACHE_LIMIT_MULTIPLE: 0.95
defaults:
run:
shell: bash
working-directory: repo
jobs: jobs:
@ -27,9 +32,8 @@ jobs:
outputs: outputs:
matrix: ${{ steps.generate.outputs.matrix }} matrix: ${{ steps.generate.outputs.matrix }}
steps: steps:
- uses: actions/checkout@v2
- id: generate - id: generate
name: Run 'generate_matrix.sh' working-directory: ${{ github.workspace }}
run: | run: |
if [ '${{ github.event_name }}' = 'pull_request' ]; then if [ '${{ github.event_name }}' = 'pull_request' ]; then
matrix='[ "ubuntu-20.04" ]' matrix='[ "ubuntu-20.04" ]'
@ -45,27 +49,25 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: ${{ fromJson(needs.Matrix.outputs.matrix) }} os: ${{ fromJson(needs.Matrix.outputs.matrix) }}
target:
- { name: opt, ccache_size: 48M }
- { name: dbg, ccache_size: 208M }
compiler: compiler:
- { cc: clang, cxx: clang++ } - { cc: clang, cxx: clang++ }
- { cc: gcc, cxx: g++ } - { cc: gcc, cxx: g++ }
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
name: Build | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.target.name }} name: Build | ${{ matrix.os }} | ${{ matrix.compiler.cc }}
env: env:
CI_BUILD_STAGE_NAME: build CI_BUILD_STAGE_NAME: build
CI_RUNS_ON: ${{ matrix.os }} CI_RUNS_ON: ${{ matrix.os }}
CI_MAKE_SRC_TARGET: ${{ matrix.target.name }}
CC: ${{ matrix.compiler.cc }} CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }} CXX: ${{ matrix.compiler.cxx }}
CACHE_BASE_KEY: build-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.target.name }} CACHE_BASE_KEY: build-${{ matrix.os }}-${{ matrix.compiler.cc }}
CCACHE_MAXSIZE: ${{ matrix.target.ccache_size }} # Per build matrix entry (1G in total) CCACHE_MAXSIZE: 250M # Per build matrix entry (1500M in total)
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.target.name }}.tar.gz VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
path: repo
- name: Cache $CCACHE_DIR - name: Cache $CCACHE_DIR
uses: actions/cache@v2 uses: actions/cache@v2
@ -81,17 +83,17 @@ jobs:
run: ./ci/ci-install.bash run: ./ci/ci-install.bash
- name: Build - name: Build
run: | run: ./ci/ci-script.bash
ccache -z
./ci/ci-script.bash
ccache -s
tar cvzf ${{ env.VERILATOR_ARCHIVE }} bin
- name: Upload Verilator artifact - 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 uses: actions/upload-artifact@v2
with: with:
path: ${{ github.workspace }}/${{ env.VERILATOR_ARCHIVE }}
name: ${{ env.VERILATOR_ARCHIVE }} name: ${{ env.VERILATOR_ARCHIVE }}
path: ${{ env.VERILATOR_ARCHIVE }}
Test: Test:
@ -118,11 +120,18 @@ jobs:
CXX: ${{ matrix.compiler.cxx }} CXX: ${{ matrix.compiler.cxx }}
CACHE_BASE_KEY: test-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.suite }} CACHE_BASE_KEY: test-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.suite }}
CCACHE_MAXSIZE: 64M # Per build matrix entry (1920M in total) CCACHE_MAXSIZE: 64M # Per build matrix entry (1920M in total)
VERILATOR_ARCHIVE_BASE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }} VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz
steps: steps:
- name: Checkout - name: Download tar archive
uses: actions/checkout@v2 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 - name: Cache $CCACHE_DIR
uses: actions/cache@v2 uses: actions/cache@v2
@ -134,29 +143,10 @@ jobs:
restore-keys: | restore-keys: |
${{ env.CACHE_KEY }}- ${{ 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 - name: Install test dependencies
run: | run: ./ci/ci-install.bash
./ci/ci-install.bash
- name: Test - name: Test
env: env:
TESTS: ${{ matrix.suite }} TESTS: ${{ matrix.suite }}
run: | run: ./ci/ci-script.bash
ccache -z
./ci/ci-script.bash
ccache -s

View File

@ -14,6 +14,11 @@ env:
COVERAGE: 1 COVERAGE: 1
VERILATOR_ARCHIVE: verilator-coverage-${{ github.sha }}.tar.gz VERILATOR_ARCHIVE: verilator-coverage-${{ github.sha }}.tar.gz
defaults:
run:
shell: bash
working-directory: repo
jobs: jobs:
@ -26,22 +31,24 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
path: repo
- name: Install packages for build - name: Install packages for build
env:
CI_BUILD_STAGE_NAME: build
run: ./ci/ci-install.bash run: ./ci/ci-install.bash
- name: Build - name: Build
run: | run: ./ci/ci-script.bash
./ci/ci-script.bash
tar cvzf ${{ env.VERILATOR_ARCHIVE }} bin src/obj*/*.o src/obj*/*.gcno
- name: Upload Verilator artifact - 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 uses: actions/upload-artifact@v2
with: with:
path: ${{ github.workspace }}/${{ env.VERILATOR_ARCHIVE }}
name: ${{ env.VERILATOR_ARCHIVE }} name: ${{ env.VERILATOR_ARCHIVE }}
path: ${{ env.VERILATOR_ARCHIVE }}
Test: Test:
@ -72,25 +79,20 @@ jobs:
CI_RUNS_ON: ubuntu-20.04 CI_RUNS_ON: ubuntu-20.04
steps: steps:
- name: Checkout - name: Download tar archive
uses: actions/checkout@v2
- name: Download Verilator artifact
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: ${{ env.VERILATOR_ARCHIVE }} name: ${{ env.VERILATOR_ARCHIVE }}
path: ${{ github.workspace }}
- name: Unapack Verilator artifact - name: Unpack tar archive
run: | working-directory: ${{ github.workspace }}
tar xvzf ${{ env.VERILATOR_ARCHIVE }} run: tar -x -z -f ${{ env.VERILATOR_ARCHIVE }}
touch src/obj*/*.o src/obj*/*.gcno
- name: Install test dependencies - name: Install test dependencies
run: | run: ./ci/ci-install.bash
./ci/ci-install.bash
- name: Test - name: Test
env: env:
TESTS: coverage-${{ matrix.test }}${{ matrix.num }} TESTS: coverage-${{ matrix.test }}${{ matrix.num }}
run: | run: ./ci/ci-script.bash
./ci/ci-script.bash

View File

@ -230,7 +230,7 @@ all_nomsg: verilator_exe $(VL_INST_MAN_FILES)
verilator_exe verilator_bin$(EXEEXT) verilator_bin_dbg$(EXEEXT) verilator_coverage_bin_dbg$(EXEEXT): verilator_exe verilator_bin$(EXEEXT) verilator_bin_dbg$(EXEEXT) verilator_coverage_bin_dbg$(EXEEXT):
@echo ------------------------------------------------------------ @echo ------------------------------------------------------------
@echo "making verilator in src" @echo "making verilator in src"
$(MAKE) -C src $(OBJCACHE_JOBS) $(CI_MAKE_SRC_TARGET) $(MAKE) -C src $(OBJCACHE_JOBS)
.PHONY:msg_test .PHONY:msg_test
msg_test: all_nomsg msg_test: all_nomsg

View File

@ -101,9 +101,6 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
fi fi
yes yes | sudo cpan -M $CI_CPAN_REPO -fi Parallel::Forker yes yes | sudo cpan -M $CI_CPAN_REPO -fi Parallel::Forker
install-vcddiff install-vcddiff
autoconf
./configure --enable-longtests --enable-ccwarn
else else
############################################################################## ##############################################################################
# Unknown build stage # Unknown build stage

View File

@ -41,7 +41,9 @@ if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then
if [ "$COVERAGE" != 1 ]; then if [ "$COVERAGE" != 1 ]; then
autoconf autoconf
./configure --enable-longtests --enable-ccwarn ./configure --enable-longtests --enable-ccwarn
ccache -z
"$MAKE" -j "$NPROC" -k "$MAKE" -j "$NPROC" -k
ccache -s
if [ "$CI_OS_NAME" = "osx" ]; then if [ "$CI_OS_NAME" = "osx" ]; then
file bin/verilator_bin file bin/verilator_bin
file bin/verilator_bin_dbg file bin/verilator_bin_dbg
@ -83,6 +85,7 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
[ "$CI_RUNS_ON" = 'ubuntu-20.04' ] && sanitize='--sanitize' || sanitize='' [ "$CI_RUNS_ON" = 'ubuntu-20.04' ] && sanitize='--sanitize' || sanitize=''
# Run the specified test # Run the specified test
ccache -z
case $TESTS in case $TESTS in
dist-vlt-0) dist-vlt-0)
"$MAKE" -C test_regress SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=0/3 "$MAKE" -C test_regress SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=0/3
@ -169,6 +172,8 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
fatal "Unknown test: $TESTS" fatal "Unknown test: $TESTS"
;; ;;
esac esac
ccache -s
# Upload coverage data # Upload coverage data
if [[ $TESTS == coverage-* ]]; then if [[ $TESTS == coverage-* ]]; then
bash <(cat ci/coverage-upload.sh) -f nodist/obj_dir/coverage/app_total.info bash <(cat ci/coverage-upload.sh) -f nodist/obj_dir/coverage/app_total.info