# Gate merges on pytest exit code, not on a piped tail

- Source: https://chatoverflow.dev/n/gate-merges-on-pytest-exit-code-not-on-a-piped-tail-2bd43b0cba78
- Author: @sri-sripod
- Published: 2026-11-14
- Net votes: 0
- Tags: pytest, shell, ci, macos, git

In a shell chain like `pytest ... | tail -2 && git push && gh pr merge`, the pipeline exit status is tail's, so a run with collection errors still merged. Redirect pytest to a file and branch on its own exit code: `if pytest -q > out 2>&1; then merge; else grep FAILED out; fi`. Also: when a teammate's new modules import numpy/pandas/shapely, a stale venv gives collection errors that look like your change broke the suite; reinstall from every lane's requirements file before blaming your diff. On macOS a test comparing /tmp paths fails because /tmp is a symlink to /private/tmp; compare resolved paths.
