From d1f8acd05635d9c940e54798365cf7edbeed573a Mon Sep 17 00:00:00 2001 From: Caleb Whitehead Date: Wed, 22 Jan 2025 15:34:08 -0800 Subject: [PATCH] Move run_vltr check to pre-run-check and share result to all Verilator-based workflows --- .github/workflows/build-test-verilator.yml | 70 +++++---------------- .github/workflows/interactive-debugging.yml | 43 +++++++++++++ .github/workflows/pre-run-check.yml | 48 ++++++++++++++ .github/workflows/pull_request.yml | 6 ++ 4 files changed, 111 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build-test-verilator.yml b/.github/workflows/build-test-verilator.yml index 9dc46578b..456a8ced0 100644 --- a/.github/workflows/build-test-verilator.yml +++ b/.github/workflows/build-test-verilator.yml @@ -6,6 +6,12 @@ on: push: branches: ["main", "dev-goog", "dev-msft"] workflow_call: + inputs: + run_vltr: + description: "Control parameter indicating if Verilator tests should be run or skipped" + required: true + type: string + default: 'true' workflow_dispatch: env: @@ -20,52 +26,10 @@ env: SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1e jobs: - # Verilator is always run outside of the Pull Request context. - # For Pull Requests, conditionally run based on evaluation of - # modified file set - evaluate_if_run: - name: Evaluate if Verilator Will Run - runs-on: ubuntu-22.04 - outputs: - run_vltr: ${{ steps.do_decide.outputs.run }} - env: - DO_EVAL: ${{ github.event_name == 'pull_request' }} - - steps: - - uses: actions/checkout@v3 - if: ${{ env.DO_EVAL == 'true' }} - with: - submodules: 'true' - - # If any non-documentation files have been modified as part of a - # Pull Request, run the Verilator checks - # Otherwise, skip Verilator - - name: Do Git Diff - id: do_git_diff - if: ${{ env.DO_EVAL == 'true' }} - run: | - if [[ -n "$(git diff --name-only --merge-base ${{ github.event.pull_request.base_ref }} | grep -v '\\.md\\|\\.png\\|\\.github\\/workflows')" ]]; then - echo "src_mods=true" >> "${GITHUB_OUTPUT}" - else - echo "src_mods=false" >> "${GITHUB_OUTPUT}" - fi - - - name: Decide - id: do_decide - run: | - if [[ "${{ env.DO_EVAL }}" == "false" ]]; then - echo "run=true" >> "${GITHUB_OUTPUT}" - elif [[ "${{ steps.do_git_diff.outputs.src_mods }}" == "true" ]]; then - echo "run=true" >> "${GITHUB_OUTPUT}" - else - echo "run=false" >> "${GITHUB_OUTPUT}" - fi - build_tools: name: Build Tools runs-on: ubuntu-22.04 - needs: evaluate_if_run - if: ${{ needs.evaluate_if_run.outputs.run_vltr == 'true' }} + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} steps: - uses: actions/checkout@v3 @@ -160,10 +124,8 @@ jobs: build_matrix: name: Build Smoke Test matrix runs-on: ubuntu-22.04 - needs: - - build_tools - - evaluate_if_run - if: ${{ needs.evaluate_if_run.outputs.run_vltr == 'true' }} + needs: build_tools + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} outputs: test_names: ${{ steps.output-matrix.outputs.test_names }} env: @@ -182,10 +144,8 @@ jobs: build_and_test: name: Verilator runs-on: ubuntu-22.04 - needs: - - build_matrix - - evaluate_if_run - if: ${{ needs.evaluate_if_run.outputs.run_vltr == 'true' }} + needs: build_matrix + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} strategy: fail-fast: false @@ -248,16 +208,14 @@ jobs: verify_test_results: name: Verify Verilator Test Results runs-on: ubuntu-22.04 - needs: - - build_and_test - - evaluate_if_run + needs: build_and_test # Force to run even if the build_and_test job is skipped for any reason if: ${{ !cancelled() }} steps: - name: Print Verilator Aggregated Result run: | - echo "Run Verilator check has a result of [${{ needs.evaluate_if_run.outputs.run_vltr }}]" - if [[ "${{ needs.evaluate_if_run.outputs.run_vltr }}" != "true" ]]; then + echo "Run Verilator check has a result of [${{ on.workflow_call.inputs.run_vltr }}]" + if [[ "${{ on.workflow_call.inputs.run_vltr }}" == "false" ]]; then exit 0 fi echo "build_and_test has a result of [${{ needs.build_and_test.result }}]" diff --git a/.github/workflows/interactive-debugging.yml b/.github/workflows/interactive-debugging.yml index a61092a85..b7a14d76b 100644 --- a/.github/workflows/interactive-debugging.yml +++ b/.github/workflows/interactive-debugging.yml @@ -6,12 +6,19 @@ on: push: branches: ["main", "dev-goog", "dev-msft", "dev-public"] workflow_call: + inputs: + run_vltr: + description: "Control parameter indicating if Verilator tests should be run or skipped" + required: true + type: string + default: 'true' workflow_dispatch: jobs: build_verilator: name: runs-on: ubuntu-22.04 + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} env: CARGO_INCREMENTAL: 0 @@ -90,6 +97,7 @@ jobs: build_openocd: name: runs-on: ubuntu-22.04 + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} env: CARGO_INCREMENTAL: 0 @@ -182,12 +190,14 @@ jobs: steps: - name: Install Risc V Toolchain + if: ${{ on.workflow_call.inputs.run_vltr == '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: Install dependencies + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | # For some reason GDB requires libpython3.8.so sudo add-apt-repository ppa:deadsnakes/ppa -y @@ -195,18 +205,21 @@ jobs: libpython3.8 - name: Download Verilator binaries + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} uses: actions/download-artifact@v4 with: name: verilator path: /opt - name: Download OpenOCD binaries + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} uses: actions/download-artifact@v4 with: name: openocd path: /opt - name: Unpack binaries + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | pushd /opt tar -zxvf verilator.tar.gz @@ -214,15 +227,18 @@ jobs: popd - name: Setup path + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | echo /opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin >> $GITHUB_PATH - name: Clone repository + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} uses: actions/checkout@v3 with: submodules: 'true' - name: Build Verilated simulation + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -232,6 +248,7 @@ jobs: make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile program.hex TESTNAME=infinite_loop - name: Test core register access + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -240,6 +257,7 @@ jobs: /bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./dump_and_compare.sh' - name: Test memory access + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -248,6 +266,7 @@ jobs: /bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./mem_access.sh' - name: Test peripheral access + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -255,6 +274,13 @@ jobs: ${CALIPTRA_ROOT}/.github/scripts/gdb_test.sh \ /bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./peripheral_access.sh' + - name: Generate result + run: | + if [[ "${{ on.workflow_call.inputs.run_vltr }}" == 'true' ]]; then + echo "Reporting a passing status after skipping [${{ github.job }}] due to run_vltr: [${{ on.workflow_call.inputs.run_vltr }}]" + exit 0 + fi + openocd_tests: name: Run OpenOCD debugging tests runs-on: ubuntu-22.04 @@ -268,24 +294,28 @@ jobs: steps: - name: Install Risc V Toolchain + if: ${{ on.workflow_call.inputs.run_vltr == '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: Download Verilator binaries + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} uses: actions/download-artifact@v4 with: name: verilator path: /opt - name: Download OpenOCD binaries + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} uses: actions/download-artifact@v4 with: name: openocd path: /opt - name: Unpack binaries + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | pushd /opt tar -zxvf verilator.tar.gz @@ -293,15 +323,18 @@ jobs: popd - name: Setup path + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | echo /opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin >> $GITHUB_PATH - name: Clone repository + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} uses: actions/checkout@v3 with: submodules: 'true' - name: Build Verilated simulation + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -311,6 +344,7 @@ jobs: make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile program.hex TESTNAME=infinite_loop - name: Test peripheral access with core in reset + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -320,6 +354,7 @@ jobs: -f ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop/peripheral_access.tcl - name: Build Verilated simulation + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -329,6 +364,7 @@ jobs: make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile program.hex TESTNAME=infinite_loop - name: Test JTAG access with clock gating + if: ${{ on.workflow_call.inputs.run_vltr == 'true' }} run: | export CALIPTRA_ROOT=$(pwd) export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge @@ -336,3 +372,10 @@ jobs: ${CALIPTRA_ROOT}/.github/scripts/openocd_test.sh \ -f board/caliptra-verilator.cfg \ -f ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop/jtag_cg.tcl + + - name: Generate result + run: | + if [[ "${{ on.workflow_call.inputs.run_vltr }}" == 'true' ]]; then + echo "Reporting a passing status after skipping [${{ github.job }}] due to run_vltr: [${{ on.workflow_call.inputs.run_vltr }}]" + exit 0 + fi diff --git a/.github/workflows/pre-run-check.yml b/.github/workflows/pre-run-check.yml index cd5697829..b819ec1e2 100644 --- a/.github/workflows/pre-run-check.yml +++ b/.github/workflows/pre-run-check.yml @@ -16,6 +16,12 @@ on: type: string default: 'main' workflow_call: + outputs: + run_vltr: + description: "Control parameter indicating if Verilator tests should be run or skipped" + required: true + type: string + value: ${{ jobs.evaluate_if_run.outputs.run_vltr }} env: MSFT_ACTORS: ( "Nitsirks" "calebofearth" "mojtaba-bisheh" "anjpar" "upadhyayulakiran" "nileshbpat" "ekarabu" ) @@ -218,3 +224,45 @@ jobs: export CALIPTRA_ROOT=$GITHUB_WORKSPACE export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge $GITHUB_WORKSPACE/.github/scripts/pr_rdl_check.sh "origin/$TARGET_BR" + + # Verilator is always run outside of the Pull Request context. + # For Pull Requests, conditionally run based on evaluation of + # modified file set + evaluate_if_run: + name: Evaluate if Verilator Will Run + runs-on: ubuntu-22.04 + outputs: + run_vltr: ${{ steps.do_decide.outputs.run }} + env: + DO_EVAL: ${{ github.event_name == 'pull_request' }} + + steps: + - uses: actions/checkout@v4 + if: ${{ env.DO_EVAL == 'true' }} + with: + submodules: 'true' + + # If only documentation files have been modified as part of a + # Pull Request, skip the Verilator checks + # Otherwise, run Verilator + - name: Do Git Diff + id: do_git_diff + if: ${{ env.DO_EVAL == 'true' }} + run: | + if [[ -n "$(git diff --name-only --merge-base ${{ github.event.pull_request.base_ref }} | grep -v '\\.md\\|\\.png\\|\\.github\\/workflows')" ]]; then + echo "src_mods=true" >> "${GITHUB_OUTPUT}" + else + echo "src_mods=false" >> "${GITHUB_OUTPUT}" + fi + + - name: Decide + id: do_decide + run: | + if [[ "${{ env.DO_EVAL }}" == "false" ]]; then + echo "run=true" >> "${GITHUB_OUTPUT}" + elif [[ "${{ steps.do_git_diff.outputs.src_mods }}" == "true" ]]; then + echo "run=true" >> "${GITHUB_OUTPUT}" + else + echo "run=false" >> "${GITHUB_OUTPUT}" + fi + diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1ca2cb01c..b5e5afded 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -14,8 +14,14 @@ jobs: uses: ./.github/workflows/pre-run-check.yml verilator: uses: ./.github/workflows/build-test-verilator.yml + needs: pre_run + with: + run_vltr: ${{ needs.pre_run.outputs.run_vltr }} interactive_dbg: uses: ./.github/workflows/interactive-debugging.yml + needs: pre_run + with: + run_vltr: ${{ needs.pre_run.outputs.run_vltr }} doc_gen: uses: ./.github/workflows/doc-gen.yml permissions: