A contributor learns about a broken renovate.json, a failing script test or a bad image pin from Lint today; as hooks they fail before the push. - check-json from pre-commit-hooks covers renovate.json. - script-tests runs the suite at pre-push, since it takes minutes. Its GIT_DIR points at an uncreatable path, so a fixture that keeps the caller's git environment fails instead of writing to this repository. Lint runs it by id; the suite now runs under the network guard. - check-image-pins runs check_image_versions.py pins on every commit: its inputs span workflows, Dockerfiles and docs/images, and it fails when one is missing. Lint's pre-commit run replaces its separate step. Adding hooks changes .pre-commit-config.yaml, an input of the ci image, so this pull request takes Lint's slow path and the next Images run publishes a new ci version. Refs: #187 Assisted-by: Claude Code
42 lines
2.6 KiB
Markdown
42 lines
2.6 KiB
Markdown
# Script rules
|
|
|
|
Every rule for the scripts in `scripts/` and their tests in `tests/scripts/`, in full. Each gives
|
|
its reason (*Why*) and how it is held (*Held*): a control names its hook or check; review means a
|
|
person other than the author sees the change before it merges; aspirational means nothing checks
|
|
it. "Until X (#N) lands" names a check that does not exist yet and its backlog issue. General
|
|
rules for scripts (prefer a standard tool, comment length) are in
|
|
[code-style.md](../docs/contributing/code-style.md).
|
|
|
|
## Scripts and their tests
|
|
|
|
- **A script change comes with its test in `tests/scripts/`** (`test_<script>.py`), in the same
|
|
pull request. Run them with `python3 -m unittest discover -s tests/scripts`.
|
|
*Why:* a script decides whether a pull request passes, so an untested change can wave through
|
|
what it should stop. *Held:* control: the `script-tests` pre-push hook runs the
|
|
tests, and the Lint check runs it again; review for whether the change is tested at all.
|
|
- **A line added to `tests/sanity/ignore-common.txt` is a last resort and carries its reason** as
|
|
a trailing `# ...` comment. Fix the finding first. A finding of one ansible-core version only
|
|
goes in a committed `ignore-<MAJOR.MINOR>.txt`, which the Build job appends.
|
|
*Why:* an ignore silences `ansible-test sanity` for good, and one without a reason cannot be
|
|
reviewed or removed later. *Held:* review (`tests/sanity/ignore-*.txt` is under `CODEOWNERS`).
|
|
|
|
## Pinned tools
|
|
|
|
- **A pin in `requirements-dev.txt` changes together with its lock `requirements-dev.lock`.**
|
|
Renovate does both; by hand, run `scripts/lock-requirements.sh` (`--upgrade` also moves
|
|
transitive packages; it needs PyPI and the Python of `.python-version`) and commit the lock in
|
|
the same pull request.
|
|
*Why:* installs use `pip install --require-hashes -r requirements-dev.lock -r
|
|
requirements-dev.txt`, which refuses an unhashed package and any disagreement between the two
|
|
files. *Held:* control: the Lint and Build checks install that way when a pin file changes.
|
|
- **Hook repositories in `.pre-commit-config.yaml` are pinned by commit SHA, with the release in a
|
|
`# frozen: vX.Y.Z` comment.** Find the SHA with
|
|
`git ls-remote <repo> "refs/tags/<tag>" "refs/tags/<tag>^{}"` (the `^{}` line, when there is
|
|
one).
|
|
*Why:* a tag can be moved; a commit SHA cannot. *Held:* review (`.pre-commit-config.yaml` is
|
|
under `CODEOWNERS`).
|
|
|
|
A pin file is also an input of the `ci` image: [images/AGENTS.md](../images/AGENTS.md) has what
|
|
the merge publishes. Whether a workflow runs a script from `main`'s copy or from the pull
|
|
request's is a rule of [.gitea/workflows/AGENTS.md](../.gitea/workflows/AGENTS.md) ("Judge scripts").
|