Scrub runner event env in test harness #2

Merged
stephen merged 1 commit from fix/harness-event-path-scrub into main 2026-08-06 00:04:20 +00:00
Owner

What changed:

  • Scrubbed ambient runner GITHUB_* context from tests/run.sh child process environments before invoking the action or helper under test.
  • Scrubbed variables: GITHUB_EVENT_PATH, GITHUB_REPOSITORY, GITHUB_REF, GITHUB_REF_NAME, GITHUB_SHA, GITHUB_RUN_ID, GITHUB_RUN_NUMBER, GITHUB_ACTIONS, GITHUB_WORKSPACE, GITHUB_OUTPUT, GITHUB_STATE, GITHUB_STEP_SUMMARY, GITHUB_PATH, GITHUB_ENV.
  • Harness-owned values are deliberately set back where needed, for example fixture GITHUB_OUTPUT/GITHUB_STATE/GITHUB_PATH/GITHUB_ENV files, GITHUB_WORKSPACE for cache-key tests, and repo/ref/sha/run metadata fixtures.

Why:

  • A real runner can export GITHUB_EVENT_PATH and other GITHUB_* values. The harness should not let those ambient values override its fixtures.

Verification:

  • Behavioural: before the fix, GITHUB_EVENT_PATH=/tmp/evt.json bash tests/run.sh failed 5 passed / 2 failed because context.payload selected PR 1 instead of the fixture INPUT_PR-NUMBER=3. After the fix, the same leaked-event run passes 7 passed / 0 failed.
What changed: - Scrubbed ambient runner GITHUB_* context from tests/run.sh child process environments before invoking the action or helper under test. - Scrubbed variables: GITHUB_EVENT_PATH, GITHUB_REPOSITORY, GITHUB_REF, GITHUB_REF_NAME, GITHUB_SHA, GITHUB_RUN_ID, GITHUB_RUN_NUMBER, GITHUB_ACTIONS, GITHUB_WORKSPACE, GITHUB_OUTPUT, GITHUB_STATE, GITHUB_STEP_SUMMARY, GITHUB_PATH, GITHUB_ENV. - Harness-owned values are deliberately set back where needed, for example fixture GITHUB_OUTPUT/GITHUB_STATE/GITHUB_PATH/GITHUB_ENV files, GITHUB_WORKSPACE for cache-key tests, and repo/ref/sha/run metadata fixtures. Why: - A real runner can export GITHUB_EVENT_PATH and other GITHUB_* values. The harness should not let those ambient values override its fixtures. Verification: - Behavioural: before the fix, GITHUB_EVENT_PATH=/tmp/evt.json bash tests/run.sh failed 5 passed / 2 failed because context.payload selected PR 1 instead of the fixture INPUT_PR-NUMBER=3. After the fix, the same leaked-event run passes 7 passed / 0 failed.
Scrub runner event env in test harness
All checks were successful
test / unit (pull_request) Successful in 4s
5768356dcf
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
fjord/forgejo-labeler-action!2
No description provided.