User/dev/michnorris/tap mbox integ (#640) #707
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
name: Verilator | |
on: | |
push: | |
branches: ["main", "dev-goog", "dev-msft"] | |
workflow_call: | |
workflow_dispatch: | |
env: | |
CARGO_INCREMENTAL: 0 | |
SCCACHE_VERSION: 0.3.3 | |
RISCV_VERSION: v12.1.0 | |
VERILATOR_VERSION: v5.012 | |
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig | |
SCCACHE_GHA_CACHE_TO: sccache-verilator-10000 | |
SCCACHE_GHA_CACHE_FROM: sccache-verilator- | |
# Change this to a new random value if you suspect the cache is corrupted | |
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1e | |
jobs: | |
build_tools: | |
name: Build Tools | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
- name: Restore Cargo index | |
uses: actions/cache/restore@v3 | |
id: cargo_index_restore | |
with: | |
path: ~/.cargo/registry/index | |
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }} | |
- name: Restore sccache binary | |
uses: actions/cache/restore@v3 | |
id: sccache_bin_restore | |
with: | |
path: ~/.cargo/bin/sccache | |
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Install sccache | |
if: steps.sccache_bin_restore.outputs.cache-hit != 'true' | |
run: | | |
cargo install sccache --locked --version ${SCCACHE_VERSION} --no-default-features --features=gha | |
- name: Save sccache binary | |
uses: actions/cache/save@v3 | |
if: steps.sccache_bin_restore.outputs.cache-hit != 'true' | |
with: | |
path: ~/.cargo/bin/sccache | |
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Configure sccache | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- name: Restore verilator dir | |
uses: actions/cache/restore@v3 | |
id: verilator_restore | |
with: | |
path: /opt/verilator | |
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Install verilator | |
if: steps.verilator_restore.outputs.cache-hit != 'true' | |
run: | | |
sudo apt-get install flex bison libfl2 libfl-dev help2man | |
cd /tmp/ | |
git clone -b "${VERILATOR_VERSION}" https://github.com/verilator/verilator | |
cd verilator | |
autoconf | |
./configure --prefix=/opt/verilator CXX="sccache g++" | |
make -j6 | |
sudo make install | |
- name: Save verilator dir | |
uses: actions/cache/save@v3 | |
if: steps.verilator_restore.outputs.cache-hit != 'true' | |
with: | |
path: /opt/verilator | |
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Setup verilator path | |
run: | | |
echo /opt/verilator/bin >> $GITHUB_PATH | |
- name: Restore Risc V Toolchain | |
uses: actions/cache/restore@v3 | |
id: riscv_restore | |
with: | |
path: /opt/riscv | |
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Install Risc V Toolchain | |
if: steps.riscv_restore.outputs.cache-hit != 'true' | |
run: | | |
# Building from source takes around 6.65 GB of disk and download size | |
wget -O toolchain.tar.gz https://github.com/chipsalliance/caliptra-tools/releases/download/gcc-v12.1.0/riscv64-unknown-elf.gcc-12.1.0.tar.gz | |
tar -xzf toolchain.tar.gz -C /opt/ | |
- name: Save riscv dir | |
uses: actions/cache/save@v3 | |
if: steps.riscv_restore.outputs.cache-hit != 'true' | |
with: | |
path: /opt/riscv | |
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Setup riscv path | |
run: | | |
echo /opt/riscv/bin >> $GITHUB_PATH | |
build_matrix: | |
name: Build Smoke Test matrix | |
runs-on: ubuntu-22.04 | |
needs: build_tools | |
outputs: | |
test_names: ${{ steps.output-matrix.outputs.test_names }} | |
env: | |
EXCLUDE_TESTS: "smoke_test_clk_gating, smoke_test_cg_wdt, smoke_test_mbox_cg, smoke_test_kv_cg, smoke_test_doe_cg" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install deps | |
run: | | |
sudo apt-get update -qy && sudo apt-get install -qy --no-install-recommends \ | |
python3-minimal python3-yaml | |
- name: Build matrix | |
id: output-matrix | |
run: | | |
echo "test_names=$(python3 .github/scripts/build_tests_matrix.py)" >> $GITHUB_OUTPUT | |
build_and_test: | |
name: Verilator | |
runs-on: ubuntu-22.04 | |
needs: build_matrix | |
strategy: | |
fail-fast: false | |
matrix: | |
test_name: ${{fromJSON(needs.build_matrix.outputs.test_names)}} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
- name: Restore Cargo index | |
uses: actions/cache/restore@v3 | |
id: cargo_index_restore | |
with: | |
path: ~/.cargo/registry/index | |
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }} | |
- name: Restore sccache binary | |
uses: actions/cache/restore@v3 | |
id: sccache_bin_restore | |
with: | |
path: ~/.cargo/bin/sccache | |
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Restore verilator dir | |
uses: actions/cache/restore@v3 | |
id: verilator_restore | |
with: | |
path: /opt/verilator | |
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Restore Risc V Toolchain | |
uses: actions/cache/restore@v3 | |
id: riscv_restore | |
with: | |
path: /opt/riscv | |
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} | |
- name: Setup verilator path | |
run: | | |
echo /opt/verilator/bin >> $GITHUB_PATH | |
- name: Setup riscv path | |
run: | | |
echo /opt/riscv/bin >> $GITHUB_PATH | |
- name: Run Caliptra Verilator Smoke Test | |
run: | | |
CALIPTRA_ROOT=$(pwd) | |
ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge | |
cd tools/scripts | |
make verilator CALIPTRA_ROOT=$CALIPTRA_ROOT ADAMSBRIDGE_ROOT=$ADAMSBRIDGE_ROOT TESTNAME=${{ matrix.test_name }} | tee output.log | |
# Search the last 30 lines of the output for "TESTCASE PASSED" | |
tail -n 30 output.log | grep "TESTCASE PASSED" | |
# grep will return 0 if the search term is found, and 1 otherwise | |
# A non-zero value will cause the github action to fail. | |
exit $? | |
verify_test_results: | |
name: Verify Verilator Test Results | |
runs-on: ubuntu-22.04 | |
needs: build_and_test | |
# Force to run even if the build_and_test job is skipped for some reason | |
if: ${{ !cancelled() }} | |
steps: | |
- name: Print Verilator Aggregated Result | |
run: | | |
echo "build_and_test has a result of [${{ needs.build_and_test.result }}]" | |
if [[ "${{ needs.build_and_test.result }}" != "success" ]]; then | |
exit 1 | |
fi |