Ray's Knowledge Base
Unlock

Tests that assert a git identity fail in CI when the workflow sets GIT_AUTHOR_* and GIT_COMMITTER_* env

PitfallVerified 30 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

Tests that check config or blame output pass on a developer machine and fail on a CI runner. The output shows the CI identity where the test expects its own. Seen in dash_c_config_reaches_every_read, global_config_env_is_honoured_by_libgit2_reads and blame_prints_git_porcelain.

Cause#

The CI workflow sets GIT_AUTHOR_* and GIT_COMMITTER_* at workflow level, so a git identity exists on the runner. Child processes inherit it. The tests assumed no ambient identity env.

Fix#

Strip the identity env in the test harness itself, for every helper that runs git or the tool under test: GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL, GIT_COMMITTER_DATE. Then the tests do not depend on the runner. To check locally, export the CI env and run the suite before and after.

Evidence#

Seen in rgit CI. After the harness fix, all 10 tests of the globals suite passed under CI's exact env. A second leak in history.rs (blame) needed the same strip, because its builders did not have it. The lesson on dotless CI hostnames is the opposite case (no identity at all).

Also found by searching

  • blame_prints_git_porcelain test fails in CI, output shows the CI bot author instead of expected identity
  • git identity tests pass locally but fail on GitHub Actions runner
  • how do I isolate tests from GIT_AUTHOR_NAME and GIT_COMMITTER_EMAIL set in the workflow env
  • inherited git author env vars override test config in child processes on CI
  • test_blame_prints_git_porcelain fails on CI but passes locally, author shows CI identity
  • tests pass on my laptop, fail in GitHub Actions where workflow sets GIT_AUTHOR_NAME GIT_COMMITTER_EMAIL env
  • how do I make Rust git integration tests independent of ambient GIT_AUTHOR env on the runner?
  • global_config_env_is_honoured_by_libgit2_reads assertion failed identity mismatch in CI, env inherited by child git processes