diff --git a/.github/workflows/ci-tests-e2e.yaml b/.github/workflows/ci-tests-e2e.yaml index 9d3371d453d..f56f946ddb6 100644 --- a/.github/workflows/ci-tests-e2e.yaml +++ b/.github/workflows/ci-tests-e2e.yaml @@ -438,7 +438,7 @@ jobs: }} uses: ./.github/workflows/ci-tests-e2e-coverage-package.yaml with: - source_sha: ${{ github.event.pull_request.head.sha || github.sha }} + source_sha: ${{ github.sha }} # A shard that died partway still uploads a tracefile, and one that # produced none fails its own upload, so the matrix verdict is what # makes the merge trustworthy for trend reporting. diff --git a/scripts/cicd/package-e2e-coverage.sh b/scripts/cicd/package-e2e-coverage.sh index 63f7e9556f9..6a2b41ddbca 100755 --- a/scripts/cicd/package-e2e-coverage.sh +++ b/scripts/cicd/package-e2e-coverage.sh @@ -64,7 +64,14 @@ ADD_ARGS=() for file in "${COVERAGE_FILES[@]}"; do ADD_ARGS+=(-a "$file") done -lcov "${ADD_ARGS[@]}" -o "$COVERAGE_DIR/coverage.lcov" +# Istanbul can emit the same nested function name at different source lines in +# one tracefile (for example LiteGraph's inner_clicked callbacks). Function +# coverage is not published below, so retain the valid line data instead of +# failing the whole coverage package on lcov's function-metadata consistency +# check. `corrupt` is paired with `inconsistent` because lcov reports both for +# this single condition. +lcov "${ADD_ARGS[@]}" -o "$COVERAGE_DIR/coverage.lcov" \ + --ignore-errors inconsistent,corrupt MERGED_SF=$(grep -c '^SF:' "$COVERAGE_DIR/coverage.lcov" || true) MERGED_LH=$(awk -F: '/^LH:/{s+=$2}END{print s+0}' "$COVERAGE_DIR/coverage.lcov") diff --git a/scripts/cicd/package-e2e-coverage.test.ts b/scripts/cicd/package-e2e-coverage.test.ts index 4f1bb8094d4..e8a468ff75b 100644 --- a/scripts/cicd/package-e2e-coverage.test.ts +++ b/scripts/cicd/package-e2e-coverage.test.ts @@ -83,6 +83,10 @@ set -euo pipefail if [[ "$1" == "--remove" ]]; then exit 0 fi +if [[ " $* " != *" --ignore-errors inconsistent,corrupt "* ]]; then + echo 'missing function-metadata error allowance' >&2 + exit 64 +fi inputs=() output='' while [[ $# -gt 0 ]]; do @@ -193,6 +197,18 @@ describe('package-e2e-coverage.sh', () => { expect(result.output).not.toContain('::warning::') }) + it('preserves line coverage when function metadata is inconsistent', () => { + using fixture = coverageFixture() + fixture.writeShard('e2e-coverage-shard-1', coverage('src')) + + const result = fixture.run(true) + + expect(result.status).toBe(0) + expect( + readFileSync(join(fixture.output, 'coverage.lcov'), 'utf8') + ).toContain('SF:src/file 0.ts') + }) + // Preserves #15342: a flaky shard must not discard every other shard's real // coverage. It stays published for Codecov and the PR comment, but flagged. it('publishes a run with a whitespace path but flags a red matrix', () => { @@ -302,6 +318,16 @@ describe('completeness gate wiring', () => { ) }) + it('packages coverage against the revision exercised by the workflow', () => { + const job = field( + readWorkflow('.github/workflows/ci-tests-e2e.yaml'), + 'jobs', + 'upload-e2e-coverage' + ) + + expect(field(job, 'with', 'source_sha')).toBe('${{ github.sha }}') + }) + it('gates the saved E2E baseline on a whole merge', () => { const steps = jobSteps( readWorkflow('.github/workflows/coverage-slack-notify.yaml')