Remove this ReportGenerator/.NET merge workaround after grcov ships

Open
#695 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
github-actions, javascript
Domain
ci-cd, devops

Research direction

Start with the coverage steps in actions/quality/publish-ci-reports/action.yml, especially the ReportGenerator merge and coverage upload matrix preparation. Read the linked grcov pull requests and check whether their changes are available in a release; then verify merged coverage and publication outputs against the report contract. Done means the workaround is removed and coverage publication still meets that contract.

Written by the indexing model from the issue text.

Description

bug need-fix

https://github\.com/mozilla/grcov/pull/1568 and

https://github\.com/mozilla/grcov/pull/1569, and merged coverage plus

publication outputs have been validated against the report contract.

v6.1.0

https://github.com/hoverkraft-tech/ci-github-common/blob/3d85e6252a0c3c45c34d6f5d50db140944f61b85/actions/quality/publish-ci-reports/action.yml#L122-L126


# Gather normalized reports, publish lint/test annotations, and prepare publication files.
# The [publication workflow](../../../.github/workflows/publish-ci-reports.md)
# owns coverage uploads and final summary/comment delivery.
# Every writable PR gets a compact overview. The comment reporters add category
# diagnostics; the Actions summary always retains all details.
# Check out the tested source before calling this action; the reusable workflow does so.
name: Publish CI reports
description: Prepare consolidated report files and coverage uploads, and publish lint/test annotations.
author: hoverkraft
branding:
  icon: bar-chart-2
  color: blue
inputs:
  job-results:
    description: JSON needs context used to display producer job outcomes.
    required: true
  lint-reporters:
    description: Newline-separated `annotations`, `comment` and `code-scanning`. Comment adds lint diagnostics to the PR overview.
    default: annotations
  test-results-reporters:
    description: Newline-separated `annotations` and `comment`. Comment adds test diagnostics to the PR overview.
    default: annotations
  test-coverage-reporters:
    description: Newline-separated `auto`, `github`, `codecov`, `coveralls` and `comment`. Auto uses GitHub when available and falls back to the comment without an external provider. Comment explicitly includes coverage alongside any provider.
    default: auto
outputs:
  artifact-id:
    description: Artifact containing report Markdown and prepared coverage files.
    value: ${{ steps.upload.outputs.artifact-id }}
  coverage-matrix:
    description: JSON include matrix of selected coverage providers, languages, labels and artifact-relative files.
    value: ${{ steps.coverage-plan.outputs.matrix || '{"include":[]}' }}
  upload-coverage:
    description: Whether the coverage matrix contains uploads.
    value: ${{ steps.coverage-plan.outputs.upload || 'false' }}
  summary-file:
    description: Artifact-relative path to the rendered summary.
    value: ${{ steps.render.outputs.summary-file }}
  comment-file:
    description: Artifact-relative path to the rendered PR comment.
    value: ${{ steps.render.outputs.comment-file }}
  comment:
    description: Whether this run can publish its PR overview. The workflow checks freshness before publishing.
    value: ${{ steps.collect.outputs.comment }}
  header:
    description: Stable comment identity for this workflow.
    value: ${{ steps.collect.outputs.header }}
runs:
  using: composite
  steps:
    - id: directory
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      with:
        script: |
          const fs = require('node:fs');
          const root = fs.mkdtempSync(require('node:path').join(process.env.RUNNER_TEMP, 'publish-ci-reports-'));
          await io.mkdirP(root + '/incoming');
          await io.mkdirP(root + '/publication');
          core.setOutput('publication-path', root + '/publication');
          core.setOutput('path', root);
    - id: artifacts
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      with:
        script: |
          const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, {...context.repo,run_id:context.runId,per_page:100});
          core.setOutput('ids', artifacts.filter(artifact => artifact.name.startsWith('ci-report-') && !artifact.expired).map(artifact => artifact.id).join(','));
    - id: download
      if: steps.artifacts.outputs.ids != ''
      uses: $/actions/download-artifact
      with:
        artifact-ids: ${{ steps.artifacts.outputs.ids }}
        path: ${{ steps.directory.outputs.path }}/incoming
    - id: collect
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        ACTION_PATH: ${{ github.action_path }}
        REPORT_DIRECTORY: ${{ steps.directory.outputs.path }}
        JOB_RESULTS: ${{ inputs.job-results }}
        LINT: ${{ inputs.lint-reporters }}
        TESTS: ${{ inputs.test-results-reporters }}
        COVERAGE: ${{ inputs.test-coverage-reporters }}
      with:
        script: |
          const { CollectReports } = await import(require('node:url').pathToFileURL(`${process.env.ACTION_PATH}/dist/index.js`));
          await new CollectReports({core, github, context}).collect({directory:process.env.REPORT_DIRECTORY,jobResults:process.env.JOB_RESULTS,lint:process.env.LINT,tests:process.env.TESTS,coverage:process.env.COVERAGE});
    - uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0
      if: steps.collect.outputs.lint == 'true'
      with:
        reviewdog_version: v0.21.3
    - id: lint
      if: steps.collect.outputs.lint == 'true'
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        ACTION_PATH: ${{ github.action_path }}
        REPORT_DIRECTORY: ${{ steps.directory.outputs.path }}
      with:
        script: |
          const { LintPublication } = await import(require('node:url').pathToFileURL(`${process.env.ACTION_PATH}/dist/index.js`));
          await new LintPublication({core, exec}).lint(process.env.REPORT_DIRECTORY);
    - name: Publish code scanning
      id: code-scanning
      if: ${{ !cancelled() && steps.lint.outputs.sarif != '' }}
      uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
      with:
        sarif_file: ${{ steps.lint.outputs.sarif }}
        category: ci-lint
        wait-for-processing: true
    - id: tests
      if: ${{ !cancelled() && steps.collect.outputs.tests == 'true' }}
      uses: ctrf-io/github-test-reporter@c2e2997afb89a9a515d83121ce7499e272630446 # v1.4.0
      with:
        report-path: ${{ steps.directory.outputs.path }}/tests/*.json
        summary-report: false
        failed-folded-report: true
        summary: false
        pull-request: false
        annotate: ${{ contains(inputs.test-results-reporters, 'annotations') }}
        exit-on-no-files: true
        exit-on-empty: true
      env:
        GITHUB_TOKEN: ${{ github.token }}
    # FIXME: Remove this ReportGenerator/.NET merge workaround after grcov ships
    # https://github.com/mozilla/grcov/pull/1568 and
    # https://github.com/mozilla/grcov/pull/1569, and merged coverage plus
    # publication outputs have been validated against the report contract.
    - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
      if: ${{ !cancelled() && steps.collect.outputs.coverage != '' }}
      with:
        dotnet-version: "10.0.x"
    - name: Merge coverage with ReportGenerator
      id: coverage
      if: ${{ !cancelled() && steps.collect.outputs.coverage != '' }}
      uses: danielpalme/ReportGenerator-GitHub-Action@70c37c4d588cff5bf9cf190830c6f01dfcfb884b # 5.6.1
      with:
        reports: ${{ steps.collect.outputs.coverage }}
        targetdir: ${{ steps.directory.outputs.publication-path }}/coverage
        toolpath: ${{ runner.temp }}/reportgenerator-5.6.1
        reporttypes: Cobertura;JsonSummary
    - name: Prepare coverage upload matrix
      id: coverage-plan
      if: ${{ !cancelled() && steps.coverage.outcome == 'success' }}
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        ACTION_PATH: ${{ github.action_path }}
        REPORT_DIRECTORY: ${{ steps.directory.outputs.path }}
        PUBLICATION_DIRECTORY: ${{ steps.directory.outputs.publication-path }}
      with:
        script: |
          const { CoveragePublication } = await import(require('node:url').pathToFileURL(`${process.env.ACTION_PATH}/dist/index.js`));
          await new CoveragePublication({core, exec}).prepare({directory:process.env.REPORT_DIRECTORY,publicationDirectory:process.env.PUBLICATION_DIRECTORY,tool:`${process.env.RUNNER_TEMP}/reportgenerator-5.6.1/reportgenerator`});
    - name: Render consolidated summary and comment
      id: render
      if: ${{ !cancelled() && steps.collect.outcome == 'success' }}
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        ACTION_PATH: ${{ github.action_path }}
        REPORT_DIRECTORY: ${{ steps.directory.outputs.path }}
        PUBLICATION_DIRECTORY: ${{ steps.directory.outputs.publication-path }}
        TEST_SUMMARY: ${{ steps.tests.outputs.summary }}
        # The CTRF report output can exceed the process environment size limit.
        # Rendering only needs publication outcomes, not other step outputs.
        PUBLICATION_STEPS: |
          {
            "lint": {"outcome": "${{ steps.lint.outcome }}"},
            "code-scanning": {"outcome": "${{ steps.code-scanning.outcome }}"},
            "tests": {"outcome": "${{ steps.tests.outcome }}"},
            "coverage": {"outcome": "${{ steps.coverage.outcome }}"},
            "coverage-plan": {"outcome": "${{ steps.coverage-plan.outcome }}"}
          }
      with:
        script: |
          const { ReportPresentation } = await import(require('node:url').pathToFileURL(`${process.env.ACTION_PATH}/dist/index.js`));
          await new ReportPresentation({core, context}).render({directory:process.env.REPORT_DIRECTORY,publicationDirectory:process.env.PUBLICATION_DIRECTORY,template:`${process.env.ACTION_PATH}/report.md.hbs`,testSummary:process.env.TEST_SUMMARY,steps:JSON.parse(process.env.PUBLICATION_STEPS)});
    - id: upload
      if: ${{ !cancelled() && steps.collect.outcome == 'success' }}
      uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
      with:
        name: ci-publication-${{ github.run_attempt }}
        path: ${{ steps.directory.outputs.publication-path }}
        if-no-files-found: error
        retention-days: 7
    - name: Clean publication workspace
      if: ${{ always() && steps.directory.outputs.path != '' }}
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        REPORT_DIRECTORY: ${{ steps.directory.outputs.path }}
      with:
        script: |
          await io.rmRF(process.env.REPORT_DIRECTORY);

Dominant language
JavaScript
Stars
5
Forks
1
Avg merge
5h 25m
Merged PRs (30d)
60

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hoverkraft-tech/ci-github-common

All issues in hoverkraft-tech/ci-github-common

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.