Add JSON Schema for validating testsuite files #154
Merged
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.
Overview
This pull request is about adding a JSON Schema file that can be used to validate test-suite files.
Most popular IDEs (IntelliJ, Visual Studio Code, etc.) support applying schemas to YAML files using a JSON Schema. This provides comprehensive documentation as well as code completion while editing the test-suite file:
In addition, test-suite files can be validated while editing so wrongfully added additional properties or incorrect data types can be detected while editing:
Based on the current documentation, I created such a schema file containing (hopefully) all possible configuration options (test suites, test jobs, assertions, ...).
How to use
Visual Studio Code
When developing with VSCode, the very popular YAML plug-in (created by RedHat) allows adding references to schemas by adding a comment line on top of the file:
Alternatively, you can add the schema globally to the IDE, using a well defined pattern:
Once this pull request is merged, the above mentioned URLs should be changed to the URL within this repo:
https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
IntelliJ
Similar to VSCode, IntelliJ allows mapping file patterns to schemas via preferences:
Languages & Frameworks -> Schemas and DTDs -> JSON Schema Mappings
Future outlook
Afore mentioned IDEs (and also others) support automatic download of JSON schemas from schemastore.org. If the schema was added to schemastore.org, no additional configuration in the IDE would be necessary. New users to helm-unittest would automatically get schema validation out of the box.
I'd like to follow through with that idea and provide such a pull request for the schema store, but of course only with your consent @quintush . WDYT?