-
Notifications
You must be signed in to change notification settings - Fork 26
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
Schema adherence validator #77
Conversation
This PR is a blocking pre-requisite for facebookincubator/TTPForge#83 |
Hey there, could you please post a couple (3-ish) screenshots of what different kinds of YAML validation failures look like to the end user who runs pre-commit. This will help determine whether this should be a user-facing feature baked into pre-commit or something used ad-hoc for ART imports. |
Absolutely! Here's an example of how we can get this to flag an invalid TTP:
Next, we make the following changes to broken-example.yaml:
As you can see, the step no longer has a name, which is not going to work. Next, we add the commit:
When we run
Here's another example:
Next, we make the following changes to broken-ttp.yaml:
As you can see, the step no longer has an Next, we add the commit:
When we run
For the third example:
Next, we make the following changes to broken-args.yaml:
As you can see, the step no longer has a name, which is not going to work. Next, we add the commit:
When we run
|
- Introduced a new pre-commit hook script `validate-yaml.sh` to validate all committed YAML files against a predefined schema using mage's `validateallyamlfiles` command. - Updated `.pre-commit-config.yaml` to include the new `validate-yaml-files` hook. - Added a new schema file `ttpforge-spec.yaml` under the `docs/` directory to define the structure and properties for the TTP YAML files. - Enhanced the `magefile.go` to include the new function `ValidateAllYAMLFiles` which uses the schema for validation. - Dependencies were updated in `magefiles/go.mod` and `magefiles/go.sum`.
- Streamlined the YAML validation process by consolidating it into a shared function. - Improved error messaging for enhanced clarity. - Established a new function, loadSchema, to facilitate schema loading and unmarshalling from a YAML file. - Enhanced ValidateYAML to accommodate schema path input and extended support for directory-wide YAML file validation. - Revised the validateAllYAML function to furnish comprehensive error messages and enhanced logging. - Elevated error handling for YAML validation by providing informative error messages. - Augmented the inspectAndValidate function to adeptly manage nested SubTTPSteps and validate referenced files. - Implemented custom validation to ascertain the presence of the "name" property when "ttp" is declared in a step. This commit amplifies the effectiveness of YAML file validation, ensuring strict adherence to the schema. Introduces a pre-commit hook mechanism to preemptively thwart the commitment of non-conforming YAML files.
- Fixed concurrency and infinite recursion bugs - Resolved issue with having set -e set - Optimized output to be useful
…alidator.go. - Fixed failures to catch problems in editsteps and args
Thank you for the test cases. Seems like there are two possible approaches:
The existing code catches all of these test cases, but it is only called from I'm cool with stamping this as an experiment that will tell us which approach is better, but I'm maxed out so @l50 you'll need to assume sole responsibility for keeping this schema up to date. Cool? |
I'm good with ownership of the schema to land it for now. I plan to automate its generation eventually - will just take some concerted effort on my part. In the meantime, I've cut an FR to track it: #80 |
cool, ship |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fat fingered close - my bad, LGTM after discussion on schema ownership
Proposed Changes
.pre-commit-config.yaml
to include the newvalidate-yaml-files
hook and added a schema filettpforge-spec.yaml
for TTP YAML files structure and properties definition.Related Issue(s)
N/A
Testing
validate-yaml.sh
to validate all committed YAML files against a predefined schema.magefile.go
, such asValidateYAML
, which leverages the newly defined schema for validation.Documentation
ttpforge-spec.yaml
under thedocs/
directory.validate-yaml-files
hook was documented in.pre-commit-config.yaml
.Screenshots/GIFs (optional)
N/A
Checklist
mage runprecommit
locally and fixed any issues that arose.