From e90687326ddaec3d83ea6373345f30a4f529f114 Mon Sep 17 00:00:00 2001 From: Shivam Tiwari <33183708+shivamtiwari3@users.noreply.github.com> Date: Sat, 10 Oct 2026 00:13:28 +0400 Subject: [PATCH] ci: check Python and JS KB sync in kb-check.yml (fixes #1535) The KB check verified assets/content_types_kb.min.json and (via the Rust workflow) the Rust generated files, but nothing checked the Python and JS files generated from the KB. A label rename or an is_text change could leave python/src/magika/types/content_type_label.py, js/src/content-type-label.ts and js/src/content-types-infos.ts stale. Run python/scripts/sync.py for python and js and fail if the tracked generated files changed. Also trigger the workflow when those generated files or python/scripts/sync.py change. --- .github/workflows/kb-check.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/kb-check.yml b/.github/workflows/kb-check.yml index f221a488..ebb4f42d 100644 --- a/.github/workflows/kb-check.yml +++ b/.github/workflows/kb-check.yml @@ -11,6 +11,10 @@ on: - "assets/content_types.yaml" - "assets/content_types_kb.min.json" - "assets/models/**" + - "js/src/content-type-label.ts" + - "js/src/content-types-infos.ts" + - "python/scripts/sync.py" + - "python/src/magika/types/content_type_label.py" - "rust/gen/model" - "rust/rules/rulesets/**" - "scripts/sync_kb.py" @@ -37,3 +41,16 @@ jobs: - name: Check content_types_kb.min.json is in sync run: uv run scripts/sync_kb.py --check + + - name: Check Python and JS generated files are in sync + run: | + uv run python/scripts/sync.py python + uv run python/scripts/sync.py js + if ! git diff --exit-code -- \ + python/src/magika/types/content_type_label.py \ + js/src/content-type-label.ts \ + js/src/content-types-infos.ts + then + echo "::error::Python and JS files generated from assets/content_types.yaml are out of sync. Run 'just sync-kb' locally and commit the changes." + exit 1 + fi