diff --git a/.github/workflows/generate-hatch-matrix.sh b/.github/workflows/generate-hatch-matrix.sh new file mode 100644 index 0000000..1085a68 --- /dev/null +++ b/.github/workflows/generate-hatch-matrix.sh @@ -0,0 +1,9 @@ +set -u +outfile=$1 +hatch env show --json | jq 'to_entries | map(select(.key | startswith("test")))' | jq '{include: map({"hatch-env-name": .key, "python-version": .value.python})}' > $outfile + +git diff --exit-code $outfile +if [ $? -ne 0 ]; then + echo "Hatch environment matrix has changed. Please commit ${outfile}." + exit 1 +fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5970dc1..25bf531 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,21 @@ repos: - id: conventional-pre-commit stages: [commit-msg] + - repo: local + hooks: + - id: generate-hatch-matrix + name: generate-hatch-matrix + language: system + entry: bash .github/workflows/generate-hatch-matrix.sh + files: | + (?x)^( + .github/workflows/generate-hatch-matrix.sh| + .github/workflows/hatch-matrix.json + )$ + args: [".github/workflows/hatch-matrix.json"] + pass_filenames: false + types: [file] + ci: # autofix_commit_msg: | # [pre-commit.ci] auto fixes from pre-commit.com hooks @@ -42,5 +57,6 @@ ci: # autoupdate_branch: '' # autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' autoupdate_schedule: monthly - # skip: [] + skip: + - generate-hatch-matrix # submodules: false