Skip to content
Snippets Groups Projects
Commit d424795c authored by Bastien Abadie's avatar Bastien Abadie Committed by Erwan Rouchet
Browse files

Detect system workers version mismatch through pre-commit

parent c724cd2b
No related branches found
No related tags found
1 merge request!2453Detect system workers version mismatch through pre-commit
......@@ -41,3 +41,12 @@ repos:
args: ['1000']
# Only run on Arkindex unit test files
files: '^arkindex\/[^\/]*\/tests\/(.*\/)?test_.*\.py'
- repo: local
hooks:
- id: check-system-workers-version
name: Check system workers version matches current Arkindex version
entry: python ci/check_system_workers.py
language: system
pass_filenames: false
files: '^(VERSION|arkindex/system_workers.yml)$'
......@@ -47,7 +47,7 @@ schema:
release:
$(eval version:=$(shell cat VERSION))
echo $(version)
git commit VERSION -m "Version $(version)"
git commit VERSION arkindex/system_workers.yml -m "Version $(version)"
git tag $(version)
git push origin master $(version)
......
import sys
from pathlib import Path
import yaml
ROOT = Path(__file__).parent.parent
def check_versions_match():
system_workers_file = ROOT / "arkindex" / "system_workers.yml"
assert system_workers_file.exists(), f"Missing system workers file in {system_workers_file}"
version_file = ROOT / "VERSION"
assert version_file.exists(), f"Missing version file in {version_file}"
version = version_file.read_text().strip()
system_workers = yaml.safe_load(system_workers_file.open())
assert system_workers["version"] == version, f"Version mismatch between VERSION ({version}) and system worker ({system_workers['version']})"
if __name__ == "__main__":
try:
check_versions_match()
except AssertionError as e:
print(f"[ERROR] {e}")
sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment