Summary
The CI workflow (.github/workflows/ci.yml) will fail on pull requests opened from forks, even when all tests pass, because the Report Test Results step can't get a writable token on forked-PR runs.
This was diagnosed in the AutoMapper repo (LuckyPennySoftware/AutoMapper#4642); MediatR's CI uses the same dorny/test-reporter pattern and is affected the same way.
Symptom
Error: HttpError: Resource not accessible by integration
from the Report Test Results step:
- name: Report Test Results
uses: dorny/test-reporter@v1.9.1
if: success() || failure()
with:
name: Test Results (Windows)
path: '**/TestResults/**/*.trx'
reporter: dotnet-trx
Cause
dorny/test-reporter calls the Checks API (POST /repos/.../check-runs) to publish results, which requires checks: write. The workflow declares permissions: checks: write, but GitHub forcibly downgrades GITHUB_TOKEN to read-only for pull_request runs triggered from a fork (so untrusted PR code can't write to the base repo). The API responds with 403 "Resource not accessible by integration" ("integration" = the GitHub Actions app), and the action's default fail-on-error: true fails the whole job — even though the tests passed.
Note: MediatR's ci.yml has no Azure-login step, so (unlike AutoMapper) only the test-reporter step is affected here. Push to MyGet is already correctly gated to main.
Suggested fix
- Minimal: add
continue-on-error: true to the Report Test Results step so report publishing is best-effort and never fails the build (the Build and Test step remains the source of truth for pass/fail).
- Fuller (optional): adopt the
workflow_run pattern — the pull_request build uploads the .trx files as an artifact, and a separate workflow_run-triggered workflow running in the base-repo context (with checks: write) publishes the report. This gives fork PRs real inline test reports instead of skipping them.
Reference
Diagnosis and stop-gap fix: LuckyPennySoftware/AutoMapper#4642 (and PR LuckyPennySoftware/AutoMapper#4634).
Summary
The
CIworkflow (.github/workflows/ci.yml) will fail on pull requests opened from forks, even when all tests pass, because theReport Test Resultsstep can't get a writable token on forked-PR runs.This was diagnosed in the AutoMapper repo (LuckyPennySoftware/AutoMapper#4642); MediatR's CI uses the same
dorny/test-reporterpattern and is affected the same way.Symptom
from the
Report Test Resultsstep:Cause
dorny/test-reportercalls the Checks API (POST /repos/.../check-runs) to publish results, which requireschecks: write. The workflow declarespermissions: checks: write, but GitHub forcibly downgradesGITHUB_TOKENto read-only forpull_requestruns triggered from a fork (so untrusted PR code can't write to the base repo). The API responds with 403 "Resource not accessible by integration" ("integration" = the GitHub Actions app), and the action's defaultfail-on-error: truefails the whole job — even though the tests passed.Note: MediatR's
ci.ymlhas no Azure-login step, so (unlike AutoMapper) only the test-reporter step is affected here.Push to MyGetis already correctly gated tomain.Suggested fix
continue-on-error: trueto theReport Test Resultsstep so report publishing is best-effort and never fails the build (theBuild and Teststep remains the source of truth for pass/fail).workflow_runpattern — thepull_requestbuild uploads the.trxfiles as an artifact, and a separateworkflow_run-triggered workflow running in the base-repo context (withchecks: write) publishes the report. This gives fork PRs real inline test reports instead of skipping them.Reference
Diagnosis and stop-gap fix: LuckyPennySoftware/AutoMapper#4642 (and PR LuckyPennySoftware/AutoMapper#4634).