Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdding linting checks for buildbot_steps.yml #14051
Conversation
6a7aae3
to
7357244
|
This is still a work-in-progress per @aneeshusa. I'd like some feedback on if I'm taking the right approach with adding linting checks for buildbot_steps files, and YML files in general, along with using somewhat-descriptive messages. |
|
r? @aneeshusa |
|
|
7357244
to
f247ca4
| if not file_name.endswith("buildbot_steps.yml"): | ||
| raise StopIteration | ||
|
|
||
| # YAML specification doesn't necessarily prevent |
This comment has been minimized.
This comment has been minimized.
| return loader.construct_mapping(node, deep) | ||
|
|
||
|
|
||
| class SafeYamlLoader(yaml.SafeLoader): |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Nov 15, 2016
Member
I don't see the benefit of this over using yaml.SafeLoader in the qualified form.
This comment has been minimized.
This comment has been minimized.
leikahing
Nov 15, 2016
Author
Contributor
I guess for the unit tests, it's not necessary. Only reason to do this is because I do the SafeYamlLoader.add_constructor later on, which mutates the YAML loader. If I did this to the default yaml.SafeLoader, it would modify it globally.
This comment has been minimized.
This comment has been minimized.
aneeshusa
Nov 15, 2016
Member
Oh, I misread and thought we were calling add_constructor on an object returned by the Loader constructor, i.e.
loader = yaml.SafeLoader()
loader.add_constructor(...)
yaml.load(contents, loader=loader)
Since we're mutating the Loader itself, having the SafeYamlLoader seems like a better idea, so let's go back to that approach.
This comment has been minimized.
This comment has been minimized.
aneeshusa
Nov 15, 2016
Member
Oh, and please add a comment with this explanation for why we're making a subclass.
|
Looks pretty good overall - just a few nits that I can see right now. The error messages are fine for now IMO. |
| # buildbot_steps.yml as it could lead to confusion | ||
| SafeYamlLoader.add_constructor( | ||
| yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, | ||
| duplicate_key_yaml_constructor) |
This comment has been minimized.
This comment has been minimized.
|
@aneeshusa Thanks for the feedback/review! Just updated my PR with changes addressing the issues you pointed out. |
|
|
||
| def lint_buildbot_steps_yaml(mapping): | ||
| # Check for well-formedness of contents | ||
| # A well-formed buildbot_steps.yml should just be a map to list of strings |
This comment has been minimized.
This comment has been minimized.
e0373c6
to
81b257f
|
Review ping @aneeshusa |
|
Sorry about the delay! Looks good, but I'd still like to move back to subclassing |
81b257f
to
e28d1b2
|
@aneeshusa Sorry, I didn't see the continuation of our code review discussion - GitHub apparently doesn't notify me of that. I put the |
|
Thanks @birryree! @bors-servo r+ |
|
|
Adding linting checks for buildbot_steps.yml This pull request adds some tidy checks around YAML files, and specifically `buildbot_steps.yml`. Tidy checks added: * YAML files are checked for well-formedness/parse-ability * Whether a YAML file has duplicate keys * Whether a `buildbot_steps.yml` file contains only mappings to list-of-strings. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] These changes fix #13838 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> …ing checking for correct mappings and duplicate YAML keys. Added unit tests to test_tidy.py. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14051) <!-- Reviewable:end -->
|
|
|
This commit adds tidy checks for buildbot_steps.yml, as well as unit tests. These checks include: * Checking buildbot_steps.yml can be parsed by a YAML loader * buildbot_steps.yml does not contain duplicate keys * buildbot_steps.yml keys map to a list of strings
e28d1b2
to
aceb60e
|
Forgot to run Pushed an update that resolves all that. |
|
@bors-servo r+ |
|
|
Adding linting checks for buildbot_steps.yml This pull request adds some tidy checks around YAML files, and specifically `buildbot_steps.yml`. Tidy checks added: * YAML files are checked for well-formedness/parse-ability * Whether a YAML file has duplicate keys * Whether a `buildbot_steps.yml` file contains only mappings to list-of-strings. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] These changes fix #13838 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> …ing checking for correct mappings and duplicate YAML keys. Added unit tests to test_tidy.py. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14051) <!-- Reviewable:end -->
|
|
leikahing commentedNov 3, 2016
•
edited by larsbergstrom
This pull request adds some tidy checks around YAML files, and specifically
buildbot_steps.yml.Tidy checks added:
buildbot_steps.ymlfile contains only mappings to list-of-strings../mach build -ddoes not report any errors./mach test-tidydoes not report any errors…ing checking for correct mappings and duplicate YAML keys. Added unit tests to test_tidy.py.
This change is