--- # DESCRIPTION: Github actions config # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 name: Code coverage on: workflow_dispatch: schedule: - cron: '0 0 * * 0' # weekly pull_request: types: [opened, synchronize, reopened, labeled, unlabeled] permissions: contents: read actions: read defaults: run: shell: bash concurrency: # At most 1 job per branch. Auto cancel all but scheduled jobs group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name != 'schedule' }} jobs: build: name: Build # Only run scheduled jobs if explicitly enabled for that repo (e.g.: not on forks) # Only run pull request jobs if labelled as needing an coverage run # Always run workflow dispatch jobs if: | (github.event_name == 'schedule' && vars.ENABLE_SCHEDULED_JOBS == 'true') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'pr: dev-coverage')) || (github.event_name == 'workflow_dispatch') uses: ./.github/workflows/reusable-build.yml with: cc: gcc dev-gcov: true runs-on: ubuntu-24.04 # For pull requests, build the head of the pull request branch, not the # merge commit, otherwise patch coverage would include the changes # between the root of the pull request and the target branch sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} test: name: Test | ${{ matrix.test }}${{ matrix.num }} needs: build uses: ./.github/workflows/reusable-test.yml with: archive: ${{ needs.build.outputs.archive }} cc: gcc dev-gcov: true runs-on: ubuntu-24.04 suite: ${{ matrix.test }}${{ matrix.num }} strategy: fail-fast: false matrix: test: [coverage-vlt-, coverage-vltmt-] num: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] include: - {test: coverage-dist, num: ''} publish-codecov: name: Publish results to codecov.io needs: test if: ${{ contains(needs.*.result, 'success') && !cancelled() }} runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - name: Download code coverage data uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: pattern: code-coverage-* path: obj_coverage merge-multiple: true - name: List files id: list-files run: | ls -lsha obj_coverage find obj_coverage -type f | paste -sd, | sed "s/^/files=/" >> "$GITHUB_OUTPUT" - name: Upload to codecov.io uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 with: disable_file_fixes: true disable_search: true fail_ci_if_error: true files: ${{ steps.list-files.outputs.files }} plugins: noop token: ${{ secrets.CODECOV_TOKEN }} verbose: true prepare-report: name: Prepare HTML report needs: [build, test] if: ${{ contains(needs.*.result, 'success') && !cancelled() }} runs-on: ubuntu-24.04 steps: - name: Download repository archive uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: name: ${{ needs.build.outputs.archive }} path: ${{ github.workspace }} - name: Unpack repository archive run: | tar --zstd -x -f ${{ needs.build.outputs.archive }} ls -lsha - name: Install dependencies uses: ./repo/.github/actions/install-deps with: stage: coverage - name: Download code coverage data uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: pattern: code-coverage-* path: repo/obj_coverage merge-multiple: true - name: Create report working-directory: repo env: GH_TOKEN: ${{ github.token }} run: | ci/ci-coverage-report.bash \ ${{ github.run_id }} \ "${{ github.event_name == 'pull_request' && github.event.number || '' }}" \ "${{ github.event.pull_request.base.sha }}" \ "${{ github.event.pull_request.head.sha }}" # Create the report artifact. Note there is no report if the patch is empty. mkdir ../report-artifact [ ! -d obj_coverage/report ] || mv obj_coverage/report ../report-artifact/ if [[ "${{ github.event_name }}" == "pull_request" ]]; then echo ${{ github.event.number }} > ../report-artifact/pr-number.txt fi - name: Upload report uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: path: report-artifact name: coverage-report - name: Upload PR notification if: ${{ github.event_name == 'pull_request' }} uses: ./repo/.github/actions/upload-pr-notification with: path: repo/notification key: coverage # Create GitHub issue for failed scheduled jobs # This should always be the last job (we want an issue if anything breaks) create-issue: name: Create issue on failure needs: [publish-codecov, prepare-report] if: ${{ github.event_name == 'schedule' && github.repository == 'verilator/verilator' && github.run_attempt == 1 && failure() && !cancelled() }} runs-on: ubuntu-24.04 steps: # Creating issues requires elevated privilege - name: Generate access token id: generate-token uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 with: client-id: ${{ vars.VERILATOR_CI_ID }} private-key: ${{ secrets.VERILATOR_CI_KEY }} owner: verilator repositories: verilator permission-issues: write - name: Create issue env: GH_TOKEN: ${{ steps.generate-token.outputs.token }} run: |- echo "This issue was created automatically by the GitHub Actions CI due to the failure of a scheduled Code coverage run." >> body.txt echo "" >> body.txt echo "Workflow status: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> body.txt gh issue --repo ${{ github.repository }} create \ --title "Code coverage run #${{ github.run_number }} Failed" \ --body-file body.txt \ --label new \ --assignee gezalore,wsnyder