-
Notifications
You must be signed in to change notification settings - Fork 190
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
Workflow validation #820
Workflow validation #820
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #820 +/- ##
==========================================
- Coverage 78.40% 78.34% -0.06%
==========================================
Files 22 22
Lines 2477 2480 +3
==========================================
+ Hits 1942 1943 +1
- Misses 535 537 +2
Continue to review full report at Codecov.
|
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.
Love it! Super clean code, just as I'd hoped 🚀
Would be nice to add the ability to ignore specific files if listed in the linting config. Pattern for doing this in some other lint tests somewhere.
# load workflow | ||
wf_path = os.path.join(self.wf_path, ".github/workflows", wf) | ||
with open(wf_path, "r") as fh: | ||
wf_json = yaml.safe_load(fh) |
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.
Would be good to catch errors raised from yaml syntax problems and log as a failure here.
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.
Good point - those files are also loaded in the other actions_* lint checks, I guess it makes sense to catch those errors there as well? Could basically just copy-paste the same code. We'll have a few redundant errors reported then, if the yml is wrong.
Thanks for the review! |
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.
Love it! Haven't tested but review on my phone looks good. Couple of very minor suggestions but LGTM ✅
Validate workflows against a schema | ||
|
||
Uses the JSON Schema from | ||
https://json.schemastore.org/github-workflow |
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.
Needs to be valid RST to make the hyperlink work in the docs.
Would also be good to add a bit more detail here - which files exactly? And where to get help (the URL is just a big JSON document). Have to assume that people reading this might not know that these files even exist..
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.
Aaah sorry, didn't think about that this will be rendered at that moment 😱
Will write a nicer message, thanks!
Added a longer description - not sure if there's anything else worth mentioning there except what these workflow files are for, where they are, and what the lint test checks. Let me know if something else comes to your mind! Also added a commit to cast the exception at the schema validation to string, which should make the code more robust (as mentioned in slack). |
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.
Perfect ✨
PR checklist
CHANGELOG.md
is updateddocs
is updatedAdded the lint function
actions_schema_validation
which uses the GitHub workflow JSON schema to validate GitHub action workflows in.github/workflows/
.As suggested in #795