diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd4fdef6..81aa485d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -473,6 +473,7 @@ jobs: - build - discover-tests - test + - coverage steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 @@ -484,14 +485,17 @@ jobs: with: path: all-test-results - # Dependabot runs get a read-only token whatever the job asks for, so the - # check run and PR comment this writes can't be published there. The - # status step below still fails the job when a test did. + # Dependabot and fork PR runs get a read-only token whatever the job + # asks for, so the check run and PR comment this writes can't be + # published there. The status step below still fails the job when a + # test did. - name: Publish test results uses: EnricoMi/publish-unit-test-result-action@d0a4676d0e0b938bc201470d88276b7c74c712b3 # v2.24.0 if: >- ${{ always() && needs.discover-tests.outputs.has_tests == 'true' && - github.actor != 'dependabot[bot]' }} + github.actor != 'dependabot[bot]' && + (github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name == github.repository) }} with: files: | all-test-results/**/*.trx @@ -508,6 +512,7 @@ jobs: BUILD_STATUS: ${{ needs.build.result }} DISCOVER_STATUS: ${{ needs.discover-tests.result }} TEST_STATUS: ${{ needs.test.result }} + COVERAGE_STATUS: ${{ needs.coverage.result }} run: | { echo "## Test Execution Summary" @@ -516,6 +521,7 @@ jobs: echo "- **Build:** ${BUILD_STATUS}" echo "- **Discovered Tests:** ${DISCOVER_STATUS}" echo "- **Test Matrix:** ${TEST_STATUS}" + echo "- **Coverage (60% gate):** ${COVERAGE_STATUS}" echo "" echo "### Artifacts" echo "- Test and coverage reports are in Actions artifacts" @@ -528,11 +534,13 @@ jobs: } >> "$GITHUB_STEP_SUMMARY" # This job is the required status check that stands in for the - # dynamically named "Tests: …" matrix jobs, so it must fail when - # they do. A skipped test matrix (no test projects) still passes. + # dynamically named "Tests: …" matrix jobs and the 60% coverage + # gate, so it must fail when any of them does. A skipped test + # matrix (no test projects) still passes. if [[ "$BUILD_STATUS" =~ ^(failure|cancelled)$ \ || "$DISCOVER_STATUS" =~ ^(failure|cancelled)$ \ - || "$TEST_STATUS" =~ ^(failure|cancelled)$ ]]; then + || "$TEST_STATUS" =~ ^(failure|cancelled)$ \ + || "$COVERAGE_STATUS" =~ ^(failure|cancelled)$ ]]; then echo "❌ **Overall Status:** FAILED" >> "$GITHUB_STEP_SUMMARY" exit 1 else