|
| 1 | +# `templates/github/workflows/` — budget-friendly CI defaults |
| 2 | + |
| 3 | +Workflow files in this directory are copied into a gitguardex-managed |
| 4 | +project's `.github/workflows/` directory when bootstrapping. They are |
| 5 | +the **default** budget posture for projects that use `gx branch start` |
| 6 | +to drive agent iterations. |
| 7 | + |
| 8 | +Agent flows land a high volume of PRs per month. Without these trims, |
| 9 | +every PR + every post-merge push fans out across CI, CodeQL, Scorecard, |
| 10 | +and Code Review — which dominates the GitHub Actions bill for any |
| 11 | +multi-agent repo. The trims below cut that cost without giving up |
| 12 | +correctness coverage. |
| 13 | + |
| 14 | +## What's trimmed and why |
| 15 | + |
| 16 | +1. **`concurrency: cancel-in-progress: true`** scoped per workflow + ref |
| 17 | + so rapid pushes to the same agent branch cancel the prior run |
| 18 | + instead of letting both finish on Actions minutes. |
| 19 | + |
| 20 | +2. **`if: github.event.pull_request.draft == false`** on every job that |
| 21 | + shouldn't run on a draft PR, paired with |
| 22 | + `pull_request.types: [..., ready_for_review]` in the trigger list so |
| 23 | + CI fires the moment the PR is promoted out of draft. |
| 24 | + |
| 25 | +3. **`if: !startsWith(head.ref, 'agent/')`** on the Code Review job |
| 26 | + (`cr.yml`) — skip AI review on automated agent-lane PRs. AI review |
| 27 | + on hundreds of agent PRs per month burns both Actions minutes and |
| 28 | + OpenAI tokens without adding signal; human-authored PRs (any non- |
| 29 | + `agent/*` head branch) still get reviewed. |
| 30 | + |
| 31 | +4. **No `push: main` trigger** in `ci.yml` — branch protection on |
| 32 | + `main` forces all changes through a PR, so PR-time CI is sufficient |
| 33 | + and post-merge CI on `main` was pure duplication. Use |
| 34 | + `workflow_dispatch` for ad-hoc full runs. |
| 35 | + |
| 36 | +5. **`paths-ignore`** for docs / openspec / template-only changes — skip |
| 37 | + CI on changes that don't affect runtime behavior. |
| 38 | + |
| 39 | +## Customizing |
| 40 | + |
| 41 | +- Replace `placeholder` steps in `ci.yml` with your build/test/lint |
| 42 | + commands. |
| 43 | +- Keep the `concurrency:`, `if:`, and `paths-ignore:` patterns. They |
| 44 | + are the load-bearing part of the budget posture; removing them undoes |
| 45 | + the win. |
| 46 | + |
| 47 | +## When to skip the draft-skip pattern |
| 48 | + |
| 49 | +If your CI is fast (≤ 2 min) and you want continuous validation as |
| 50 | +agents iterate, drop the `if: pull_request.draft == false` job guard. |
| 51 | +The concurrency cancel alone still prevents minute pile-up. |
| 52 | + |
| 53 | +## When to re-enable AI code review on agent PRs |
| 54 | + |
| 55 | +If your team relies on AI review as a true gating signal (not just |
| 56 | +advisory), remove the `!startsWith(head.ref, 'agent/')` guard in |
| 57 | +`cr.yml`. Expect the OpenAI bill to scale linearly with merge volume. |
| 58 | + |
| 59 | +## Per-PR label opt-in |
| 60 | + |
| 61 | +Both `cr.yml` and `ci-full.yml` honor PR labels so the occasional |
| 62 | +agent PR that actually needs the heavier check can opt in without |
| 63 | +flipping a global toggle: |
| 64 | + |
| 65 | +| Label | Effect | |
| 66 | +| --- | --- | |
| 67 | +| `needs-review` | Run AI code review on this PR even though it's `agent/*`. Useful for security-sensitive changes or public-API redesigns. | |
| 68 | +| `needs-ci-full` | Run the full cross-runtime matrix from `ci-full.yml` on this PR instead of waiting for the weekly schedule. Useful before a release branch lands. | |
| 69 | + |
| 70 | +To enable: open the PR, then `gh pr edit <num> --add-label needs-review` |
| 71 | +(or click the labels picker in the GitHub UI). The label-trigger fires |
| 72 | +the workflow immediately; you don't need to re-push. |
| 73 | + |
| 74 | +Add label definitions to your repo with `gh label create needs-review |
| 75 | +--description "Run AI code review on this PR"` and similar for |
| 76 | +`needs-ci-full`, or define them in `.github/labels.yml` if you use a |
| 77 | +label-sync workflow. |
| 78 | + |
| 79 | +## What about CodeQL / Scorecard? |
| 80 | + |
| 81 | +The gitguardex repo itself runs CodeQL and Scorecard on the **weekly |
| 82 | +schedule + `workflow_dispatch`** only — not on per-PR / per-push |
| 83 | +triggers. Those workflows are long-running (5–10 min for CodeQL) and |
| 84 | +were the largest single line item on the monthly Actions bill before |
| 85 | +this change. If your project needs per-PR CodeQL gating for compliance |
| 86 | +reasons, re-add the `pull_request` trigger and accept the cost; for |
| 87 | +most repos, weekly + on-demand is the right default. |
0 commit comments