Skip to content

Commit

Permalink
Add check-packages-versions hook to pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pamella committed Jun 26, 2024
1 parent 6c99fde commit 1e111ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ repos:
# Only run missing migration check if migration-generating files have changed:
files: (.*/?(settings|migrations|models)/.+|.+models\.py|.+constants\.py|.+choices\.py|.+pyproject\.toml)
pass_filenames: false
- id: check-packages-versions
name: check packages versions
entry: ./scripts/check_packages_versions.sh
language: script
files: ^(pyproject\.toml|frontend/package\.json)$
- id: generate-openapi-schema
name: generate OpenAPI schema
entry: poetry run python manage.py generate_openapi_schema --output frontend/openapi_schema.json
Expand Down
13 changes: 13 additions & 0 deletions scripts/check_packages_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | awk -F'"' '{print $2}')
PACKAGE_JSON_VERSION=$(grep '"version":' frontend/package.json | awk -F'"' '{print $4}')

if [ "$PYPROJECT_VERSION" != "$PACKAGE_JSON_VERSION" ]; then
echo "Version mismatch: pyproject.toml ($PYPROJECT_VERSION) != frontend/package.json ($PACKAGE_JSON_VERSION)"
echo "The backend and the frontend are versioned together, that is, they should have the same version number."
echo "Please update the version number in both files to match."
exit 1
fi

echo "Versions match."

0 comments on commit 1e111ec

Please sign in to comment.