Skip to content

ci: check Python and JS KB sync in kb-check.yml - #1539

Open
shivamtiwari3 wants to merge 1 commit into
google:mainfrom
shivamtiwari3:ci-kb-check-python-js-sync
Open

shivamtiwari3 wants to merge 1 commit into
google:mainfrom
shivamtiwari3:ci-kb-check-python-js-sync

Conversation

@shivamtiwari3

Copy link
Copy Markdown

Fixes #1535.

Summary

.github/workflows/kb-check.yml verified that assets/content_types_kb.min.json is in sync (sync_kb.py --check) and the Rust workflow verified the Rust generated files, but nothing checked the Python and JS files generated from the KB. A content type label rename or an is_text change could leave these stale:

  • python/src/magika/types/content_type_label.py
  • js/src/content-type-label.ts
  • js/src/content-types-infos.ts

Change

  • Run uv run python/scripts/sync.py python and uv run python/scripts/sync.py js, then fail if git diff --exit-code reports changes to the three generated files, with a message pointing at just sync-kb.
  • Add python/scripts/sync.py, the Python generated file, and the two JS generated files to the workflow's paths triggers.

Testing

  • uv run python/scripts/sync.py python and ... js are idempotent on a clean tree (no diff).
  • Simulated a stale generated file (committed a modified content_type_label.py); the new check reports it out of sync and exits non-zero.
  • python -c "import yaml; yaml.safe_load(...)" parses the workflow.

Note

@reyammer mentioned doing this via the new just sync-kb. I kept it to the Python/JS steps described in the issue so the workflow doesn't rebuild the Rust side (which rust-test.yml already checks), but I'm happy to switch to uvx --from rust-just just sync-kb if you prefer a single entry point.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: check Python and JS KB sync in kb-check.yml

1 participant