github-actions-conventions
ACTIVATE when writing, reviewing or debugging a GitHub Actions workflow: jobs, timeouts, concurrency, a scheduled canary, path filters, caching, a red or stuck run. ACTIVATE for '.github/workflows', 'timeout-minutes', 'cancel-in-progress', 'on: schedule', 'nightly CI job', 'required check Pending', 'not acquired by Runner'. Covers: one entry step and one size per job, PR-only cancellation, pinned gate vs floating canary, allowlist guards, macOS legs. DO NOT use for: test sizes and where each check runs (see craft:test-suite-design), a canary release to users (see product:delivery), node --test flags (see node-test:node-test-conventions), bash 3.2 script fixes (see mac:mac-platform).
- License 许可
- MIT
- 最近更新
- 2026-10-13
- Stars
- ★ 9
- Forks
- 2
01 前言 Front Matter
- name
- github-actions-conventions
- description
- ACTIVATE when writing, reviewing or debugging a GitHub Actions workflow: jobs, timeouts, concurrency, a scheduled canary, path filters, caching, a red or stuck run. ACTIVATE for '.github/workflows', 'timeout-minutes', 'cancel-in-progress', 'on: schedule', 'nightly CI job', 'required check Pending', 'not acquired by Runner'. Covers: one entry step and one size per job, PR-only cancellation, pinned gate vs floating canary, allowlist guards, macOS legs. DO NOT use for: test sizes and where each check runs (see craft:test-suite-design), a canary release to users (see product:delivery), node --test flags (see node-test:node-test-conventions), bash 3.2 script fixes (see mac:mac-platform).
02 资源文件 5
- 参考文档bmad-skill-manifest.yaml682 B
- 参考文档evals/evals.json4.3 KB
- 参考文档references/sources.md6.4 KB
- 参考文档stories-told.md206 B
- 参考文档story-preferences.md217 B
03 SKILL.md 正文
GitHub Actions Conventions
How a test pipeline is wired into GitHub Actions, and how GitHub behaves around it. The suite's own design (the sizes and where each runs, the single entry point, per-check deadlines, what makes a canary worth having) lives in
craft:test-suite-design; what a test asserts, incraft:testing-principles;node --testflags, innode-test:node-test-conventions; bash 3.2 and BSD fixes, inmac:mac-platform; hook suites and their per-platform rows, inshell-test:shell-test-conventions. The source of every GitHub behaviour below, and of every number measured on this marketplace's own CI, is listed inreferences/sources.md.
1. Steps
- A job is its setup steps, then one step that calls the entry point with every group the job covers (
node scripts/verify.ts static; the entry point itself:craft:test-suite-design§11). A failed step skips the steps after it, so a second entry step loses its verdict whenever the first one goes red, and a check written straight into arun:block is one the local entry never runs, so local and CI verdicts drift. - Call the entry script itself, never through a package manager.
npm run verifystays the local shortcut; in CI, a committed.npmrc(script-shell=/usr/bin/true) or a changedscriptsentry inpackage.jsonmakesnpm runexit 0 without running the entry, and no workflow guard reads those files (§8). - Let the entry install the dependencies before its first check (
npm ci), so a job's setup is only the checkout and the toolchain, and no job can forget the install. An entry that does not install needs an install step in every job, the canary included.
2. Jobs
- One job per size, all running in parallel. The run lasts as long as its slowest job, and a red job names the size that broke.
- Split or shard only the job that sets the run's wall time, and only once its own work dwarfs its setup. Shortening any other job saves nothing, and every split costs: each job gets a fresh VM and pays checkout, setup and install again; a run fails when one of its jobs never gets a runner; the Free and Pro plans run at most 20 and 40 jobs at once, 5 of them on macOS; and
node --test --test-sharddeals files out by count, not by duration. - Repeat the setup in every job rather than hand a result from one job to another. An
npm ciof about 100 packages took at most 3 s per job on this marketplace's CI, while a handed-over result costs an artifact upload, a download and aneeds:wait that serialises the two jobs. Work that runs twice is removed, not shared (craft:test-suite-design§8). - Measure before caching dependencies. setup-node caches the npm cache, not
node_modules, andnpm cideletesnode_modulesbefore installing, so a lockfile of about 100 packages gains a few seconds at most. Since setup-node v5, apackageManager(ordevEngines.packageManager) field set to npm turns that cache on by itself; its README advisespackage-manager-cache: falsein workflows with elevated privileges.
3. Timeouts
- Every job declares
timeout-minutes, about 4 to 5 times its longest green run, read from the durations the entry reports. Left out, it is 360: one hang holds a runner and keeps the pull request pending for six hours. The wide margin keeps a slow runner day green. - The job timeout only backs up each check's own deadline (
craft:test-suite-design§10): on its own, it cancels the job without naming the check that hung.Terminate orphan processlines at the end of a job log mean a check left processes behind for the runner to kill (craft:test-suite-design§7). - No timeout shortens a job that never got a runner. That failure ends on GitHub's side (§10).
4. Concurrency
Cancel superseded pull request runs, never a push to main or a scheduled run. It pays off during a runner shortage, when a superseded run's jobs would still hold or wait for scarce runners.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
- Fall back to
github.run_id.github.head_refis only defined on pull_request events, so every other run gets a group of its own: each commit on main keeps its verdict, and a push never cancels the nightly. - Never build the group from a value that main or the schedule share (
${{ github.ref }}on every event, for instance). Even withoutcancel-in-progress, a pending run is cancelled as soon as a newer one queues in its group.
5. Pin the Gate, Float the Canary
Why a verdict that can change without a diff stays out of the gate: craft:test-suite-design §1. In a workflow:
- Pin the runner image (
ubuntu-24.04,macos-26), never a-latestlabel. Such a label moves to a new image gradually, over 1 to 2 months (ubuntu-latest to Ubuntu 26.04 from 2026-10-19 to 2026-11-19): jobs of one run can land on two OS versions, and the preinstalled tools change with the image (bash 5.2 to 5.3, ShellCheck 0.9 to 0.11). - Pin every CLI a check or a setup step installs (
npx skills@1.7.0, notnpx skills). - Pin the language version to the exact one developers run, in one file the gate jobs read (an
.nvmrcholding24.16.0, read withnode-version-file: .nvmrc).node-version: '24'takes the newest 24.x: CI ran 24.21 while the developer's machine ran 24.16, so a feature added in between works in CI and not locally. - Float the same things in the canary (
ubuntu-latest,@latest, the major version only). A red canary means a floated version broke something: find which one, then move that pin, with any fix it needs, in a pull request of its own; move the image pin before the pinned image is deprecated.
6. Scheduled Canary
What makes a canary worth having: craft:test-suite-design §6. In a workflow:
- The canary job is the gate's setup on floating versions, plus one entry step naming the canary group, under
if: github.event_name == 'schedule'. Run the group locally before merging a change to it, since a schedule only runs from the default branch. - On failure it opens one issue, or comments on the one already open. Notifications for a scheduled workflow go to one user only: its creator, or whoever last edited its cron or re-enabled it. Give that job
issues: writepluscontents: readfor the checkout: a job-levelpermissionsblock sets every permission it omits to none. - A hung canary check ends on its own deadline (
craft:test-suite-design§10), well before the job'stimeout-minutes. The issue step runs onfailure(), which a failed step turns true, whiletimeout-minutescancels the job: a hang that only the job timeout ends may never reach the issue. - Put the cron at an odd minute (
23 4 * * *) and treat its timing as best effort. The schedule event is delayed under high load, the start of every hour is high load, and queued jobs may be dropped: a0 6 * * *cron on this marketplace started 4 to 12 hours late. - In a public repository, a schedule is disabled after 60 days without activity. Check it is still enabled when a quiet project resumes.
7. Path Filters and Required Checks
- Never put a path or branch filter (
paths,paths-ignore,branches,branches-ignore) under thepull_requesttrigger of a workflow whose checks are required. A workflow skipped that way leaves its checks Pending, and the pull request cannot merge. With a base-branch filter, a stacked pull request runs nothing while it targets its parent's branch, and changing its base to main later is aneditedevent, which starts no workflow by default (onlyopened,synchronizeandreopeneddo): its checks wait for the next push. - Select by diff inside the entry instead, on pull requests only, against the merge base, printing what it skipped (
not needed: no change under plugins/goal since <base>); a push to main and the schedule run everything. Measure what it would save first: 8 of the last 60 changes on this marketplace would have skipped its slowest job. - An aggregate job used as the required check runs under
if: always()and fails unless every job it needs succeeded. Withoutalways()it is skipped when a dependency fails, and a job skipped by a condition reports Success.
8. Guard the Workflow with Allowlists
When a test guards the workflow file (worth it once agents edit CI), it lists what may appear, never what may not.
- A step carries only
name,uses,withandrun; a job onlyname,runs-on,strategy,stepsandtimeout-minutes, plus the canary's schedule condition, permissions and failure step; noenvordefaultsat workflow or job level. A denylist ofcontinue-on-errorandif: falsestill acceptsshell: true {0}(a custom shell that never runs the script), a job'sdefaults.run.shell, and a stepenvsettingnpm_config_script_shell=/usr/bin/true, under whichnpm run verifyexits 0 without running anything. - Check coverage against the workflow itself: every group but the canary is named by exactly one entry step in a job that runs on pull requests, and the canary only by the scheduled job. The general rule, a copy checked by its role:
craft:test-suite-design§5. - Test the guard on YAML strings parsed in memory (milliseconds, no CI run), and change it in the same pull request as the workflow.
9. macOS Legs
- A macOS leg runs platform checks only (
craft:test-suite-design§1): the suites of code that/bin/bashruns on a developer's Mac.macos-26ships Bash 3.2.57 with BSD tools whereubuntu-24.04ships Bash 5.2 with GNU tools, and ShellCheck has no bash-version target, so in CI only the macOS leg catches a bash 4 construct. Nothing else goes there: macOS runners are capped at 5 concurrent jobs, and GitHub warned of longer macOS queues during the 2026-10-05 incident. - The leg catches only what some case drives. The rows that drive each platform branch:
shell-test:shell-test-conventions. - Put the OS legs in one matrix with
fail-fast: false. The default cancels the other legs as soon as one fails, which hides their verdicts.
10. A Red or Stuck Run
- Read the annotation before re-running.
The job was not acquired by Runner of type hosted even after multiple attempts, with no step run, is GitHub's infrastructure, and the job is cancelled after about 15 minutes: re-run the failed jobs once the incident clears (gh run rerun RUN_ID --failed). No test change fixes it; fewer jobs only shrink the exposure. - A check that turns green on re-run is flaky, not fixed. Open an issue for it, and never add automatic retries to the gate: they hide real races and teach everyone to ignore red.
Example
One job per size (static checks, small in-process tests, medium process-level suites, and a platform job on Linux and macOS for the suites of code that runs on both), pinned images, PR-only cancellation, and a schedule-only canary on floating versions that reports to an issue. The gate jobs carry no if, so a push and the schedule re-run the whole gate. pull_request carries no filter, so a stacked pull request runs the gate too (§7). No job installs its dependencies: the entry runs npm ci (§1). .nvmrc holds an exact Node version (§5). Size each timeout-minutes from your own measured durations.
name: Verify
on:
pull_request:
push:
branches: [main]
schedule:
- cron: '23 4 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
static:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with: { node-version-file: .nvmrc }
- run: node scripts/verify.ts static
small:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with: { node-version-file: .nvmrc }
- run: node scripts/verify.ts small
medium:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with: { node-version-file: .nvmrc }
- run: node scripts/verify.ts medium
platform:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-26]
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with: { node-version-file: .nvmrc }
- run: node scripts/verify.ts platform
canary:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with: { node-version: '24' }
- run: node scripts/verify.ts canary
- if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
issue=$(gh issue list --search 'in:title "Scheduled canary is red"' --json number --jq '.[0].number')
if [ -n "$issue" ]; then
gh issue comment "$issue" --body "Still red: $RUN"
else
gh issue create --title 'Scheduled canary is red' --body "Red: $RUN"
fi
Quick Reference
| Situation | Rule |
|---|---|
| Writing a job | Checkout and toolchain, then one entry step calling the entry script directly with every group the job covers; the entry installs |
| Laying out jobs | One per size, in parallel; split or shard only the job that sets the wall time |
| A result another job needs | Repeat the setup instead of handing results over; remove work that runs twice |
| Dependency cache | Measure first: setup-node caches the npm cache, not node_modules |
timeout-minutes |
On every job, 4 to 5 times its longest green run, behind each check's own deadline |
concurrency |
Group on head_ref with a run_id fallback; cancel only on pull_request |
| Versions | Image, CLIs and exact language version pinned in the gate, floating in the canary; a pin moves in its own pull request |
| Scheduled canary | Gate setup plus one entry step, check deadlines under the job timeout, an issue on failure, an odd-minute cron |
| Path and branch filters | Never under pull_request on a required check; select by diff inside the entry |
| Aggregate required job | if: always(), red unless every job it needs succeeded |
| Workflow guard | Allowlisted keys, every group covered by a PR job, tested on YAML parsed in memory |
| macOS leg | Platform checks only, in one OS matrix with fail-fast: false |
| "not acquired by Runner" | Infrastructure: re-run the failed jobs, change no test |
| Green on re-run | Flaky: an issue, never an automatic retry |
04 同仓库更多 Skills
vitest-test-conventions
ACTIVATE when writing Vitest tests, creating test files, using vi.fn()/vi.mock()/vi.spyOn(), or test factories. ACTIVATE for 'Vitest', 'it.each', 'NestJS testing module', 'supertest', 'vi.fn', 'vi.mock', 'spyOn'. Provides Vitest/NestJS-specific testing patterns; cross-language testing principles (DAMP, AAA, spy over mock, what NOT to test) live in craft:testing-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), TDD workflow/iterations (see vitest:vitest-tdd-workflow), PHP/PHPUnit tests (see phpunit:php-test-conventions).
vitest-tdd-workflow
ACTIVATE when building new features, endpoints, or user stories using TDD with Vitest in a TypeScript/NestJS context. ACTIVATE for '/feature-tdd-dev', 'TDD', 'red-green-refactor' in TS context. Provides Vitest/NestJS-specific TDD examples and commands; cross-language TDD workflow (cross-layer iterations, RED-GREEN-REFACTOR, working app, bug-fix-first-test, mocks-hiding-bugs) lives in craft:tdd-workflow-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), test writing conventions (see vitest:vitest-test-conventions), PHP TDD (see phpunit:php-tdd-workflow).
ts-refactoring
ACTIVATE when refactoring TypeScript code. ACTIVATE for 'refactor', 'extract', 'redesign', 'simplify', or 'clean up' in a TypeScript / Node / NestJS context. This skill provides TS-specific examples for the cross-language refactoring rules defined in craft:refactoring-principles. DO NOT use for: writing new features from scratch, general OOP patterns (see ts-oop).
ts-ports-adapters
ACTIVATE when a TypeScript codebase with no dependency-injection container has to declare a port and wire its adapter — a repository, a clock, an id generator, an event dispatcher the domain depends on. ACTIVATE for 'port', 'adapter', 'SPI', 'dependency inversion' or 'composition root' in a codebase that wires its dependencies by hand. Covers: the port as a type of functions in the domain layer, the adapter as an object literal annotated with it, the handler that takes its dependencies first and its data second, the composition root in the infrastructure layer, and the in-memory stub that substitutes for the adapter in a unit test. DO NOT use for: NestJS, or any container-based DI with decorators and tokens (see nest-ddd-conventions), aggregate operations and smart constructors (see ddd-ts-fp), the Result type itself (see ts-functional).
ts-oop
ACTIVATE when designing TypeScript classes, and the value objects or collections modelled as classes, or when the user asks about object design, encapsulation, Tell Don't Ask, or Symbol.iterator. Provides TS-specific examples for the cross-language OOP rules defined in craft:oop-principles, plus TS-specific patterns (Symbol.iterator, branded types for primitive identifiers). DO NOT use for: a value object or an aggregate modelled as an immutable record rather than a class (see ddd-ts-fp), refactoring methodology (see ts-refactoring).
ts-layer-boundaries
ACTIVATE when wiring a Worker entry point, a Router, a controller, or a domain event consumer in a TypeScript CQRS codebase, or when deciding where a port belongs. ACTIVATE for 'composition root', 'layer boundary', 'ESLint zones', 'domain must not import infrastructure'. Covers: the *Worker.ts composition root, the curried consumer, Router wiring of command endpoints, the five-gesture controller, the domain-to-infrastructure import boundary enforced by ESLint, infrastructure-only ports, in-memory doubles for every port, the read-can-reach-write asymmetry, and read endpoints going through a domain handler. DO NOT use for: the port's own shape and adapter binding (see ts-ports-adapters), the Result type (see ts-functional), domain event structure (see ts-ddd-events).