ci: widen the docs-only gate to Markdown, images and repository metadata (#5235)

## What

The PR pipeline skips build, Talos and E2E only when every changed path
is under `docs/` or one of the two CI-only Go tools. A PR that touches
`README.md`, `GOVERNANCE.md`, an issue template or `LICENSE` still
builds every image, boots a sandbox and runs the suite, for files
nothing in that pipeline reads.

This PR moves the classifier into `hack/code-changed.sh` and widens what
counts as non-code:

- `docs/` tree, Markdown outside `packages/`, `img/`, `LICENSE`
(Markdown under `packages/` stays code: Go controller tests read chart
READMEs)
- `.github/ISSUE_TEMPLATE/`, `CODEOWNERS`, `PULL_REQUEST_TEMPLATE.md`,
`labels.yml`, `renovate.json`, `.gemini/`, `.coderabbit.yaml`,
`security-insights.yml`

Both lanes read the same script: 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` + `previous_filename`, so a
`packages/… -> docs/…` rename still reads as code). The fork lane checks
out `hack/` from the base repository's default branch, never from the
fork.

The `push` triggers of `build-main`, `build-release` and CodeQL mirror
the classifier with a `paths` filter (`**`, one `!` glob per non-code
path, then `packages/**.md` re-included; `paths` rather than
`paths-ignore` because only `paths` documents re-including after a
negation), so a docs-only push to main no longer rebuilds it.
`hack/code-changed_test.bats` keeps the three filters equal, checks that
every `!` glob is non-code and every re-include is code for the script,
so a push of real code can never skip its build, and pins CodeQL's
`pull_request` trigger to having no path filter.

## What still checks non-code files

- Markdown under `packages/` is code, so chart READMEs keep the full
pipeline: `packages/system/flux-plunger/README.md` is checked by a Go
test (`TestDocs_StateTheTimingsTheBinaryAndTheChartUse` in
`internal/controller/fluxplunger/hook_contract_test.go`) that runs only
on the code path, and all chart READMEs are regenerated by `make
generate` under pre-commit. The Bats lane of `checks` runs for every
path except the two CI-only tools (`cmd/backport-batch/`,
`cmd/api-gate/`), so `labels.yml`, `CODEOWNERS`, `renovate.json`, the PR
template and the Markdown outside `packages/` keep their `hack/*.bats`
contract tests; they only skip build, Talos and E2E.
- `labels.yml` has its own workflow; zizmor still runs on workflow
changes.
- CodeQL is a required check on `main`, so its `pull_request` trigger
has no `paths-ignore`: a path-filtered required workflow would leave the
PR on "Expected". Only the `push` trigger keeps the mirrored list, so a
docs-only merge does not rerun it.

## Numbers

Over the 200 merged PRs returned by `gh pr list --state merged --limit
200` on 2026-11-18 (merged 2026-10-14 to 2026-11-18; the list is ordered
by creation, not merge date) the gate on main (`docs/` plus the two
CI-only tools) skips 8, the new one 10. The extra two: #5168 and #5188.
None of them touches Markdown under `packages/`, so keeping it as code
costs nothing in this window.

## Not changed

- `.gitignore`, `.dockerignore`, `packages/tests/` fixtures and
`dashboards/*.json` stay code: the first two change what gets built, the
fixtures feed helm-unittest (code lane only), the dashboards ship in
charts.
- `select-e2e.sh`'s `inert_config_pattern` is untouched;
`docs/agents/e2e-testing.md` already says the `plan` gate is the place
to widen.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **CI Improvements**
* Main and maintained release-branch builds are skipped for changes
limited to documentation, images, selected tooling, repository metadata,
and Markdown outside `packages/`. Changes to Markdown files under
`packages/` still trigger builds.
* CodeQL is skipped on pushes to `main` for those non-code changes; pull
requests targeting `main` remain subject to CodeQL checks.
* End-to-end checks are skipped when all changed files are classified as
non-code, including renames. Status messages clarify when checks are not
required.
* **Documentation**
* Updated end-to-end testing guidance to distinguish the build gate from
test-suite selection; dashboard-only changes still install dependencies
but skip the Chainsaw suite.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-12-03 10:12:33 +03:00
commit 8e430c011f
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
+1 -1
View File
@@ -120,7 +120,7 @@ Be precise about TIA's scope — it is narrower than "skip E2E for unrelated PRs
- **It trims only which suites `chainsaw test` runs, not the expensive stages.** `Prepare environment` and `Install Cozystack` (the full platform install) run regardless of the selection. TIA only decides the `CHAINSAW_SUITES` passed to the final E2E step. A perfect narrow saves the suite tail, not the bulk of wall-time. (Package image builds are scoped separately by `hack/build-matrix.sh`; the Talos leg runs when its direct or shared inputs changed and remains unconditional for forks, while installer/finalize runs for every non-docs PR. That is a distinct mechanism from TIA's suite trimming.)
- **`Select E2E tests` runs *after* `Install Cozystack` and has no `always()`.** GitHub implicitly ANDs a step's `if:` with `success()`, so if install fails the selector (and `Run E2E tests`) are skipped entirely. On a red install you will not see TIA narrow anything — that is the ordering, not a selector bug.
- **Most PRs legitimately escalate to the full suite.** Platform manifests live under `packages/core/`, Go under `api/`/`internal/`, helpers under `hack/`, plus the `Makefile` — touching any one triggers the full suite. So "all suites selected" is usually correct, not a failure to narrow.
- **Two skip layers, with a gap.** The `plan` job computes a coarse gate (`code`, false only when every changed path is under `docs/` or one of the CI-only Go tools no image builds, `cmd/backport-batch/` and `cmd/api-gate/`) that skips the whole build+E2E pipeline for such PRs, and `e2e-fork.yaml` skips on the same prefixes (`hack/gate-concurrency-contract.bats` holds the two lists equal), plus a per-package build matrix (`hack/build-matrix.sh`) that scopes which images build. TIA's finer skip (`select-e2e.sh` ignoring `docs/`, `dashboards/`, `*.md` and the rest of `inert_config_pattern`) only trims the suite selection. A PR touching only `dashboards/*.json` therefore still runs install, then skips just the Chainsaw suites — near-zero savings. If you need such PRs to skip the pipeline, widen the `plan` docs-gate, not `select-e2e.sh`.
- **Two skip layers, with a gap.** The `plan` job computes a coarse docs-only gate (`code`, from `hack/code-changed.sh`: false only when every path is `docs/`, Markdown outside `packages/` (Go tests read chart READMEs), images, repository metadata or a CI-only Go tool no image builds, `cmd/backport-batch/` and `cmd/api-gate/`) that skips the whole build+E2E pipeline for docs-only PRs, plus a per-package build matrix (`hack/build-matrix.sh`) that scopes which images build. TIA's finer skip (`select-e2e.sh` ignoring `docs/`, `dashboards/`, `*.md` and the rest of `inert_config_pattern`) only trims the suite selection. A PR touching only `dashboards/*.json` therefore still runs install, then skips just the Chainsaw suites — near-zero savings. If you need such PRs to skip the pipeline, widen `non_code_pattern` in `hack/code-changed.sh` (and the mirrored push `paths` filters its test checks), not `select-e2e.sh`.
### 8. Failure must be self-explanatory — diagnostics are first-class
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
# Classify a changed-path list for the PR pipeline: prints `true` when at least
# one path can reach the product (Go, charts, images, build inputs, workflows)
# and `false` when every path is documentation or repository metadata.
#
# This is the single source of truth for the docs-only gate: pull-requests.yaml
# `plan` feeds it the merge diff and e2e-fork.yaml `resolve` feeds it the
# base-repo PR file list. A rename must appear as BOTH paths (git diff
# --no-renames, or filename + previous_filename), so a packages/... -> docs/...
# move still reads as code. A blank line reads as code: fail closed.
#
# Non-code: the docs/ tree, Markdown outside packages/, images, LICENSE, GitHub
# and review-bot metadata. Markdown under packages/ stays code: Go controller
# tests read chart READMEs (internal/controller/fluxplunger/hook_contract_test.go
# checks packages/system/flux-plunger/README.md), and those run only when this
# prints `true`. The Bats lane of the `checks` job runs for every path except
# the CI-only tools in this list (cmd/backport-batch, cmd/api-gate), so non-code
# files still get their contract tests; they only skip build and e2e.
# The push `paths` filters in build-main.yaml, build-release.yaml and codeql.yml
# mirror this classifier (CodeQL's pull_request trigger has none: it is
# a required check); hack/code-changed_test.bats keeps them in step.
set -eu
if [ "$#" -ne 1 ] || [ ! -f "$1" ] || [ ! -r "$1" ]; then
echo "usage: code-changed.sh <readable-changed-files>" >&2
exit 2
fi
non_code_pattern='^(docs/|cmd/backport-batch/|cmd/api-gate/|img/|\.gemini/|\.github/ISSUE_TEMPLATE/|\.github/(CODEOWNERS|PULL_REQUEST_TEMPLATE\.md|labels\.yml|renovate\.json)$|\.coderabbit\.yaml$|security-insights\.yml$|LICENSE$)'
# ENVIRON, not -v: -v would expand the backslash escapes in the pattern.
pattern="$non_code_pattern" awk '
!($0 ~ ENVIRON["pattern"] || ($0 ~ /\.md$/ && $0 !~ /^packages\//)) { code = 1 }
END { print (code ? "true" : "false") }
' "$1"
+113
View File
@@ -0,0 +1,113 @@
#!/usr/bin/env bats
# Unit tests for hack/code-changed.sh, the PR docs-only gate, and for the
# paths-ignore lists that mirror it in the push-triggered workflows.
#
# Run from the repo root through `make bats-unit-tests`; the relative paths
# below resolve against that cwd. Negated assertions use `if cmd; then false`
# rather than `! cmd`; see hack/bats-no-negated-assert.bats.
load test_helper
classify() {
list=$(mktemp)
printf '%s\n' "$@" > "$list"
hack/code-changed.sh "$list"
rm -f "$list"
}
@test "docs tree, Markdown and repo metadata are not code" {
[ "$(classify docs/release.md docs/img/arch.png)" = "false" ]
[ "$(classify README.md ADOPTERS.md CLAUDE.md hack/README.md)" = "false" ]
[ "$(classify examples/backups/etcd/README.md examples/backups/etcd/91-scenario-user-backup.md)" = "false" ]
[ "$(classify img/logo.svg LICENSE security-insights.yml .coderabbit.yaml .gemini/styleguide.md)" = "false" ]
[ "$(classify .github/CODEOWNERS .github/ISSUE_TEMPLATE/bug_report.md .github/ISSUE_TEMPLATE/config.yml .github/PULL_REQUEST_TEMPLATE.md .github/labels.yml .github/renovate.json)" = "false" ]
}
@test "Markdown under packages/ is code: Go tests read chart READMEs" {
# internal/controller/fluxplunger/hook_contract_test.go reads this README.
[ "$(classify packages/system/flux-plunger/README.md)" = "true" ]
[ "$(classify packages/apps/mariadb/README.md docs/release.md)" = "true" ]
[ "$(classify hack/README.md examples/backups/etcd/README.md)" = "false" ]
}
@test "CI-only Go tools are not code, the rest of cmd/ is" {
[ "$(classify cmd/backport-batch/main.go cmd/api-gate/main.go)" = "false" ]
[ "$(classify cmd/backport-batch/main.go cmd/cozystack-api/main.go)" = "true" ]
}
@test "any product path makes the list code" {
[ "$(classify docs/release.md packages/apps/mariadb/values.yaml)" = "true" ]
[ "$(classify README.md hack/code-changed.sh)" = "true" ]
[ "$(classify .github/workflows/pull-requests.yaml)" = "true" ]
[ "$(classify .github/workflows/README.md .github/actionlint.yaml)" = "true" ]
[ "$(classify examples/backups/etcd/run-all.sh)" = "true" ]
[ "$(classify packages/tests/fixture/values.yaml)" = "true" ]
[ "$(classify .gitignore)" = "true" ]
[ "$(classify .dockerignore)" = "true" ]
}
@test "a Markdown suffix on a directory does not hide the files under it" {
[ "$(classify packages/apps/foo.md/templates/deploy.yaml)" = "true" ]
[ "$(classify docs.md/x.go)" = "true" ]
}
@test "a rename listed as both paths reads as code when either side is code" {
# git diff --no-renames and the fork lane both list old and new path.
[ "$(classify packages/apps/foo/templates/deploy.yaml docs/deploy.yaml)" = "true" ]
[ "$(classify docs/old.md docs/new.md)" = "false" ]
}
@test "an empty list is not code and a blank line fails closed" {
list=$(mktemp)
: > "$list"
[ "$(hack/code-changed.sh "$list")" = "false" ]
printf 'docs/a.md\n\n' > "$list"
[ "$(hack/code-changed.sh "$list")" = "true" ]
rm -f "$list"
}
@test "usage errors exit 2" {
run hack/code-changed.sh
[ "$status" -eq 2 ]
run hack/code-changed.sh /nonexistent/changed.txt
[ "$status" -eq 2 ]
}
# The push-triggered workflows cannot call the script, so they carry a `paths`
# filter: `**`, then one `!` glob per non-code path, then re-includes. Every `!`
# glob must name something the script calls non-code, or a push of real code
# would skip its build; every re-include must name code; and the three filters
# must be identical, so one copy cannot drift from the others.
push_paths() {
yq '.on.push.paths[]' "$1"
}
# A representative path for a glob: `**` spans directories, `*` a name.
samples() {
sed -e 's#/\*\*$#/sub/dir/file.txt#' -e 's#^\*\*\.md$#examples/x/README.md#' -e 's#\*\*#sub/dir#g' -e 's#\*#name#g'
}
@test "push path filters mirror the classifier and each other" {
main=$(push_paths .github/workflows/build-main.yaml)
[ "$(printf '%s\n' "$main" | head -n 1)" = "**" ]
[ "$(push_paths .github/workflows/build-release.yaml)" = "$main" ]
[ "$(push_paths .github/workflows/codeql.yml)" = "$main" ]
# Chart READMEs are code (see code-changed.sh), so `!**.md` needs this back.
printf '%s\n' "$main" | command grep -qxF 'packages/**.md'
list=$(mktemp)
printf '%s\n' "$main" | sed -n 's/^!//p' | samples > "$list"
cat "$list"
[ -s "$list" ]
[ "$(hack/code-changed.sh "$list")" = "false" ]
for glob in $(printf '%s\n' "$main" | sed -e '1d' -e '/^!/d'); do
printf '%s\n' "$glob" | samples > "$list"
cat "$list"
[ "$(hack/code-changed.sh "$list")" = "true" ]
done
rm -f "$list"
}
@test "CodeQL's pull_request trigger has no path filter: it is a required check" {
# Only `branches`: any paths or paths-ignore key would leave PRs on "Expected".
[ "$(yq '.on.pull_request | keys | join(",")' .github/workflows/codeql.yml)" = "branches" ]
}
+5 -4
View File
@@ -122,11 +122,12 @@ map_section() {
[ "$docs_run" = 'make bats-unit-tests' ]
[ "$code_run" = 'make unit-tests test-controllers test-controllers-envtest -j4 -k --output-sync=target' ]
# `code` is false for the CI-only tools too, so the docs lane is keyed on a
# docs/ path being present, not on `code` alone. Pin that the output means
# exactly that and that Bats gets installed for it.
# `code` is false for non-code paths and the CI-only tools alike, so the docs
# lane is keyed on any path outside the CI-only tools, not on `code` alone.
# Pin that the output means exactly that and that Bats gets installed for it.
plan_run=$(yq -r '.jobs.plan.steps[] | select(.id == "p") | .run' "$WORKFLOW")
printf '%s\n' "$plan_run" | grep -qF "if grep -qE '^docs/' /tmp/changed_norenames.txt; then"
printf '%s\n' "$plan_run" | grep -qF "if [ \"\$full\" = true ] || grep -qvE '^cmd/(backport-batch|api-gate)/' /tmp/changed_norenames.txt; then"
printf '%s\n' "$plan_run" | grep -qF 'code=true'
[ "$(yq -r '.jobs.plan.outputs.docs' "$WORKFLOW")" = '${{ steps.p.outputs.docs }}' ]
toolchain_if=$(yq -r '.jobs.checks.steps[] | select(.name == "Set up test toolchain") | .if' "$WORKFLOW")
[ "$toolchain_if" = "needs.plan.outputs.code == 'true' || needs.plan.outputs.docs == 'true'" ]
+15 -31
View File
@@ -266,47 +266,31 @@ resolve_silent_conclusions() {
plan_block="$(job_block plan "$PULL_REQUESTS" | code_lines)"
[ -n "$plan_block" ]
count="$(printf '%s\n' "$plan_block" | grep -c "grep -qvE '\^(.*)' /tmp/changed_norenames.txt" || true)"
# Both lanes classify with hack/code-changed.sh; `plan` feeds it the
# rename-blind list and never the rename-detected one.
count="$(printf '%s\n' "$plan_block" | grep -c 'hack/code-changed\.sh /tmp/changed_norenames\.txt' || true)"
[ "${count:-0}" -eq 1 ]
# The rename-detected list may still feed the build matrix, but never this.
count="$(printf '%s\n' "$plan_block" | grep -c "grep -qvE '\^(.*)' /tmp/changed.txt" || true)"
count="$(printf '%s\n' "$plan_block" | grep -c 'hack/code-changed\.sh /tmp/changed\.txt' || true)"
[ "${count:-0}" -eq 0 ]
# The fork half of the same agreement: both sides of a rename are inspected.
# Pinned on the skip expression itself — `previous_filename` also appears
# in the TIA file list a few lines down, so counting the identifier would stay
# satisfied by that one with this check deleted.
# The fork half of the same agreement: both sides of a rename reach the
# classifier. Pinned on the list expression itself — `previous_filename` also
# appears in the TIA file list a few lines down, so counting the identifier
# would stay satisfied by that one with this check deleted.
block="$(job_block resolve "$FORK" | code_lines)"
[ -n "$block" ]
count="$(printf '%s\n' "$block" \
| grep -c 'f\.previous_filename && !isNoRuntime(f\.previous_filename)' || true)"
| grep -c 'files\.flatMap(f => \[f\.filename, f\.previous_filename\])' || true)"
[ "${count:-0}" -eq 1 ]
count="$(printf '%s\n' "$block" | grep -c "exec\.exec('hack/code-changed\.sh'" || true)"
[ "${count:-0}" -eq 1 ]
}
@test "both lanes skip e2e for the same path prefixes" {
# The rename test above pins HOW each lane reads its list; this one pins
# WHAT it skips. A prefix added to one lane only is a fork PR that one lane
# reads as nothing-to-build and the other as needing the pr-patch artifact,
# which nothing will ever produce.
plan_prefixes="$(job_block plan "$PULL_REQUESTS" | code_lines \
| sed -nE "s,.*grep -qvE '\^\(([^)]*)\)' /tmp/changed_norenames\.txt.*,\1,p" \
@test "the classifier's CI-only tools are the ones the build matrix and suite selector skip" {
# A tool skipped on its own must also be left alone in a mixed diff;
# otherwise it still rebuilds everything beside a one-line package change.
tools="$(sed -nE "s,^non_code_pattern='\^\(docs/\|(cmd/[^|]*/(\|cmd/[^|]*/)*)\|img/.*,\1,p" "$REPO_ROOT/hack/code-changed.sh" \
| tr '|' '\n' | sort)"
fork_prefixes="$(job_block resolve "$FORK" | code_lines \
| sed -nE "s,.*const noRuntimePrefixes = \[([^]]*)\];.*,\1,p" \
| tr ',' '\n' | tr -d " '" | sort)"
[ -n "$plan_prefixes" ]
printf '%s\n' "$plan_prefixes" | grep -qx 'docs/'
if [ "$plan_prefixes" != "$fork_prefixes" ]; then
echo "plan skips:" >&2; printf ' %s\n' $plan_prefixes >&2
echo "fork skips:" >&2; printf ' %s\n' $fork_prefixes >&2
exit 1
fi
# The tools in that list must also be the ones the build matrix and the suite
# selector leave alone in a mixed diff; otherwise a tool skipped on its own
# still rebuilds everything beside a one-line package change.
tools="$(printf '%s\n' "$plan_prefixes" | grep -vx 'docs/')"
[ -n "$tools" ]
matrix_tools="$(sed -nE "s,^tooling_pattern='\^cmd/\(([^)]*)\)/'$,\1,p" "$REPO_ROOT/hack/build-matrix.sh" \
| tr '|' '\n' | sed 's,^,cmd/,; s,$,/,' | sort)"