diff --git a/.github/actions/docker-lint-pins/Dockerfile b/.github/actions/docker-lint-pins/Dockerfile new file mode 100644 index 000000000..de2ee9028 --- /dev/null +++ b/.github/actions/docker-lint-pins/Dockerfile @@ -0,0 +1,9 @@ +# The Docker lint images, read by action.yml beside this file, by repo_gate.py, and by scripts/docker_lint.py. +# It is never built, and is a Dockerfile only so Dependabot's docker ecosystem bumps each tag and its digest. +FROM ghcr.io/editorconfig-checker/editorconfig-checker:4.0.2@sha256:2ba6232bfa0058f72f5f7d7816711590aa764afab1542af30b3ecb4553587918 AS editorconfig-checker +FROM rhysd/actionlint:1.7.12@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667 AS actionlint +FROM davidanson/markdownlint-cli2:v0.24.2@sha256:c768e94d8bb161c449bde28f60656929ca1f02c3010a405f65c9cac71563a889 AS markdownlint +FROM ghcr.io/streetsidesoftware/cspell:10.5.2@sha256:d16ebc7f7b81414c500f279b0f96c43a8c1bfa04279b9b8d98d13c300e2b7095 AS cspell +FROM mirror.gcr.io/koalaman/shellcheck:v0.11.0@sha256:61862eba1fcf09a484ebcc6feea46f1782532571a34ed51fedf90dd25f925a8d AS shellcheck +FROM mirror.gcr.io/mvdan/shfmt:v3.14.1@sha256:8c06884a35683d8763fba6c0d9484d11a61a96da65f8d497d6f625825a6043f2 AS shfmt +FROM mcr.microsoft.com/powershell:7.4-ubuntu-22.04@sha256:62300a213a9293916333df2b014cd3a8f22fb0b0b65f2bb446aaf436bcf8c868 AS powershell diff --git a/.github/actions/docker-lint-pins/action.yml b/.github/actions/docker-lint-pins/action.yml new file mode 100644 index 000000000..f2c5538e4 --- /dev/null +++ b/.github/actions/docker-lint-pins/action.yml @@ -0,0 +1,35 @@ +name: Docker lint pins +description: Read the Docker lint image references, each a version tag with its digest, from the Dockerfile beside this action. + +outputs: + editorconfig-checker: + description: The editorconfig-checker image reference the Dockerfile pins. + value: ${{ steps.read.outputs.editorconfig-checker }} + shellcheck: + description: The shellcheck image reference the Dockerfile pins. + value: ${{ steps.read.outputs.shellcheck }} + shfmt: + description: The shfmt image reference the Dockerfile pins. + value: ${{ steps.read.outputs.shfmt }} + powershell: + description: The PowerShell image reference the Dockerfile pins. + value: ${{ steps.read.outputs.powershell }} + +runs: + using: composite + steps: + # The manifest is read from the action's own path, so a caller reaching this action at a hub pin runs that pin's images. + - name: Read Docker lint pins step + id: read + shell: bash + run: | + set -Eeuo pipefail + manifest="$GITHUB_ACTION_PATH/Dockerfile" + for stage in editorconfig-checker actionlint markdownlint cspell shellcheck shfmt powershell; do + ref=$(sed -n "s/^FROM \([^[:space:]@]*:[^[:space:]@/]*@sha256:[0-9a-f]\{64\}\) AS ${stage}[[:space:]]*\$/\1/p" "$manifest") + if [ -z "$ref" ] || [ "$ref" != "${ref%%$'\n'*}" ]; then + echo "::error::$manifest must pin $stage on exactly one 'FROM :@sha256: AS $stage' line." + exit 1 + fi + echo "$stage=$ref" >> "$GITHUB_OUTPUT" + done diff --git a/.github/actions/repo-gate/repo_gate.py b/.github/actions/repo-gate/repo_gate.py index a6d183a9e..620c035c5 100755 --- a/.github/actions/repo-gate/repo_gate.py +++ b/.github/actions/repo-gate/repo_gate.py @@ -45,6 +45,7 @@ import subprocess import sys import tempfile +import time from pathlib import Path from types import ModuleType from urllib.parse import quote @@ -432,8 +433,11 @@ def check_eol_coverage(root: Path, files: list[str]) -> list[str]: ACTION_FILE = re.compile(r"^\.github/actions/(?:.+/)?action\.ya?ml$") # A GitHub expression is not shell, so shellcheck would read its braces as syntax. EXPRESSION_START = "${{" -SHELLCHECK_IMAGE = "mirror.gcr.io/koalaman/shellcheck:stable" +PIN_MANIFEST = ".github/actions/docker-lint-pins/Dockerfile" +SHELLCHECK_PIN = re.compile(r"(?m)^FROM (\S+:[^\s@/]+@sha256:[0-9a-f]{64}) AS shellcheck[ \t]*$") SHELLCHECK_TIMEOUT = 300 +PULL_ATTEMPTS = 3 +PULL_BACKOFF = 5 SCHEMA_TIMEOUT = 300 YAML_TIMEOUT = 60 DOCKER_TIMEOUT = 30 @@ -655,9 +659,30 @@ def substitute_expressions(body: str) -> str: return "\n".join(out) +def shellcheck_image() -> str: + """The shellcheck image reference the pin manifest names, a tag with its digest. + + It is read from the hub tree this gate sits in, at the commit that tree holds. + Raises ValueError where the manifest names it on no line or on more than one. + A copy fetched alone has no hub tree, so that error names where the check can run. + """ + hub = gate_hub_root() + if hub is None: + raise ValueError( + f"{PIN_MANIFEST} is not beside this script, so run this check from a hub checkout " + "or through the repo-gate action" + ) + manifest = hub / PIN_MANIFEST + pins = SHELLCHECK_PIN.findall(manifest.read_text(encoding="utf-8")) + if len(pins) != 1: + raise ValueError(f"{manifest} names the shellcheck image on {len(pins)} lines, not 1") + return pins[0] + + def shellcheck_body(label: str, dialect: str, text: str) -> list[str]: + image = shellcheck_image() # SC2154 is off because a step's `env:` variables are invisible to shellcheck. - command = ["docker", "run", "--rm", "-i", "--network=none", SHELLCHECK_IMAGE] + command = ["docker", "run", "--rm", "-i", "--network=none", image] command += ["-s", dialect, "-S", "warning", "-e", "SC2154", "-f", "gcc", "-"] try: result = subprocess.run( @@ -685,8 +710,13 @@ def docker_unreachable() -> str | None: """The reason no docker daemon answers or the image cannot be pulled, or None where both work. The explicit pull makes a fetch failure one finding with its reason, rather than one per body. - A locally cached image is reused, so a local run may lag CI, which always pulls fresh. + The image is pinned by digest, so a locally cached copy is the one CI pulls. + A pull exiting non-zero is retried a bounded number of times, as a registry error is often transient. """ + try: + image = shellcheck_image() + except (OSError, ValueError) as error: + return f"the shellcheck pin could not be read: {error}" try: result = subprocess.run( ["docker", "info"], capture_output=True, check=False, timeout=DOCKER_TIMEOUT @@ -699,7 +729,7 @@ def docker_unreachable() -> str | None: return f"docker info exited {result.returncode}" try: present = subprocess.run( - ["docker", "image", "inspect", SHELLCHECK_IMAGE], + ["docker", "image", "inspect", image], capture_output=True, check=False, timeout=DOCKER_TIMEOUT, @@ -710,21 +740,26 @@ def docker_unreachable() -> str | None: return f"docker image inspect could not start: {error}" if present.returncode == 0: return None - try: - pull = subprocess.run( - ["docker", "pull", "--quiet", SHELLCHECK_IMAGE], - capture_output=True, - check=False, - timeout=SHELLCHECK_TIMEOUT, - ) - except subprocess.TimeoutExpired: - return f"docker pull did not finish within {SHELLCHECK_TIMEOUT}s" - except OSError as error: - return f"docker pull could not start: {error}" - if pull.returncode != 0: + failure = "" + for attempt in range(PULL_ATTEMPTS): + if attempt: + time.sleep(PULL_BACKOFF * attempt) + try: + pull = subprocess.run( + ["docker", "pull", "--quiet", image], + capture_output=True, + check=False, + timeout=SHELLCHECK_TIMEOUT, + ) + except subprocess.TimeoutExpired: + return f"docker pull did not finish within {SHELLCHECK_TIMEOUT}s" + except OSError as error: + return f"docker pull could not start: {error}" + if pull.returncode == 0: + return None detail = pull.stderr.decode("utf-8", errors="replace").strip() - return f"docker pull of {SHELLCHECK_IMAGE} exited {pull.returncode}: {detail}" - return None + failure = f"docker pull of {image} exited {pull.returncode}: {detail}" + return f"{failure} (attempt {PULL_ATTEMPTS} of {PULL_ATTEMPTS})" def check_composite_shell(root: Path, path: str) -> list[str]: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c02026760..e51b4708d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,6 +2,7 @@ # # The github-actions ecosystem covers every workflow and composite action this repo ships. # The pip pair covers the ruff version the validator runs, pinned in .github/actions/python-tool-pins/requirements.txt. +# The docker pair covers the lint images, each a version tag with its digest, pinned in .github/actions/docker-lint-pins/Dockerfile. # Both main and develop are targeted so each stays current independently of the develop to main release cadence. # The merge-bot auto-merges each base with its per-base method. # See catalog/snippets/configs/dependabot.yml for the multi-ecosystem reference, covering nuget, uv, and pip, that a code-shipping repo uses. @@ -43,3 +44,23 @@ updates: directory: "/.github/actions/python-tool-pins" schedule: interval: "daily" + + - package-ecosystem: "docker" + target-branch: "main" + directory: "/.github/actions/docker-lint-pins" + schedule: + interval: "daily" + groups: + docker-lint: + patterns: + - "*" + + - package-ecosystem: "docker" + target-branch: "develop" + directory: "/.github/actions/docker-lint-pins" + schedule: + interval: "daily" + groups: + docker-lint: + patterns: + - "*" diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index ba9e6ee03..b1423e1d3 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -189,15 +189,53 @@ jobs: - name: Lint workflows step uses: raven-actions/actionlint@3d39aea434753780c3b3d4a1a31c854b4dbf49d7 # v2.2.0 + # Each image is a version tag with its digest, from the Dockerfile beside the action, which Dependabot's docker ecosystem bumps. + # A fresh runner still pulls a pinned image, so each step retries a failed pull before it runs a container. + - name: Read Docker lint pins step + id: docker-pins + uses: $/.github/actions/docker-lint-pins + - name: Check EditorConfig step - run: docker run --rm --pull=always -v "$PWD":/check --workdir /check ghcr.io/editorconfig-checker/editorconfig-checker:latest + env: + EDITORCONFIG_IMAGE: ${{ steps.docker-pins.outputs.editorconfig-checker }} + run: | + set -Eeuo pipefail + pull() { + local attempt status + for attempt in 1 2 3; do + status=0 + timeout 300 docker pull --quiet "$1" || status=$? + [ "$status" -ne 0 ] || return 0 + [ "$status" -ne 124 ] || { echo "::error::docker pull of $1 timed out after 300s."; return 1; } + echo "::warning::docker pull of $1 failed on attempt $attempt of 3." + [ "$attempt" -eq 3 ] || sleep $((attempt * 15)) + done + return 1 + } + pull "$EDITORCONFIG_IMAGE" + docker run --rm -v "$PWD":/check --workdir /check "$EDITORCONFIG_IMAGE" # The file list comes from git rather than a glob, and the docker run is skipped rather than invoked on an empty argument list. # That is how a repo with no shell scripts stays clean instead of failing on a linter's own no-file usage error. # A `*.sh` glob alone misses a bare-command script with no extension, so a shebang-matched file joins the list too. - name: Check shell scripts step + env: + SHELLCHECK_IMAGE: ${{ steps.docker-pins.outputs.shellcheck }} + SHFMT_IMAGE: ${{ steps.docker-pins.outputs.shfmt }} run: | set -Eeuo pipefail + pull() { + local attempt status + for attempt in 1 2 3; do + status=0 + timeout 300 docker pull --quiet "$1" || status=$? + [ "$status" -ne 0 ] || return 0 + [ "$status" -ne 124 ] || { echo "::error::docker pull of $1 timed out after 300s."; return 1; } + echo "::warning::docker pull of $1 failed on attempt $attempt of 3." + [ "$attempt" -eq 3 ] || sleep $((attempt * 15)) + done + return 1 + } # Tokenizes rather than substring-matches, so `#!/usr/bin/python bash` is not mistaken for a shell script. # `docker_lint.py`'s shell_shebang_interpreter is the same logic; keep both in sync on a change here. is_shell_shebang() { @@ -258,8 +296,10 @@ jobs: fi done if [ "${#scripts[@]}" -gt 0 ]; then - docker run --rm --pull=always -v "$PWD":/mnt --workdir /mnt mirror.gcr.io/koalaman/shellcheck:stable -- "${scripts[@]}" - docker run --rm --pull=always -v "$PWD":/mnt --workdir /mnt mirror.gcr.io/mvdan/shfmt:latest -d -- "${scripts[@]}" + pull "$SHELLCHECK_IMAGE" + pull "$SHFMT_IMAGE" + docker run --rm -v "$PWD":/mnt --workdir /mnt "$SHELLCHECK_IMAGE" -- "${scripts[@]}" + docker run --rm -v "$PWD":/mnt --workdir /mnt "$SHFMT_IMAGE" -d -- "${scripts[@]}" else echo "no shell scripts are tracked" fi @@ -268,11 +308,26 @@ jobs: # A repo with no .ps1 files pays nothing for the pull. # 1.23.0 rather than the newest, since 1.24.0 needs a newer System.Management.Automation than this image carries, which installs and then fails to import. - name: Check PowerShell scripts step + env: + POWERSHELL_IMAGE: ${{ steps.docker-pins.outputs.powershell }} run: | set -Eeuo pipefail + pull() { + local attempt status + for attempt in 1 2 3; do + status=0 + timeout 300 docker pull --quiet "$1" || status=$? + [ "$status" -ne 0 ] || return 0 + [ "$status" -ne 124 ] || { echo "::error::docker pull of $1 timed out after 300s."; return 1; } + echo "::warning::docker pull of $1 failed on attempt $attempt of 3." + [ "$attempt" -eq 3 ] || sleep $((attempt * 15)) + done + return 1 + } mapfile -t ps_scripts < <(git ls-files '*.ps1') if [ "${#ps_scripts[@]}" -gt 0 ]; then - docker run --rm --pull=always -e PS_SCRIPTS="$(git ls-files '*.ps1')" -v "$PWD":/mnt --workdir /mnt mcr.microsoft.com/powershell:latest \ + pull "$POWERSHELL_IMAGE" + docker run --rm -e PS_SCRIPTS="$(git ls-files '*.ps1')" -v "$PWD":/mnt --workdir /mnt "$POWERSHELL_IMAGE" \ pwsh -NoProfile -Command ' Set-PSRepository PSGallery -InstallationPolicy Trusted Install-Module PSScriptAnalyzer -RequiredVersion 1.23.0 -Force -Scope AllUsers diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 16e4195f7..a29fde72d 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -315,7 +315,7 @@ CI runs the full lint set, but run the linters locally before pushing to catch i **Each surface runs the lint with the tool that fits it, all from the same config files** (`.markdownlint-cli2.jsonc`, `cspell.json`, `.editorconfig`): -- **CI (authoritative)** runs **markdownlint-cli2**, **cspell**, and **actionlint** as pinned action wrappers, which Dependabot bumps. It runs **editorconfig-checker** via Docker `:latest`, since its action only installs the CLI and the Docker one-liner is what actually runs the check. **shellcheck** and **shfmt** run the same way for a repo that carries a shell script, and **PSScriptAnalyzer** does for a repo that carries `.ps1` files. None of shellcheck, shfmt, and PSScriptAnalyzer has an action. For a repo that carries an action under `.github/actions/`, the repo gate's `composite-actions` check runs **shellcheck** in Docker over each bash or sh `run:` body. It also runs **check-jsonschema** through `uvx`, because actionlint reads workflows only. The `composite-actions` check runs shellcheck at warning severity without SC2154, weaker than for a `.sh` file. markdownlint covers all `**/*.md`, and **cspell is scoped to `README.md` + `HISTORY.md`** (see [CODESTYLE.md](./CODESTYLE.md) "Markdown and Spelling" for why), matching the wrapper's CSpell scope below. A "shell script" here is a tracked `.sh` file, plus a tracked, extension-less file whose shebang names bash or sh. That second shape is the one a script meant to run as a bare command takes. A bare `*.sh` glob misses that second case, so both discovery paths run before either tool does. This whole block is the hub's `validate-task.yml` reusable workflow, so a fleet repo reaches it rather than carrying a copy of these steps. +- **CI (authoritative)** runs **markdownlint-cli2**, **cspell**, and **actionlint** as pinned action wrappers, which Dependabot bumps. It runs **editorconfig-checker** via Docker, since its action only installs the CLI and the container is what actually runs the check. Its image is the tag and digest `.github/actions/docker-lint-pins/Dockerfile` pins, which Dependabot bumps. **shellcheck** and **shfmt** run the same way for a repo that carries a shell script, and **PSScriptAnalyzer** does for a repo that carries `.ps1` files. None of shellcheck, shfmt, and PSScriptAnalyzer has an action. For a repo that carries an action under `.github/actions/`, the repo gate's `composite-actions` check runs **shellcheck** in Docker over each bash or sh `run:` body. It also runs **check-jsonschema** through `uvx`, because actionlint reads workflows only. The `composite-actions` check runs shellcheck at warning severity without SC2154, weaker than for a `.sh` file. markdownlint covers all `**/*.md`, and **cspell is scoped to `README.md` + `HISTORY.md`** (see [CODESTYLE.md](./CODESTYLE.md) "Markdown and Spelling" for why), matching the wrapper's CSpell scope below. A "shell script" here is a tracked `.sh` file, plus a tracked, extension-less file whose shebang names bash or sh. That second shape is the one a script meant to run as a bare command takes. A bare `*.sh` glob misses that second case, so both discovery paths run before either tool does. This whole block is the hub's `validate-task.yml` reusable workflow, so a fleet repo reaches it rather than carrying a copy of these steps. - **A working local hook is strongly suggested fleet-wide, and its absence is a measured audit finding, not an invisible gap.** `spec/project-types.json`'s `parity.hooks` check reads this section for its rationale. It is judged by hand during an `AUDIT.md` run like every sibling check in its dimension, never mechanized by `spec/audit.py`. A repo with no local hook mechanism wired at all is a `linter-parity` defect, the same severity a missing markdownlint config already gets. A repo mid-convergence (below) stays operational. CI remains the authoritative run regardless. Catalog snippets carry the canonical shape, each with a copy of `catalog/snippets/hub_fetch_run.py` in the repo root, the one location both shapes share. `catalog/snippets/husky/` is Husky.Net, for a repo that already keeps a .NET tool manifest declaring it. That is because `dotnet tool restore` then `dotnet husky install` is what generates the `.husky/_/husky.sh` its hook sources. It is also because the snippet ships no manifest of its own. `catalog/snippets/pre-commit/` is the `pre-commit` framework, for a repo without one and for any repo that prefers it. No snippet is scoped to a language by what it runs. Each carries the repo's own language checks plus the shared doc gates. A repo drops the block for a language it does not have. A Docker, config, or docs repo therefore wires the doc gates alone, which is a mechanism rather than the absence of one. Which snippet a repo starts from is bounded by the toolchain it already keeps, never by which languages its checks cover. A snippet is a starting point rather than the only shape. A repo may wire an equivalent hook of its own at `.husky/pre-commit`, enabled with `core.hooksPath` and sourcing nothing. That is what this repository does. That path matters, since `parity.hooks` reads the tracked file at `.husky/pre-commit` or `.pre-commit-config.yaml` rather than a per-clone hooks path it cannot observe. - **The hook** runs **language formatting** and the **doc gates**, never Docker, so it stays fast. The formatting half is whatever the repo's own language needs, via native tooling. That is CSharpier and `dotnet format` for .NET, or ruff and the repo's type checker for Python. A repo adds each half once its tree passes that half. That is because a gate that fails on the corpus it guards blocks every commit from the moment it lands. So a hook running one half is a repo mid-convergence rather than a repo out of conformance. The doc half runs each gate at the scope that fits it. The prose gate reads the working tree diff against `HEAD`, or against both parents on a merge commit, rather than sweeping the tree. That is the difference between about 2.2 seconds and about 0.13, and is what makes it affordable in a hook at all. Under a plain git hook that scope is the working tree rather than the staged index. So a partially staged file is judged on all of its edits. Under the `pre-commit` framework it is the staged state instead. That is because that runner sets unstaged changes aside before running a hook, which is measured rather than assumed. That set-aside leaves untracked files in place, so the hook there passes the gate the paths `pre-commit` names instead of the tree. The fleet's Husky hook passes the gate the paths the commit stages, with `--skip-generated`, and the gate reads each one's working-tree content. The pull request gate re-checks every line the branch changes against its base, which is the scope a review is judged on. A whole-repo check belongs in the hook too when it is already fast and takes no file list. The line-ending consistency check is one such check. So scope is a property of the gate rather than a rule the hook applies to all of them. `repo_gate.py --check sha-pin` stays out of the hook regardless, since it resolves a same-owner pin against the GitHub API. - **The doc gates reach a downstream repo by fetching `.github/actions/prose-gate/prose_lint.py` with the `prose-gate.json` beside it and `.github/actions/repo-gate/repo_gate.py`. Each file comes fresh from `ptr727/ProjectTemplate`'s `main` branch, via `hub_fetch_run.py`, never vendored and never pinned.** Pinning anything Dependabot does not maintain goes stale by construction. CI (this repo's own, and the hub's) is the backstop. It catches a change landing broken on `main` before a locally fetched copy does real damage. The prose gate adds one `api.github.com` commit lookup to its fetch, with a `git ls-remote` against `github.com` where that fails. `uv` resolves the packages its script block declares on a cache miss. Beyond fetching the scripts, those lookups and that resolution are the only network calls the doc gates make. An allow-list permitting only `raw.githubusercontent.com` still runs the gate, with the commit reported as unresolved. The unresolved-commit fallback reads the prose gate and its data from `main` twice. When the two reads differ, it refuses to run a mixed pair, and a re-run is the remedy. A Python repo's `uvx`-run ruff and type checker can also reach the network, to resolve `@latest` on a cache miss or refresh. That is the same category of dependency as the Docker pulls the VS Code Lint tasks already do routinely, not a new one. A fetch failure fails the commit, and it never silently skips the gate. The **hub's own** `.husky/pre-commit` is the one exception, staying local and offline, since it carries both gates directly and has no hub to reach. A repo enables its hook per clone with `git config core.hooksPath .husky` or (`uv tool install pre-commit` once, then) `pre-commit install`. The Husky.Net snippet needs one more step per clone, `dotnet tool restore` then `dotnet husky install`, which generates `.husky/_/husky.sh`, the file the hook sources. CI remains the authoritative run either way. diff --git a/OPERATIONS.md b/OPERATIONS.md index ce888cf7c..075752607 100644 --- a/OPERATIONS.md +++ b/OPERATIONS.md @@ -116,7 +116,7 @@ A local gate reproduces a CI failure exactly, because CI runs the same commands ## Tool Usage -The Docker linters pull `:latest` deliberately, so a local run matches whatever CI resolved: +The Docker linters pull the digests `.github/actions/docker-lint-pins/Dockerfile` pins, the images CI also runs for the EditorConfig, shell, and PowerShell checks: ```sh python3 scripts/docker_lint.py diff --git a/catalog/snippets/hub_fetch_run.py b/catalog/snippets/hub_fetch_run.py index 08267b84c..1d33e2637 100644 --- a/catalog/snippets/hub_fetch_run.py +++ b/catalog/snippets/hub_fetch_run.py @@ -32,7 +32,7 @@ # The files a script reads or imports from the hub tree, fetched before it runs. COMPANIONS = { PROSE_GATE_PATH: (".github/actions/prose-gate/prose-gate.json",), - "scripts/docker_lint.py": (), + "scripts/docker_lint.py": (".github/actions/docker-lint-pins/Dockerfile",), } LOOKUP_TIMEOUT = 5 diff --git a/catalog/snippets/husky/README.md b/catalog/snippets/husky/README.md index fac6cdf8c..b24b6207e 100644 --- a/catalog/snippets/husky/README.md +++ b/catalog/snippets/husky/README.md @@ -27,7 +27,7 @@ what it runs, and the two shared doc gates are what every repo owes either way. Full linting (workflow YAML, Markdown, spelling, EditorConfig) is **not** run in the hook. It runs in CI as pinned action wrappers, and on demand via the VS Code **Lint** tasks in -`catalog/snippets/configs/vscode-tasks.json` (Docker at `:latest`). That file also carries the +`catalog/snippets/configs/vscode-tasks.json` (Docker at pinned digests). That file also carries the prose gate in whole-repo mode, for on-demand full-tree validation beyond the diff-scoped commit-time run. Its `Lint: EOL` task runs the same whole-tree EOL check the hook runs. Keeping the Docker-dependent doc linters out of the hook is what keeps it fast. Docker is the diff --git a/catalog/snippets/pre-commit/README.md b/catalog/snippets/pre-commit/README.md index 54cb56098..b89df18d0 100644 --- a/catalog/snippets/pre-commit/README.md +++ b/catalog/snippets/pre-commit/README.md @@ -52,7 +52,7 @@ re-source the shell, or add the directory `uv tool dir --bin` prints directly. Full linting (workflow YAML, Markdown, spelling, EditorConfig) stays out of the hook. It runs in CI as pinned action wrappers, and on demand via the VS Code **Lint** tasks. A Python repo takes those from -`catalog/snippets/configs/vscode-tasks-python.json` (Docker at `:latest`). +`catalog/snippets/configs/vscode-tasks-python.json` (Docker at pinned digests). A repo with no Python takes the Lint group alone rather than that file's Python tasks. Either way they carry the prose gate in whole-repo mode, for on-demand full-tree validation beyond the diff-scoped diff --git a/host-setup/linux/README.md b/host-setup/linux/README.md index 562720963..ffa377527 100644 --- a/host-setup/linux/README.md +++ b/host-setup/linux/README.md @@ -185,7 +185,7 @@ Two of those are guards rather than previews. `--release --dry-run` on a Proxmox `--repo` adds the repository's `install.linux` entries to the report or action. Only `apt` package names are accepted. The script does not execute the declaration's `remedy` text. Reading the JSON needs `jq`, which the ordinary fleet install provides. -CI checks the scripts with `shellcheck` and `shfmt`. It runs both over every `.sh` file `git ls-files` returns, plus a tracked, extension-less file whose shebang names bash or sh. A local run uses the same `mirror.gcr.io/koalaman/shellcheck:stable` and `mirror.gcr.io/mvdan/shfmt:latest` containers. [`tests/test_bootstrap.py`][test-bootstrap] asserts that every tool the spec requires on Linux is one `install-tools.sh` can provide, or a recorded exception. It also asserts each script here is tracked executable, so a fresh checkout can run it. +CI checks the scripts with `shellcheck` and `shfmt`. It runs both over every `.sh` file `git ls-files` returns, plus a tracked, extension-less file whose shebang names bash or sh. A local run uses the same `mirror.gcr.io/koalaman/shellcheck` and `mirror.gcr.io/mvdan/shfmt` images, at the digests `.github/actions/docker-lint-pins/Dockerfile` pins. [`tests/test_bootstrap.py`][test-bootstrap] asserts that every tool the spec requires on Linux is one `install-tools.sh` can provide, or a recorded exception. It also asserts each script here is tracked executable, so a fresh checkout can run it. diff --git a/scripts/README.md b/scripts/README.md index 5dbe03c00..a0e90fdd9 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -6,7 +6,7 @@ The fleet's checks and review tooling, run by hand, with the deterministic ones Python only, and standard library only. The exceptions are markdown-it-py, PyYAML, ruamel.yaml, tomlkit, and EditorConfig. `backlog_metrics.py`, `build_dist.py`, `canonical_review.py`, `carry.py`, `pr_review.py`, `pr_review_copilot.py`, and `pr_cleanup.py` declare markdown-it-py in their inline script metadata, and `build_dist.py` declares PyYAML as well. Every library a script declares inline is pinned to one exact version, and so is each package one of those requires. An open bound once let an upstream release change the prose gate with no change here. `tests/requirements.txt` pins the same versions, and `PinTests` in `tests/test_backlog_metrics.py` holds every pin equal. `build_dist.py` and `carry.py` import markdown-it-py only on the path that reads a region. `build_dist.py` imports PyYAML only on the path that measures a skill description. That is because `skills_install.py` and `handoff.py` import them under a plain `python3`. Every check script is read-only and exits non-zero on a finding. `build_dist.py`, `local_review.py`, `canonical_review.py`, `handoff.py`, `agent_policy.py`, `central_config.py`, `skills_install.py`, and `secrets_sync.py` below are the exceptions. A generator, two recorders, an installer, the handoff chain, the two settings writers, and the secrets sync all exist to write. `build_dist.py --check` and `skills_install.py --report` are read-only modes for CI and for asking without changing anything. `local_review.py status` and `check` answer without recording anything, but they are not read-only in that same sense. Reading the working tree stages it, which writes inside `.git` and runs any `filter.*.clean` the repository configures. Only the receipt is left untouched. `canonical_review.py` reads files rather than staging them, so its `list`, `status`, `sweep`, and `report` are read-only outright, and `record` and `prune` alone write. -The directory separates its kinds by name and by tree. A gate checks and exits non-zero on a finding, and its name carries a `_lint` or `_gate` suffix saying what it gates. The `prose_lint.py` and `repo_gate.py` entry points delegate to the action-owned implementations that gate this tree in CI, and `host_gate.py` gates the machine it runs on. A utility does work rather than gating and carries no suffix: `agent_policy.py`, `backlog_metrics.py`, `build_dist.py`, `canonical_review.py`, `carry.py`, `central_config.py`, `handoff.py`, `local_review.py`, `pr_cleanup.py`, `pr_review.py`, `pr_review_copilot.py`, `secrets_sync.py`, `skills_install.py`. `gh_graphql.py` is a library with no command line. It is the GraphQL transport and cursor walker that `agent_policy.py`, `backlog_metrics.py`, `central_config.py`, `handoff.py`, `pr_cleanup.py`, and `pr_review.py` import from beside them. `pr_review_checks.py`, `pr_review_check_lines.py`, `pr_review_rounds.py`, `pr_review_hold.py`, and `pr_review_digest.py` are libraries with no command line as well. They are the pure readers `pr_review.py` imports for the head's checks, its review rounds, the hosted-review registration grace, and the digest rendered from them. `pr_review_policy.py` reads and validates a repository's review policy, and `pr_review_side.py` reads and asks the comment-triggered reviewers, its one write handed in by `pr_review.py`. `pr_review_payload.py` reads the policy's key and each bot's entry off a payload, for the readers that may not load `pr_review_policy.py`. `pr_review_promotion.py` reads a promotion's commits back to the pull requests that landed them, for the coverage reading a green Dependabot bump earns. `pr_cleanup_rest.py` is a library with no command line too, holding the REST reads `pr_cleanup.py` makes, a promotion's shape among them. `run_deadline.py` is a library with no command line as well. It runs a captured child under a deadline that holds on Windows, where `subprocess.run` waits out a grandchild holding the pipes. `host_gate.py`, `local_review.py`, `pr_cleanup.py`, `pr_review.py`, and `skills_install.py` import it, and `test_skills_install.py` tests it. `docker_lint.py` keeps its own runs, since a carrying repository fetches it alone. The digest takes its lines about the checks from `pr_review_check_lines.py`. The unit tests live apart at the repository root under [`tests/`][tests], one `test_