Omit run URL when GITHUB_REPOSITORY or GITHUB_RUN_ID is absent (#132) · buildkite/test-collector-python@1ef260c · GitHub
Skip to content
This repository was archived by the owner on Aug 24, 2026. It is now read-only.

Commit 1ef260c

Browse files
pdaSirHegel
andauthored
Omit run URL when GITHUB_REPOSITORY or GITHUB_RUN_ID is absent (#132)
_github_actions_env builds the URL with an f-string over two values that _get_env can legitimately return as None. When either is missing, the interpolation produces the literal string 'None' inside the URL: https://github.com/None/actions/runs/None That value is then a non-None string, so as_json() keeps it and sends it to the API instead of omitting the field. The other two CI branches do not have this problem. _buildkite_env and _circle_ci_env pass _get_env(...) straight through, so a missing value stays None and as_json() filters it out. This brings the GitHub Actions branch in line with them. The guard clause above only requires GITHUB_ACTION, GITHUB_RUN_NUMBER and GITHUB_RUN_ATTEMPT, so reaching this code with either of the other two unset is possible — most plausibly through RunEnvBuilder's documented injected environment, or a runner with a trimmed environment. Adds a regression test that fails on the current code with the 'None' URL and passes with the change. Co-authored-by: SirHegel <SirHegel@users.noreply.github.com>
2 parents bbf3ad1 + cdc0782 commit 1ef260c

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/buildkite_test_collector/collector/run_env.py

Lines changed: 5 additions & 1 deletion

tests/buildkite_test_collector/collector/test_run_env.py

Lines changed: 12 additions & 0 deletions

0 commit comments

Comments
 (0)