Skip to content

Commit 5a44905

Browse files
authored
dev: include ASF status checks in the local lint suite (#25313)
## Which issue does this PR close? - Part of #21048. The issue stays open for the other checklist items. ## Rationale for this change `.asf.yaml` lists the GitHub Actions jobs that must pass before a PR can merge. If a job is renamed and `.asf.yaml` still requires the old name, PRs wait for a status that never arrives. CI runs `ci/scripts/check_asf_yaml_status_checks.py` in `dev.yml` to catch this, but `dev/rust_lint.sh` does not. A contributor can pass the local lint suite and then see the failure only in CI. This PR adds the existing validator to the local suite. ## What changes are included in this PR? - `dev/rust_lint.sh` runs `ci/scripts/check_asf_yaml_status_checks.py` as a read-only step, after the workflow install check and before the Markdown link check. The `--write` and `--allow-dirty` flags never reach it. - The runner needs `python3` on `PATH` with PyYAML installed. It checks both after argument parsing and before any tool install or formatter, and it reports a distinct error for each missing prerequisite. It does not install Python packages. Help output does not run these checks. - `ci/scripts/check_asf_yaml_status_checks.py` becomes executable, because the runner invokes each registered script directly. The script body, `.asf.yaml`, and the GitHub workflow do not change. - `docs/source/contributor-guide/testing.md` documents the purpose of the check, the Python setup, the standalone command, and the local lint integration. ## What is the testing strategy for this PR? - The real validator passes on this branch through `python3 ci/scripts/check_asf_yaml_status_checks.py` and through direct invocation, with Python 3.14.7 and PyYAML 6.0.3. - Disposable configurations exercised the real validator. A valid configuration passes. A required name with no matching job fails with the existing diagnostic. A name served only by a path-filtered workflow fails, and an added unfiltered workflow makes it pass. - A disposable fixture with stubbed steps and tools exercised the runner. The validator runs once with no arguments in check mode and in both write modes. A missing `python3` and a missing PyYAML each stop the suite with their own error before any tool install or formatter. Help output skips the checks. A validator failure stops the later steps. - A disposable clone with a bogus required name in `.asf.yaml`: `./dev/rust_lint.sh` fails with the validator diagnostic before the link check, and passes again after the file is restored. - The full `./dev/rust_lint.sh` passes on this branch. ## Are there any user-facing changes? No. The local lint suite gains the check and needs Python 3 with PyYAML. CI is unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 62dc7ac commit 5a44905

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎ci/scripts/check_asf_yaml_status_checks.py‎

100644100755
File mode changed.

‎dev/rust_lint.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ done
8888
SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")"
8989
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9090

91+
# `ci/scripts/check_asf_yaml_status_checks.py` runs with `python3` from PATH
92+
# and imports PyYAML. Report a missing prerequisite before any tool is
93+
# installed or any formatter runs, and point at `uv run`, which sets up the
94+
# Python dependencies from the uv workspace.
95+
ensure_python_with_yaml() {
96+
if ! command -v python3 &> /dev/null; then
97+
echo "[${SCRIPT_NAME}] python3 was not found on PATH. Please run the suite through uv, which provides Python and its packages: uv run ./dev/rust_lint.sh" >&2
98+
exit 1
99+
fi
100+
if ! python3 -c 'import yaml' &> /dev/null; then
101+
echo "[${SCRIPT_NAME}] PyYAML is not installed for $(command -v python3). Please run the suite through uv, which installs it: uv run ./dev/rust_lint.sh" >&2
102+
exit 1
103+
fi
104+
}
105+
106+
ensure_python_with_yaml
107+
91108
# Load the tool versions shared with CI (for example, LYCHEE_VERSION).
92109
source "${SCRIPT_DIR}/../ci/scripts/utils/tool_versions.sh"
93110

@@ -114,6 +131,7 @@ declare -a WRITE_STEPS=(
114131

115132
declare -a READONLY_STEPS=(
116133
"ci/scripts/check_no_cargo_install_in_workflows.sh|false"
134+
"ci/scripts/check_asf_yaml_status_checks.py|false"
117135
"ci/scripts/markdown_link_check.sh|false"
118136
"ci/scripts/rust_docs.sh|false"
119137
)

‎docs/source/contributor-guide/testing.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,25 @@ Rust doc comments are validated by rustdoc in CI and can be checked locally with
220220
bash ci/scripts/rust_docs.sh
221221
```
222222

223+
## ASF Status Check Validation
224+
225+
`ci/scripts/check_asf_yaml_status_checks.py` checks that every required status
226+
check in `.asf.yaml` matches a job in `.github/workflows`. `./dev/rust_lint.sh`
227+
runs it and needs `python3` with [PyYAML]. The [uv] workspace provides both:
228+
229+
```shell
230+
uv run ./dev/rust_lint.sh
231+
```
232+
233+
To run the check on its own:
234+
235+
```shell
236+
uv run python3 ci/scripts/check_asf_yaml_status_checks.py
237+
```
238+
239+
[pyyaml]: https://pypi.org/project/PyYAML/
240+
[uv]: https://docs.astral.sh/uv/
241+
223242
## Benchmarks
224243

225244
### Criterion Benchmarks

0 commit comments

Comments
 (0)