Skip to content

Commit 9fb969a

Browse files
committed
ci: add pre-commit hook to detect generated base_client drift
Compares the hand-written base_client.py against the generated copy and fails if they diverge, preventing releases with stale codegen.
1 parent 25f00a9 commit 9fb969a

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ repos:
4040
language: system
4141
types: [python]
4242
exclude: "^deezer_python_gql/generated/"
43+
- id: check-codegen-sync
44+
name: check-codegen-sync
45+
entry: scripts/check_codegen_sync.sh
46+
language: script
47+
always_run: true
48+
pass_filenames: false

scripts/check_codegen_sync.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
# Verify that generated/base_client.py is in sync with the hand-written base_client.py.
3+
# The generated copy has a 2-line header ("# Generated by ariadne-codegen\n") that we skip.
4+
set -euo pipefail
5+
6+
if ! diff <(tail -n +3 deezer_python_gql/generated/base_client.py) deezer_python_gql/base_client.py > /dev/null 2>&1; then
7+
echo "ERROR: generated/base_client.py is out of sync with base_client.py"
8+
echo "Run 'make codegen' to regenerate."
9+
exit 1
10+
fi

0 commit comments

Comments
 (0)