Repository navigation
Docs only fast path
What it does. Three opt-in pieces that make a caller's CI faster without making CI green easier to pass. Each is off by
default, so a caller that sets nothing sees no change after it re-pins.
-
tofu-ci.ymlinputtest-matrix:tofu testruns as one job per directory instead of every directory one after another in one job. -
python-ci.ymlinputxdist: thetestjob's pytest runs in parallel with pytest-xdist. - Two composite actions,
classify-changesandci-gate: a pull request that changes only docs and tests leaves a named job (the tofu job, say) out on purpose, and the caller's ownCI greenjob counts that skip, and only that skip, as a pass.
Why it exists. Clouds-Against-Humanity measured a pull request run at 5 min 15 s, its critical path the tofu / test job
at 286 s (17 directories, one after another), then the Python test jobs at 209 s and 139 s with plain pytest. A lesson that
touches only docs/ waited for all of it (issues Clouds-Against-Humanity#519 and #520, GYST #331).
With test: true and test-matrix: true, a small test-dirs job lists one matrix leg per directory and test runs the legs
at once with fail-fast: false, so one failing directory does not hide another. Each leg is named test (<directory>).
With test-matrix off, test-dirs produces a single leg named test that holds every directory, so the job is what it always
was, name included.
The ci-green job still reports one result. GitHub gives a matrix job the result failure if any leg failed, cancelled if
any leg was cancelled, and success only when every leg succeeded. ci-green fails on anything but success for test and
for test-dirs when test was asked for, so a skipped matrix (for instance because the leg list failed) is a missing check, not
a pass. tests/test_docs_only_fast_path.py runs that shell for every result.
Cost: every leg repeats the runner start, harden-runner, checkout and the tofu install, about 40 to 60
seconds. That is why it is a choice. It pays when the directories' tofu test time dominates, as it does for a repository with
many stacks and modules.
With xdist: true the test job installs pytest-xdist after install-command and sets
PYTEST_ADDOPTS=-n <xdist-workers> for the test-command step. PYTEST_ADDOPTS is read by pytest itself, so:
- the caller's
test-commandruns exactly as written: a command that chains scripts and gates beforepytestkeeps its semantics, and the-nreaches everypytestin it (pytest,python -m pytest,python -I -m pytest) and no other program; - the
distrojob runs the command as written, without it; - the install is
pip install --require-hashes --no-deps --only-binary=:all:from a lock that travels insidepython-ci.yml(source:.github/requirements/pytest-xdist.{in,txt}, copied in byscripts/tool_locks.py), holdingpytest-xdistand its one dependencyexecnetwith hashes. There is no version input: a free-form version cannot coexist with a hash lock, so the locked release is the only one and a bump is a change to the lock. pytest itself is the caller's and is not locked here; -
xdist-workersisauto,logicalor a whole number, checked before it can reach pytest.
Under xdist, tests must not share state (a fixed port, one scratch path), and test ids must be identical on every worker.
A parametrize over a bare object() puts a memory address in the id and makes xdist stop with "Different tests were
collected"; give such a case an explicit ids=.
Two actions and one rule.
Wiring (the caller's ci.yml).
jobs:
classify:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
docs-only: ${{ steps.c.outputs.docs-only }}
steps:
- id: c
uses: ChiefGyk3D/git-your-ship-together/.github/actions/classify-changes@<sha> # vX.Y.Z
with:
docs-only-patterns: |
docs/**
tests/**
*.md
tofu:
needs: classify
if: needs.classify.outputs.docs-only != 'true'
uses: ChiefGyk3D/git-your-ship-together/.github/workflows/tofu-ci.yml@<sha> # vX.Y.Z
# permissions (grant pull-requests: read too) and with: as before
ci-green:
name: CI green
if: ${{ always() }}
needs: [classify, tofu, python, security]
runs-on: ubuntu-latest
permissions: {}
steps:
- uses: ChiefGyk3D/git-your-ship-together/.github/actions/ci-gate@<sha> # vX.Y.Z
with:
needs: ${{ toJSON(needs) }}
required-jobs: classify tofu python security
skippable-jobs: tofu
classifier-job: classifyThe needs input. ci-gate takes the calling job's needs as the input needs, and the caller supplies it with
needs: ${{ toJSON(needs) }} in its own with: block, as above. The needs context exists in the caller's job and not inside
an action, so the input has no default; the action fails with a clear message when it is empty, not JSON, or not a non-empty
JSON object. The ci-gate action in v1.32.0 and v1.33.0 is unusable: its manifest put an expression over needs in the
input's description, which a runner evaluates when it loads the manifest, so the job died in Set up job. Use v1.33.1 or later.
This is the composite action .github/actions/ci-gate, called as a step; the reusable workflow ci-gate.yml
(ci-gate), called as a job, is a different thing and is unaffected. A caller that already
passes needs as an input, as above, changes nothing but the pin. Do not write ${{ }} in any description of an action's
manifest; tests/test_action_manifests.py refuses it.
The decision rules.
- A pull request is docs only when every path it changes matches
docs-only-patternsand none is under.github/or onnever-skip-patterns. One path outside the list, such asstacks/ormodules/, makes the whole change a normal one and the job runs. A mixed docs and code pull request runs the job. - Patterns are anchored at the repository root and matched against the whole path.
*does not cross/;**does;**/is zero or more directories. So*.mdis the root-level Markdown files, and**/*.mdis every one. A pattern that matches every path (**,*,**/*), starts with/or!, or contains..fails the step. - A rename counts both names:
git mv stacks/a/main.tf docs/main.tfremoves code and is not docs only. - Anything the step cannot confirm is
docs-only=false, and the job runs: the event is not apull_request, the pull request head is no longer the commit the run started for, the API's file list is a different size from the event's own count, the list is at the API's 3,000-file limit, or the API call failed. A push to the default branch, a schedule, a dispatch and a merge queue run are never docs only. -
CI greenpasses a job only when its result issuccess. The one exception is a job named inskippable-jobsthat isskippedwhile theclassifier-jobitself succeeded withdocs-only=true. A job skipped for any other reason (an upstream failure, a mistypedif:, a classifier that failed or saidfalse), a failure, a cancellation or a job left out ofneedsfails.required-jobsmakes a job dropped fromneeds:a failure too.
Wiring the classifier by hand in every caller is the per-repository edit this input removes. python-ci.yml and bash-ci.yml
take skip-docs-only: true and nothing else: a classify job inside the workflow (an inline, byte-identical copy of
scripts/classify_changes.py, since a reusable workflow cannot check out its own commit) reads the pull request's files, and
the test and distro jobs leave a markdown-only pull request. The decision rules and threat notes below apply unchanged.
-
Off by default (
false). A workflow cannot tell a private repository from a public one: a policy test (tests/test_runs_on_input.py) forbids readingrepository.private. So a caller opts in, and a re-pin changes nothing until it does. -
What skips. Only
testanddistro, only when the classifier saysdocs-only=true. Lint, type check, workflow lint, the smoke test, the container build, the changelog and commit checks and every security scan run as before. A skipped job isskipped, whichci-greenalready counts as a pass; it still fails on any failed job, and it now waits onclassifytoo, so a failed classifier fails the gate. -
Fails closed. The
testanddistroconditions are!cancelled() && needs.classify.outputs.docs-only != 'true', so a skipped, failed or empty classifier leaves them running. -
Permissions. The
classifyjob holdscontents: readandpull-requests: read. A reusable job cannot exceed the caller's grant, so every caller grantspull-requests: readin itspermissions:, whether or not it setsskip-docs-only; a caller that leaves it out fails at startup, as a missingid-tokengrant does. The read lets the classifier list the pull request's files, and a private repository needs it for that API read; without it the script answersfalseand every job runs. The grant is read-only. -
The list.
docs-only-patternsdefaults to*.mdanddocs/**/*.md;never-skip-patternsadds files the tests read..github/**never skips. -
Egress.
classifystays inblockmode like the other jobs that hand the job token to the GitHub API (api.github.com:443is in the default allow-list), and runs the same self-hosted-runner guard as every job. -
Not covered here.
container-releaseandartifact-releasekeep their own shape: they build on tags and pushes, where there is no pull request to classify.tofu-citakes the same inputs (see tofu-ci).
pr-python-versions. Its default stays "". A reduced matrix changes what a pull request proves, and an existing caller
that re-pins must not get a thinner matrix without choosing it. Set pr-python-versions: '["3.11", "3.15"]' (oldest and
newest) with skip-docs-only: true for the two cheapest cuts. Moving the default would be a breaking change for a major release.
The fast path is a way to run less, so the question is what an attacker gains by making the check run less. Each row names the route and what closes it.
| Route | What closes it |
|---|---|
| The changed-file list is read from the pull request's own checkout, which its author controls | It is read from the REST API (pulls/{n}/files), which GitHub computes. The checkout is not consulted |
| The list is truncated, stale or hides files | The head the API reports must equal the head the event started for, the count must equal the event's changed_files, and a list at the 3,000-file limit is refused. Any mismatch is false
|
| A pull request edits the rule (the patterns, the workflow, this action's wiring) |
.github/** is never docs only, whatever the patterns say, and never-skip-patterns adds the caller's other rule files. Such a pull request runs every job. Residual: a pull request's own workflow file runs from the pull request, so it can also remove the check outright. That is true of every CI job and is closed by what guards .github/ (code owner review, a required CI green that the base branch's rules produce), not by this step |
| A change that mixes docs and code | One path off the list fails the whole classification, so the code runs |
| A rename that moves code into a docs path | Both the old and the new name are classified |
A path with .., ., an empty segment or a leading /
|
Not a normal repository path; the classification is false
|
| A pattern that widens the list to everything | Catch-all patterns, a leading / or !, and .. fail the step. A narrower but wrong list (for example scripts/**) is a caller decision, and only reachable by editing .github/, which runs everything |
| A push lands while the file pages are being fetched | The pull request is read again after the last page. The head must still be the commit the run started for, and the file count must agree three ways (the event, the listing, the final read). Same count and paths on a different head still fail closed |
| A test hook that ships in the action | There is none. The script reads the API through gh only; an environment variable cannot substitute a file list (CC_FILES_JSON was removed, and a test pins that setting it changes nothing) |
A directories entry that leaves the repository (tofu-ci test-matrix) |
Each entry is checked before any leg exists: no absolute path, no leading -, no .. or empty segment, only A-Z a-z 0-9 _ . / -. The same check runs with test-matrix off |
| A fork pull request | The step needs only pull-requests: read, which a fork's token has. It checks out nothing and runs none of the fork's code. A fork cannot reach a secret through it |
| A skipped job passes for the wrong reason | The gate counts a skip only for a named job and only when the classifier succeeded with docs-only=true. Skipped because an upstream failed, skipped by a typo, or skipped with a false verdict all fail |
| Output injection through a file name | Values go to $GITHUB_OUTPUT on one line each, with whitespace collapsed and the path quoted |
| The classifier is itself skipped or fails | The gate fails: classify is in needs and must be success for a skip to count |
| An expression injection | Every input reaches the scripts through the environment, never by interpolation into the script text |
Not covered: a repository that does not require review on .github/. A pull request that rewrites ci.yml to skip a job
needs a reviewer to see it, with or without this feature.
A job that needs a token a fork's pull request does not get (a publishing job's grants, a SARIF upload) is skipped on a fork
by its own if:. Two optional inputs of ci-gate let the caller's CI green accept exactly that and nothing wider:
fork-skippable-jobs names the jobs, and fork-pull-request is the caller's own expression,
${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}. A named job
may be skipped only when that is the string true; a failure or a cancellation still fails, and a job that is not named
still fails when skipped. Unset, the action behaves as before.
ci.yml runs about a hundred jobs. It uses the same two actions: a changes job runs classify-changes with
Markdown under docs/, the Python, JSON and text files under tests/, and CHANGELOG.md (not README.md: tests/test_sbom.py reads it; by file type, not by directory, see below), and every job except actionlint, zizmor, test (the suite reads tests/), changes
and CI green carry needs: changes and if: needs.changes.outputs.docs-only != 'true'. CI green is the ci-gate
action over all of them, with skippable-jobs set to exactly those jobs, required-jobs set to every job, and the
fork excuse above for the jobs that already skipped on a fork. tests/test_path_aware_gating.py holds the three lists
together: add a job to ci.yml without gating it and the test names it.
Tests a gated job runs (the rule that keeps this honest). tests/** is on the docs-only list because the suite reads it
and is never skipped, but a gated job also runs some test files: fixture-sbom runs tests/test_sbom.py, rescan-live runs
tests/test_verify_published.py, and dast-live runs tests/test_dast.py, which imports tests/test_workflows.py. Those, and
tests/fixtures/**, are on never-skip-patterns, so a change to one runs the jobs that depend on it even beside docs.
tests/test_path_aware_gating.py reads every gated job, follows the test files it runs and the local modules and root Markdown
files they name, and fails if any of those paths alone would be classified docs only.
Implicit inputs. Some gated jobs choose their own files instead of naming them: bash-ci runs git ls-files over the
whole repository and lints every tracked .sh or .bash file and any file with a shell shebang. So the docs-only list is by
file type, **/*.sh and **/*.bash are on never-skip-patterns, and a test models adding, deleting and renaming such files in
every directory. Residual: a file of a docs-only type (a .md or .py) that starts with a shell shebang is still treated as docs
only.
Who judges CI green. The aggregate job checks out the gate action and scripts/ci_gate.py from the base commit on a pull
request (github.sha otherwise), sparse and without credentials, so the code under review cannot change its own verdict. A
test pins that. Residual: a pull request can still edit ci.yml itself, because a workflow file runs from the pull request;
only a repository ruleset or a required workflow can pin that. Tracked as a follow-up.
The live jobs and the nightly run (issue #308). rescan-live (real Trivy) and dast-live (real ZAP image, about 450
seconds, the long pole) are gated the same way. ci.yml also has a schedule trigger, every
night on the default branch. The classifier says false for anything but a pull request, so the nightly run is the full run:
the live jobs, the jobs that read the published image and today's vulnerability database, everything. A job that wants to opt
out of the nightly run is a test failure (tests/test_path_aware_gating.py).
Docs-only means every changed path is documentation or a test file nothing else reads. A change under .github/,
scripts/, fixture/, .github/actions/, a requirements file, or any path the patterns do not name runs everything, as does a
push to main, the nightly schedule and a manual run (the classifier is false for anything but a pull request).
scripts/classify_changes.py and scripts/ci_gate.py are the whole logic; the actions only pass the environment. Both are
tested in tests/test_docs_only_fast_path.py with a fake gh. tests/test_action_manifests.py checks every expression in
every .github/actions/*/action.yml against the contexts that location can see, and GYST's own ci.yml runs both actions on
a real runner (fixture-ci-gate-action, fixture-classify-action), so a manifest a runner cannot load fails GYST's CI green.
Generated from docs/wiki/ at commit f3af2fa0bae3. Do not edit this wiki: the next push to main replaces every page. Corrections go to docs/wiki/ by pull request.
GYST
- Home
- Why GYST exists
- Getting started
- Design rules
- Secrets: Doppler and OIDC
- Security scanning explained
- The baseline and the weekly audit
- Releases and supply chain
- Keeping a project board current
- Adopting GYST in your own project
- Glossary
- Roadmap
Learn and contribute
- Learning path
- Which workflow do I need?
- Repository map
- Egress control
- Troubleshooting
- Lessons learned
- Testing and the contract
- Contributing and developing
- Maintaining this wiki
- Verify main
- FAQ
CI
Security
Release
- container-release
- python-docker-release
- python-package-release
- artifact-release
- verify-published
- base-image-digest
Docs and project
- docs-pages
- wiki-publish
- project-sync
- threat-model
- lory-audit
- agent-scan
- token-drift
- node-typecheck
- pr-title-lint
- vendored-drift
- upstream-sync
- repin
- pin-comments
Tools