Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate test cases against provided schema #1

Closed

Conversation

echeran
Copy link

@echeran echeran commented Apr 29, 2024

This PR attempts to update unicode-org#767 with automation to ensure that for now & going forward, our test data is stored in well-formed JSON that adheres to the test schema.

The test schema number is currently hard-coded, but if this is good, we can merge this now and look at a followup PR to discern the latest semver automatically from the directory names.

Copy link

@eemeli eemeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can and should be submitted as a separate, follow-on PR to unicode-org#767, rather than getting the former blocked by new concerns, such as whether a custom Python script is the right tool for validating JSON test schemas.

Comment on lines +17 to +20
- name: Validate tests for schema v0.0.1
run: |
cd test
python3 validate.py --schema-dir ./schemas/v0-0-1/
Copy link

@eemeli eemeli Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With something like this, we don't need to define a custom validator script:

Suggested change
- name: Validate tests for schema v0.0.1
run: |
cd test
python3 validate.py --schema-dir ./schemas/v0-0-1/
- run: npm install --global ajv-cli
- run: >
ajv validate --spec=draft2020
-s schemas/v0-0-1/tests.schema.json
-d 'tests/**/*.json'
working-directory: ./test

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of reusing a tool and not having to write a script. But having to enumerate each nested directory is annoying. Also, do we want a command to automatically figure out our latest schema version? The ajv tool only takes a hard coded schema version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the ** segment in the glob pattern takes care of nested directories, so that's not an issue. The only issue is whether we want to have this CI job automatically take the latest schema version, or if we want to manually maintain the CI job to reflect the latest schema every time we change it.

@mradbourne
Copy link
Owner

mradbourne commented Apr 29, 2024

Test validation in CI sounds good, @echeran - thanks.
I'll pull this into a separate PR for unicode-org/message-format-wg to keep contributions bite-sized.

Update: The new branch is https://github.com/mradbourne/message-format-wg/tree/validate-tests

@mradbourne mradbourne changed the base branch from test-schema to validate-tests April 29, 2024 13:01
@echeran
Copy link
Author

echeran commented Apr 30, 2024

Since I moved this PR to upstream at unicode-org#778, I will close this PR now.

@echeran echeran closed this Apr 30, 2024
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.

3 participants