Skip to content

Commit

Permalink
ci: add script to generate hatch matrix, integrate pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ketozhang committed Dec 9, 2024
1 parent 8460530 commit ad3a901
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/generate-hatch-matrix.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ad3a901

Please sign in to comment.