Add CI workflow to validate the exercise dataset#57
Open
Mavi9412 wants to merge 1 commit into
Open
Conversation
Adds a GitHub Actions workflow that runs on every PR and push to main touching the dataset, checking: - data/exercises.json validates against data/exercises.schema.json (JSON Schema draft 2020-12, via ajv) - no duplicate exercise ids - every image and gif_url path resolves to a real file - index.html's embedded copy of the dataset stays in sync with data/exercises.json None of this was previously enforced, so a future data or translation PR could silently break the schema, reference a missing media file, or leave index.html out of sync with the source data. The validation script fails with a clear message rather than a raw stack trace on malformed JSON, a broken schema, or missing required fields, since those are the most likely mistakes for a contributor hand-editing a large JSON file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This repo currently has no automation at all — every data or translation PR is merged on trust. This adds a single GitHub Actions workflow that validates
data/exercises.jsonon every PR and push tomain, covering five checks:data/exercises.jsonagainstdata/exercises.schema.json(draft 2020-12, viaajv)imagepath resolves to a real filegif_urlpath resolves to a real fileindex.html's embedded copy of the dataset stays in sync withdata/exercises.json—index.htmlinlines the full dataset as a JS literal for offline use; today it's byte-identical todata/exercises.json, but nothing currently stops that from silently drifting on a future data PRThe workflow installs
ajv/ajv-formatsat CI time (npm install --no-save) rather than committing apackage.json/lockfile, to keep the repo's zero-build, "just open the HTML files" design intact.Why
The last several merged PRs in this repo's history are contributors adding new-language instructions (French, Hindi, Polish, Korean...). That pattern is exactly where an unenforced schema causes real friction —
daceea8is a follow-up commit fixing the JSON Schema's language maps after a language PR had already been merged once. This workflow would have caught that at review time instead of needing a second commit.Design notes
index.htmlsync check parses the embedded array with a small bracket-depth scanner rather than a fixed regex, so it keeps working whether the array is minified or reformatted to multi-line JSON later.exercises.json, a broken schema) are caught and reported as a clear✗ message, not a raw stack trace — since a JSON syntax slip is the most likely mistake for a contributor hand-editing a ~150k-line file, and it deserves the clearest error of anything this workflow checks.pushis restricted tobranches: [main]andpull_requestcovers incoming PRs (including forks), so a PR from a branch in this repo doesn't trigger the workflow twice for the same commit.permissions: contents: readandtimeout-minutes: 5are set explicitly — the job only reads the repo and doesn't need more than that.Test plan
Verified locally by deliberately breaking each check one at a time against the real dataset and confirming a correct failure, then restoring:
idis caughtimagefile is caughtgif_urlfile is caughtbody_partenum, missing required language) is caughtindex.htmlgoing out of sync withdata/exercises.jsonis caughtdata/exercises.jsonproduces a clean error, not a stack traceimage/gif_urlentirely reports a clear message instead of"missing image file \"undefined\""push/pull_requestpath list stays in sync via a YAML anchor