mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 23:23:23 +09:00
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:
10 files changed
+268
-68
No files matched your search
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user