Replace this temporary ReportGenerator/.NET dependency with grcov

Offen
#693 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Refactoring
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
github-actions, javascript
Bereich
ci-cd, tooling

Rechercherichtung

Start with the coverage preparation and finish logic in actions/quality/prepare-ci-reports/action.yml, including the referenced dist/index.js implementation. Check whether the specified grcov releases support the required LCOV branch counts and Cobertura and Clover inputs, then validate the existing report contract. Done when coverage normalization uses grcov in place of the ReportGenerator/.NET steps and the report contract is validated.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug need-fix

after these changes are released and the report contract is validated:

https://github\.com/mozilla/grcov/pull/1568 (LCOV branch counts)

https://github\.com/mozilla/grcov/pull/1569 (Cobertura and Clover XML inputs).

v6.1.0

https://github.com/hoverkraft-tech/ci-github-common/blob/3d85e6252a0c3c45c34d6f5d50db140944f61b85/actions/quality/prepare-ci-reports/action.yml#L138-L142


# Convert supported native reports with upstream tools and retain one artifact.
# Language actions call this after their command, including failures.
# See the [publication workflow](../../../.github/workflows/publish-ci-reports.md)
# for destinations, permissions, summaries and comments.
#
# ## Custom commands
#
# Run the command in its normal workflow step and prepare its reports afterwards.
# Use a fresh directory owned by that execution. The preparation step still runs
# when the command fails, so diagnostic reports remain available.
#
# ```yaml
# - id: report-directory
#   shell: bash
#   run: echo "path=$(mktemp -d "$RUNNER_TEMP/integration-reports.XXXXXX")" >> "$GITHUB_OUTPUT"
# - id: integration
#   working-directory: application
#   env:
#     CI_REPORTS_DIR: ${{ steps.report-directory.outputs.path }}
#   run: ./scripts/integration-tests
# - uses: hoverkraft-tech/ci-github-common/actions/quality/prepare-ci-reports@d22d9532441a353f54431721affbf3ec7874034b # PR #683
#   if: ${{ !cancelled() && steps.report-directory.outcome == 'success' }}
#   with:
#     directory: ${{ steps.report-directory.outputs.path }}
#     outcome: ${{ steps.integration.outcome }}
#     definition: |
#       {
#         "name": "Integration tests",
#         "project": "application",
#         "reports": [{"kind": "test"}]
#       }
# - name: Clean integration report directory
#   if: ${{ always() && steps.report-directory.outputs.path != '' }}
#   env:
#     REPORT_DIRECTORY: ${{ steps.report-directory.outputs.path }}
#   run: rm -rf -- "$REPORT_DIRECTORY"
# ```
#
# Write supported native outputs under `CI_REPORTS_DIR`. Required missing, malformed
# or empty reports fail the producer. Selected native files and valid converted
# results are retained after failures; unrelated files are not uploaded.
#
# ## Provider action contract
#
# The provider owns command execution and a fresh output directory. After the
# command, including failure, call `actions/quality/prepare-ci-reports` with:
#
# - `directory`: the directory populated by this command.
# - `outcome`: the command's actual step outcome.
# - `definition`: JSON containing `name`, repository-relative `project`, optional
#   `variant`, and `reports` selectors.
#
# ```json
# {
#   "name": "Python tests",
#   "project": "services/api",
#   "variant": { "runtime": "3.14" },
#   "reports": [{ "kind": "test" }, { "kind": "coverage", "language": "Python" }]
# }
# ```
#
# The language action declares required kinds, not filenames. Preparation discovers
# supported JSON, XML, SARIF and LCOV reports recursively in the command's fresh
# directory. A combined Jest/Vitest report supplies tests and coverage and is
# retained once. Missing required kinds or malformed report files fail preparation;
# other valid evidence remains available. Coverage HTML and other ancillary outputs
# are ignored. The publisher receives the same normalized artifact contract.
#
# A custom producer may use a `pattern` to narrow selection, relative to its fresh
# directory, or a `format` for another Reviewdog-supported format. Those are provider
# implementation details, not language workflow inputs. Paths cannot escape through
# traversal or symlinks. Each selected file must be nonempty and at most 100 MiB.
# Source paths for tests and lint are resolved inside the checkout. A
# `path-mapping` object can map container prefixes to repository-relative paths;
# prebuilt source must match the workflow commit.
#
# | Evidence | Supported inputs                                                                                             | Maintained conversion                                         |
# | -------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- |
# | Tests    | JUnit, CTRF, Jest/Vitest JSON                                                                                | JUnit-to-CTRF, Jest JUnit reporter and CTRF schema validation |
# | Lint     | SARIF, Checkstyle, ESLint JSON, named Reviewdog formats                                                      | Reviewdog and Microsoft's ESLint SARIF formatter              |
# | Coverage | Cobertura, LCOV, Clover and ReportGenerator-supported coverage XML; Istanbul JSON or Jest/Vitest coverageMap | ReportGenerator and Istanbul                                  |
#
# Astro diagnostics use a Reviewdog errorformat. The native Super-Linter Markdown
# summary is retained directly; Super-Linter continues to own its annotations.
# CodeQL keeps its own code-scanning results.
#
# A Jest/Vitest JSON file containing `coverageMap` can be selected for both
# tests and coverage. Clover supplies coverage, not test outcomes. Go's provider
# uses gocover-cobertura to convert its native profile before normalization.
#
# The uploaded artifact contains a small `report.json` manifest, normalized CTRF
# and Reviewdog JSON, normalized coverage, and selected native evidence. The
# publisher consumes these standard outputs without reparsing native formats.
# Normalized coverage uses repository-relative file identities so files with the
# same basename in different projects remain separate when merged.
name: Prepare CI reports
description: Validate and normalize test, lint and coverage reports for consolidated publication.
author: hoverkraft
branding:
  icon: file-text
  color: blue
inputs:
  directory:
    description: Fresh report directory populated by the producer command.
    required: true
  definition:
    description: JSON name, project, variant and required report kinds, with optional coverage language. Supported native files are discovered automatically; a pattern can narrow selection for custom producers.
    required: true
  outcome:
    description: Actual producer command outcome (success, failure or cancelled).
    required: true
outputs:
  artifact-id:
    description: Report artifact ID, discovered automatically by the publication workflow.
    value: ${{ steps.upload.outputs.artifact-id }}
runs:
  using: composite
  steps:
    - uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0
      if: contains(inputs.definition, '"lint"')
      with:
        reviewdog_version: v0.21.3
    - id: prepare
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        ACTION_PATH: ${{ github.action_path }}
        REPORT_DIRECTORY: ${{ inputs.directory }}
        DEFINITION: ${{ inputs.definition }}
        OUTCOME: ${{ inputs.outcome }}
      with:
        script: |
          const { PrepareReports } = await import(require('node:url').pathToFileURL(`${process.env.ACTION_PATH}/dist/index.js`));
          await new PrepareReports({core, exec, context}).prepare({
            directory: process.env.REPORT_DIRECTORY, definition: process.env.DEFINITION,
            outcome: process.env.OUTCOME, workspace: process.env.GITHUB_WORKSPACE,
            temporaryDirectory: process.env.RUNNER_TEMP,
          });
    # FIXME: Replace this temporary ReportGenerator/.NET dependency with grcov
    # after these changes are released and the report contract is validated:
    # https://github.com/mozilla/grcov/pull/1568 (LCOV branch counts)
    # https://github.com/mozilla/grcov/pull/1569 (Cobertura and Clover XML inputs).
    - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
      if: steps.prepare.outputs.coverage != ''
      with:
        dotnet-version: "10.0.x"
    - name: Normalize coverage with ReportGenerator
      id: coverage
      if: steps.prepare.outputs.coverage != ''
      uses: danielpalme/ReportGenerator-GitHub-Action@70c37c4d588cff5bf9cf190830c6f01dfcfb884b # 5.6.1
      with:
        reports: ${{ steps.prepare.outputs.coverage }}
        targetdir: ${{ steps.prepare.outputs.directory }}/coverage
        toolpath: ${{ runner.temp }}/reportgenerator-5.6.1
        reporttypes: Cobertura;JsonSummary
        sourcedirs: ${{ steps.prepare.outputs.source-directory }};${{ github.workspace }}
    - id: finish
      if: ${{ !cancelled() && steps.prepare.outputs.directory != '' }}
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        ACTION_PATH: ${{ github.action_path }}
        REPORT_DIRECTORY: ${{ steps.prepare.outputs.directory }}
        COVERAGE_OUTCOME: ${{ steps.coverage.outcome }}
        SOURCE_DIRECTORY: ${{ steps.prepare.outputs.source-directory }}
      with:
        script: |
          const { PrepareReports } = await import(require('node:url').pathToFileURL(`${process.env.ACTION_PATH}/dist/index.js`));
          await new PrepareReports({core, exec, context}).finish(process.env.REPORT_DIRECTORY, process.env.COVERAGE_OUTCOME, `${process.env.RUNNER_TEMP}/reportgenerator-5.6.1/reportgenerator`, process.env.SOURCE_DIRECTORY);
    - id: upload
      if: ${{ !cancelled() && steps.finish.outcome == 'success' }}
      uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
      with:
        name: ${{ steps.prepare.outputs.artifact-name }}
        path: ${{ steps.prepare.outputs.directory }}
        if-no-files-found: error
        retention-days: 7
    - name: Enforce producer result and clean staging
      if: ${{ always() && steps.prepare.outputs.directory != '' }}
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      env:
        REPORT_DIRECTORY: ${{ steps.prepare.outputs.directory }}
        ERRORS: ${{ steps.finish.outputs.errors }}
        OUTCOME: ${{ inputs.outcome }}
        REPORT_FAILED: ${{ steps.finish.outputs.failed }}
      with:
        script: |
          await io.rmRF(process.env.REPORT_DIRECTORY);
          const errors = JSON.parse(process.env.ERRORS || '[]');
          if (errors.length) core.setFailed(errors.join('\n'));
          if (process.env.OUTCOME !== 'success') core.setFailed(`Producer command ${process.env.OUTCOME}. See its logs and retained reports.`);
          if (process.env.REPORT_FAILED === 'true') core.setFailed('The retained report contains failed checks.');

Vorherrschende Sprache
JavaScript
Sterne
5
Forks
1
Ø Merge
5 Std. 25 Min.
Gemergte PRs (30 T.)
60

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus hoverkraft-tech/ci-github-common

Alle Issues in hoverkraft-tech/ci-github-common

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.