diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2048df664941a1102734c3b9fb710043a820585e..8066ca82168863f98637df93611b4d9048d550c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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)$' diff --git a/Makefile b/Makefile index aa9f5bdb7d3708083b6f1ea8e0715552840bf3ab..f266281fd5e954b86587e530f4aec20faeb1a7c4 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/ci/check_system_workers.py b/ci/check_system_workers.py new file mode 100644 index 0000000000000000000000000000000000000000..0d5dcef51e4add8e7574c668cf0a2881acb5580f --- /dev/null +++ b/ci/check_system_workers.py @@ -0,0 +1,28 @@ +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)