ci: widen the docs-only gate to Markdown, images and repository metadata

The PR pipeline skipped build, Talos and E2E only when every changed path
was under docs/. A pull request that touched README.md, GOVERNANCE.md, an
issue template or LICENSE still built every image, booted a sandbox and
ran the suite, for files nothing in that pipeline reads.

Move the classifier into hack/code-changed.sh, the one source of truth for
both lanes: the in-tree `plan` job feeds it the --no-renames merge diff and
the fork `resolve` job feeds it the base-repo PR file list (filename and
previous_filename, so a packages/… -> docs/… rename still reads as code).
Non-code is the docs/ tree, Markdown outside packages/, img/, LICENSE and
the GitHub and review-bot metadata.

Markdown under packages/ stays code: Go controller tests read chart
READMEs. TestDocs_StateTheTimingsTheBinaryAndTheChartUse checks
packages/system/flux-plunger/README.md and runs only under
make test-controllers, i.e. only when hack/code-changed.sh prints true, so
a README-only PR there would skip the test and turn the next code PR on
main red. The classifier uses awk rather than grep to express that
exception. Other chart READMEs are generated by `make generate`, which
pre-commit re-runs, and contract-tested by hack/*.bats, which the `checks`
job still runs for every path except the two CI-only tools.

The push triggers of build-main, build-release and CodeQL mirror the
classifier so a docs-only merge no longer rebuilds main. They use a
`paths` filter (`**`, one `!` glob per non-code path, then `packages/**.md`)
because only `paths` documents re-including after a negation.
hack/code-changed_test.bats checks that the three filters are equal, that
every `!` glob is non-code, that every re-include is code, and that
CodeQL's pull_request trigger carries no path filter at all: it is a
required check on main.

Over the 200 merged PRs returned by `gh pr list --state merged --limit
200` on 2026-11-18 the gate on main (docs/ plus the two CI-only tools)
skipped 8, the new one 10 (#5168 and #5188 are newly skipped).

Assisted-by: LLM
Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
This commit is contained in:
Marian Koreniuk committed 2026-12-02 10:53:49 +01:00
1 parent ce04ec3fb8
commit ceb2063f34
10 files changed
+268 -68

No files matched your search

+20 -2
View File
@@ -23,8 +23,26 @@ env:
on:
push:
branches: [main]
paths-ignore:
- 'docs/**'
# Mirrors hack/code-changed.sh; hack/code-changed_test.bats keeps them equal.
# `paths`, not `paths-ignore`: Markdown under packages/ is code (Go tests
# read chart READMEs), and only `paths` documents re-including after `!`.
paths:
- '**'
- '!docs/**'
- '!cmd/backport-batch/**'
- '!cmd/api-gate/**'
- '!img/**'
- '!.gemini/**'
- '!.github/ISSUE_TEMPLATE/**'
- '!.github/CODEOWNERS'
- '!.github/PULL_REQUEST_TEMPLATE.md'
- '!.github/labels.yml'
- '!.github/renovate.json'
- '!.coderabbit.yaml'
- '!security-insights.yml'
- '!LICENSE'
- '!**.md'
- 'packages/**.md'
# Only the newest main commit's cache matters; cancel older in-flight warmers.
concurrency:
+20 -2
View File
@@ -32,8 +32,26 @@ on:
# (release-1.6.1) nor rc staging branches (release-1.6.0-rc.4) — building
# those would be pure waste, since their images are built by tags.yaml.
branches: ['release-[0-9]+.[0-9]+']
paths-ignore:
- 'docs/**'
# Mirrors hack/code-changed.sh; hack/code-changed_test.bats keeps them equal.
# `paths`, not `paths-ignore`: Markdown under packages/ is code (Go tests
# read chart READMEs), and only `paths` documents re-including after `!`.
paths:
- '**'
- '!docs/**'
- '!cmd/backport-batch/**'
- '!cmd/api-gate/**'
- '!img/**'
- '!.gemini/**'
- '!.github/ISSUE_TEMPLATE/**'
- '!.github/CODEOWNERS'
- '!.github/PULL_REQUEST_TEMPLATE.md'
- '!.github/labels.yml'
- '!.github/renovate.json'
- '!.coderabbit.yaml'
- '!security-insights.yml'
- '!LICENSE'
- '!**.md'
- 'packages/**.md'
# Run against a line on request. The push trigger above cannot cover the moment
# a line is BORN: cut-prerelease.yaml creates release-X.Y at a commit that is
+22
View File
@@ -3,8 +3,30 @@ name: CodeQL
on:
push:
branches: [main]
# Mirrors hack/code-changed.sh; hack/code-changed_test.bats keeps them equal.
# `paths`, not `paths-ignore`: Markdown under packages/ is code (Go tests
# read chart READMEs), and only `paths` documents re-including after `!`.
paths:
- '**'
- '!docs/**'
- '!cmd/backport-batch/**'
- '!cmd/api-gate/**'
- '!img/**'
- '!.gemini/**'
- '!.github/ISSUE_TEMPLATE/**'
- '!.github/CODEOWNERS'
- '!.github/PULL_REQUEST_TEMPLATE.md'
- '!.github/labels.yml'
- '!.github/renovate.json'
- '!.coderabbit.yaml'
- '!security-insights.yml'
- '!LICENSE'
- '!**.md'
- 'packages/**.md'
pull_request:
branches: [main]
# No paths-ignore: CodeQL is a required check on main, and a path-filtered
# required workflow never reports, so the PR would wait on "Expected".
schedule:
# Weekly on Monday 03:27 UTC — off-peak and offset from the other
# scheduled jobs (scorecard 06:00 Mon, labels 04:17 Mon, stale 04:37
+21 -12
View File
@@ -60,9 +60,8 @@ jobs:
# cannot forge — the workflow_run conclusion, the base-repo PR list, and the
# base-repo PR file list — NOT from the presence/absence of an artifact the
# fork's own build controls. Fail-closed if the fork build failed or the
# pr-patch artifact is missing; green-and-stop only for a PR whose file list is
# entirely under docs/ or the CI-only tools cmd/backport-batch/ and
# cmd/api-gate/ (verified against the base-repo API).
# pr-patch artifact is missing; green-and-stop only for a PR whose file list
# hack/code-changed.sh calls non-code (verified against the base-repo API).
resolve:
name: Resolve fork PR
# Only fork PRs: head_repository differs from the base repository. Same-repo
@@ -88,6 +87,12 @@ jobs:
changed_b64: ${{ steps.r.outputs.changed_b64 }}
full_e2e: ${{ steps.r.outputs.full_e2e }}
steps:
# The docs-only classifier for the verdict below. Under workflow_run this
# checks out the base repository's default branch, never the fork.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
sparse-checkout: hack
# Decide the verdict and post the "E2E Tests" commit status directly, with
# this job's default (workflow_run) token — it already has the actions:read
# / pull-requests:read scopes the lookups need, plus statuses:write from the
@@ -273,15 +278,19 @@ jobs:
// hack/gate-concurrency-contract.bats holds the two lists equal.
//
// A rename reports the NEW path in `filename` and the old one in
// `previous_filename`. Checking only `filename` would read a
// packages/… -> docs/… rename as docs-only, when it in fact removes
// a code path. BOTH sides must be under these prefixes to count.
const noRuntimePrefixes = ['docs/', 'cmd/backport-batch/', 'cmd/api-gate/'];
const isNoRuntime = p => typeof p === 'string' && noRuntimePrefixes.some(x => p.startsWith(x));
const hasRuntime = files.some(f =>
!isNoRuntime(f.filename) || (f.previous_filename && !isNoRuntime(f.previous_filename)));
if (!hasRuntime) {
await decide('success', 'docs or CI-only tools (verified via PR file list) — e2e not required');
// `previous_filename`. List BOTH, the shape `git diff --no-renames`
// gives the in-tree plan job, so a packages/… -> docs/… rename
// still reads as code. hack/code-changed.sh (base repo, checked
// out above) is the one classifier for both lanes.
const paths = files.flatMap(f => [f.filename, f.previous_filename])
.filter(p => typeof p === 'string');
const listFile = `${process.env.RUNNER_TEMP}/pr-files.txt`;
require('fs').writeFileSync(listFile, paths.map(p => `${p}\n`).join(''));
let code = '';
await exec.exec('hack/code-changed.sh', [listFile],
{ listeners: { stdout: d => { code += d.toString(); } } });
if (code.trim() === 'false') {
await decide('success', 'no code changed (docs/metadata only, verified via PR file list) — e2e not required');
return;
}
+16 -16
View File
@@ -57,9 +57,10 @@ permissions:
contents: read
jobs:
# Compute the docs-only gate and the per-package build matrix from the PR
# diff. hack/build-matrix.sh parses the root Makefile `build:` target (the
# single source of truth) and emits only the units whose package dir changed,
# Compute the docs-only gate (hack/code-changed.sh) and the per-package
# build matrix from the PR diff. hack/build-matrix.sh parses the root
# Makefile `build:` target (the single source of truth) and emits only the
# units whose package dir changed,
# escalating to the full set on a shared-dependency change. talos + installer
# are handled by dedicated jobs (see build-matrix.sh for why).
plan:
@@ -180,20 +181,19 @@ jobs:
# line and is not what the docs-only decision is for, so it is left
# alone here rather than widened by a side effect.
echo "Changed files:"; sed 's/^/ /' /tmp/changed_norenames.txt
# `code` is false when every path is under docs/ or in a CI-only Go
# tool that no image builds (cmd/backport-batch, cmd/api-gate): there
# is nothing to build and nothing for e2e to install. e2e-fork.yaml
# answers the same question from the PR file list with the same
# prefixes, and hack/gate-concurrency-contract.bats holds the two lists
# equal.
if [ "$full" = true ] || grep -qvE '^(docs/|cmd/backport-batch/|cmd/api-gate/)' /tmp/changed_norenames.txt; then
echo "code=true" >> "$GITHUB_OUTPUT"
# A failed path listing (`full`) leaves both lists empty, which the
# classifier reads as "nothing changed": force code=true instead.
if [ "$full" = true ]; then
code=true
else
echo "code=false" >> "$GITHUB_OUTPUT"
code="$(hack/code-changed.sh /tmp/changed_norenames.txt)"
fi
# The Bats contracts read docs, so a docs change runs them even when
# `code` is false; a change confined to the CI-only tools does not.
if grep -qE '^docs/' /tmp/changed_norenames.txt; then
echo "Code changed: $code"
echo "code=$code" >> "$GITHUB_OUTPUT"
# The Bats contracts read docs, labels.yml, CODEOWNERS, renovate.json,
# the PR template and the root Markdown, so any change outside the
# CI-only tools runs them even when `code` is false.
if [ "$full" = true ] || grep -qvE '^cmd/(backport-batch|api-gate)/' /tmp/changed_norenames.txt; then
echo "docs=true" >> "$GITHUB_OUTPUT"
else
echo "docs=false" >> "$GITHUB_OUTPUT"
@@ -1485,7 +1485,7 @@ jobs:
description = `release packages candidate did not verify (result: ${CANDIDATE_RESULT})`;
} else if (CODE !== 'true') {
state = 'success';
description = 'docs or CI-only tools — e2e not required';
description = 'no code changed (docs, metadata or CI-only tools) — e2e not required';
} else if (IS_RELEASE === 'true' && IS_FULL_E2E !== 'true') {
// Release promotion PRs deliberately do not repeat e2e: the rc was
// already verified against the immutable candidate whose digests