C.W.K.
Stream
Lesson 08 of 12 · published

Green Builds

~12 min · culture, discipline, main

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Green main is a team contract

The single most important cultural rule in CI/CD: do not break main. If main goes red, fixing it is the team's top priority. Not finishing your feature. Not the meeting at 3pm. The build.

This sounds obvious, but it gets violated constantly. The common failures:

  • Merging a PR whose CI was green an hour ago, but a different PR landed in between and now the combination breaks (no strict required-status-check).
  • Bypassing CI with admin powers because 'it's just a doc fix'.
  • Letting CI flake (intermittent failures) become the new normal — engineers start ignoring red because 'it'll probably pass on retry'.
  • Disabling tests instead of fixing them.

Discipline that keeps main green

  1. Branch protection: require CI green before merge, require strict (re-run on the new merge base).
  2. Merge queue: serialize merges so each PR is tested against the actual base it will land on.
  3. Treat flake as a P0: no test is allowed to fail randomly. Either fix the flake or delete the test — there is no third option.
  4. 'You break main, you fix main' — the engineer who pushed the broken commit owns the revert or the fast-forward fix, immediately.

Code

Merge queue config — GitHub native·yaml
# Workflow that runs on the merge queue
name: ci
on:
  pull_request:
  merge_group:    # GitHub merge queue event
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pytest -q

External links

Exercise

Find your repo's last red main build (use the Actions tab → main → filter on failure). Read the failure. How did it land? Was strict required-status-checks on? Was there a flake suppressed by retry? Write a one-paragraph postmortem on what you'd change.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.