diff --git a/ci/scripts/check_asf_yaml_status_checks.py b/ci/scripts/check_asf_yaml_status_checks.py old mode 100644 new mode 100755 diff --git a/dev/rust_lint.sh b/dev/rust_lint.sh index 542ed18c6bd72..6f185d2348cba 100755 --- a/dev/rust_lint.sh +++ b/dev/rust_lint.sh @@ -88,6 +88,23 @@ done SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# `ci/scripts/check_asf_yaml_status_checks.py` runs with `python3` from PATH +# and imports PyYAML. Report a missing prerequisite before any tool is +# installed or any formatter runs, and point at `uv run`, which sets up the +# Python dependencies from the uv workspace. +ensure_python_with_yaml() { + if ! command -v python3 &> /dev/null; then + 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 + exit 1 + fi + if ! python3 -c 'import yaml' &> /dev/null; then + 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 + exit 1 + fi +} + +ensure_python_with_yaml + # Load the tool versions shared with CI (for example, LYCHEE_VERSION). source "${SCRIPT_DIR}/../ci/scripts/utils/tool_versions.sh" @@ -114,6 +131,7 @@ declare -a WRITE_STEPS=( declare -a READONLY_STEPS=( "ci/scripts/check_no_cargo_install_in_workflows.sh|false" + "ci/scripts/check_asf_yaml_status_checks.py|false" "ci/scripts/markdown_link_check.sh|false" "ci/scripts/rust_docs.sh|false" ) diff --git a/docs/source/contributor-guide/testing.md b/docs/source/contributor-guide/testing.md index 2d0cad99cfddb..dc4430ebf4a1f 100644 --- a/docs/source/contributor-guide/testing.md +++ b/docs/source/contributor-guide/testing.md @@ -220,6 +220,25 @@ Rust doc comments are validated by rustdoc in CI and can be checked locally with bash ci/scripts/rust_docs.sh ``` +## ASF Status Check Validation + +`ci/scripts/check_asf_yaml_status_checks.py` checks that every required status +check in `.asf.yaml` matches a job in `.github/workflows`. `./dev/rust_lint.sh` +runs it and needs `python3` with [PyYAML]. The [uv] workspace provides both: + +```shell +uv run ./dev/rust_lint.sh +``` + +To run the check on its own: + +```shell +uv run python3 ci/scripts/check_asf_yaml_status_checks.py +``` + +[pyyaml]: https://pypi.org/project/PyYAML/ +[uv]: https://docs.astral.sh/uv/ + ## Benchmarks ### Criterion Benchmarks