--- # DESCRIPTION: Github actions config # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 name: reusable-test on: workflow_call: inputs: archive: description: "Name of the repository archive artifact from reusable-build" required: true type: string cc: description: "Compiler to use: 'gcc' or 'clang'" required: true type: string dev-gcov: description: "Collect gcov coverage data from the test run" required: false default: false type: boolean reloc: description: "Relocate the installation before testing" required: false default: false type: boolean runs-on: description: "Runner to test on, e.g. ubuntu-24.04" required: true type: string suite: description: "Test suite to run, e.g. dist-vlt-0" required: true type: string permissions: contents: read actions: read env: CCACHE_COMPILERCHECK: content CCACHE_DIR: ${{ github.workspace }}/.ccache CXX: ${{ inputs.cc == 'clang' && 'clang++' || 'g++' }} defaults: run: shell: bash working-directory: repo jobs: test: runs-on: ${{ inputs.runs-on }} name: Test steps: - name: Download repository archive uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: name: ${{ inputs.archive }} path: ${{ github.workspace }} - name: Unpack repository archive working-directory: ${{ github.workspace }} run: | tar --zstd -x -f ${{ inputs.archive }} ls -lsha # Test-job ccache is stored as an artifact, not actions/cache - name: Restore ccache id: ccache uses: ./repo/.github/actions/artifact-cache with: mode: restore path: ${{ env.CCACHE_DIR }} key: ccache-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ inputs.suite }} - name: Install test dependencies run: | ./ci/ci-install.bash test - name: Set up Python venv uses: ./repo/.github/actions/setup-venv with: save: ${{ github.ref == 'refs/heads/master' }} - name: Test id: run-test continue-on-error: true run: | source .venv/bin/activate ./ci/ci-test.bash \ --suite ${{ inputs.suite }} \ ${{ inputs.reloc && format('--reloc {0}/reloc', github.workspace) || '' }} - name: Combine code coverage data if: ${{ inputs.dev-gcov }} run: | make coverage-combine mv obj_coverage/verilator.info obj_coverage/verilator-${{ inputs.suite }}.info ls -lsha obj_coverage - name: Upload code coverage data if: ${{ inputs.dev-gcov }} uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: path: ${{ github.workspace }}/repo/obj_coverage/verilator-${{ inputs.suite }}.info name: code-coverage-${{ inputs.suite }} - name: Save ccache if: ${{ !cancelled() }} uses: ./repo/.github/actions/artifact-cache with: mode: save path: ${{ env.CCACHE_DIR }} key: ${{ steps.ccache.outputs.key }} # Keep master's cache around longer; PR/branch caches churn faster retention-days: ${{ github.ref == 'refs/heads/master' && 7 || 3 }} - name: Fail job if a test failed if: ${{ steps.run-test.outcome == 'failure' && !cancelled() }} run: |- echo "Click on '> Tests' arrow above (or on other steps), to expand it, and see the failure reasons" exit 1