diff --git a/.evergreen/scripts/generate-config.sh b/.evergreen/scripts/generate-config.sh new file mode 100755 index 0000000000..70b4578cf9 --- /dev/null +++ b/.evergreen/scripts/generate-config.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Entry point for the generate-config pre-commit hook. + +set -eu + +python .evergreen/scripts/generate_config.py diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index 54d5e4efe8..5d067923b6 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -1,12 +1,4 @@ -# /// script -# requires-python = ">=3.9" -# dependencies = [ -# "shrub.py>=3.2.0", -# "pyyaml>=6.0.2" -# ] -# /// - -# Note: Run this file with `pipx run`, or `uv run`. +# Note: See CONTRIBUTING.md for how to update/run this file. from __future__ import annotations import sys @@ -1113,7 +1105,7 @@ def write_variants_to_file(): with target.open("w") as fid: fid.write("buildvariants:\n") - for name, func in getmembers(mod, isfunction): + for name, func in sorted(getmembers(mod, isfunction)): if not name.endswith("_variants"): continue if not name.startswith("create_"): @@ -1143,7 +1135,7 @@ def write_tasks_to_file(): with target.open("w") as fid: fid.write("tasks:\n") - for name, func in getmembers(mod, isfunction): + for name, func in sorted(getmembers(mod, isfunction)): if not name.endswith("_tasks"): continue if not name.startswith("create_"): diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 335bf97490..bab2ea47da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -116,3 +116,9 @@ repos: (?x)( .evergreen/retry-with-backoff.sh ) + - id: generate-config + name: generate-config + entry: .evergreen/scripts/generate-config.sh + language: python + require_serial: true + additional_dependencies: ["shrub.py>=3.2.0", "pyyaml>=6.0.2"] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8cc8c8bcd..c31d2d1c96 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -367,7 +367,7 @@ If you are running one of the `no-responder` tests, omit the `run-server` step. - If there are any special test considerations, including not running `pytest` at all, handle it in `.evergreen/scripts/run_tests.py`. - If there are any services or atlas clusters to teardown, handle them in `.evergreen/scripts/teardown_tests.py`. - Add functions to generate the test variant(s) and task(s) to the `.evergreen/scripts/generate_config.py`. -- Regenerate the test variants and tasks using the instructions in `.evergreen/scripts/generate_config.py`. +- Regenerate the test variants and tasks using `pre-commit run --all-files generate-config`. - Make sure to add instructions for running the test suite to `CONTRIBUTING.md`. ## Re-sync Spec Tests