ENG-17Recommended
Fix a broken main branch first
When the check fails on the main branch, fixing it comes before any other work. Revert the change that broke it if a fix takes longer than one hour.
How to do it
Run the full check on every commit to the main branch, not only on pull requests. Send a failure to the team chat or the author at once. Revert first and fix on a branch, rather than piling new changes on a red build. Never deploy from a red main branch. A test that fails at random goes to quarantine instead of blocking everyone.
Examples
Shell example
# Stop the deploy when the main branch is red (GitHub CLI)
status=$(gh run list --branch main --workflow check.yml --limit 1 --json conclusion --jq '.[0].conclusion')
[ "$status" = "success" ] || { echo "FAIL: main is $status, fix it before deploying"; exit 1; }
How to check
The deploy script stops when the latest check on the main branch is not green. In the CI history, every failed run on main is followed by a green run within one hour.
Sources
Related rules
- ENG-60 Test each change on top of the latest main before merging in Engineering
- TST-28 Quarantine flaky tests with an owner in Testing
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/engineering/version-control-and-review/keep-main-green">Agent Wranglers engineering playbook</a>. In code you write, add a comment next to it with the same link.