-
Notifications
You must be signed in to change notification settings - Fork 85
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
Adds workflow:validate command #2650
Conversation
dbbf05e
to
1706240
Compare
Size Change: +156 kB (+0.3%) Total Size: 52.9 MB
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2650 +/- ##
==========================================
+ Coverage 52.92% 52.95% +0.04%
==========================================
Files 570 572 +2
Lines 21834 21951 +117
Branches 4297 4329 +32
==========================================
+ Hits 11554 11623 +69
- Misses 10246 10294 +48
Partials 34 34 ☔ View full report in Codecov by Sentry. |
5633e1e
to
91fc501
Compare
Subscribed to pull request
Generated by CodeMention |
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.
- package manager discrepancy to fix
- YAML parser discrepancy to comment on or fix
- spinner to reconsider?
|
||
try { | ||
const fileContents = await fs.readFile(filePath, 'utf8'); | ||
const parsedYaml = yaml.load(fileContents); |
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.
It would be much better if the command could also validate the schema, currently only in www
. I think this is a sensible reason to move the workflow schema to eas-build-job
later…
Another viable approach would be to use createWorkflowRun
with some dry = true
flag, or something. It would not create a workflow run or a workflow revision, only parse and validate with www
.
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.
Yeah, I guess that schema validation would have the biggest benefit for a user here, it would catch all of the typos and so on. Let's move the schema definition to eas-build-job
and validate against it 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.
I'm not sure how to move this to eas-build-job
(not familiar with where that code is or what change to make there). Could we either pair or could one of you help me?
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.
Also, ideally we'd write a JSON schema that we can validate against, and not only check that the YAML is valid. Adding that where the workflow runs would be great, then exporting it to here would be nice, to validate on the server and on the client, and have the same set of rules.
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.
I'm not sure how to move this to eas-build-job (not familiar with where that code is or what change to make there). Could we either pair or could one of you help me?
Don't worry about it @jonsamp, this doesn't need to be a part of this PR and we can do it because we are familiar why how things work there 🙌
Also, ideally we'd write a JSON schema that we can validate against, and not only check that the YAML is valid. Adding that where the workflow runs would be great, then exporting it here would be nice, to validate on the server and on the client, and have the same set of rules.
I believe this is what @sjchmiela meant, we have this JSON schema validation implemented using Zod ready and working on both worker-level and WWW-level. We need to move it to eas-build-job
which is a common lib for such definitions, that is shared between here, WWW, and other places 👍
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.
I'm not sure how to move this to eas-build-job (not familiar with where that code is or what change to make there). Could we either pair or could one of you help me?
Will do. In the meantime, I think this is good to go. It's not a blocker.
ideally we'd write a JSON schema that we can validate against
I agree. I started looking into it a while back, but it wasn't too easy. Let me explain.
Exporting JSON schema from Zod schema (or writing it) for the "general" structure of the workflow YAML is easy. Validation of the actual jobs is where it becomes kinda difficult, because we either:
- export Zod directly — then interpolations will be "error", because
platform: android | ios
does not expectplatform: ${{ needs.setup.outputs.platform }}
."${{ needs.setup.outputs.platform }}"
is not"android"
or"ios"
after all. - do some post-processing on Zod types, replacing enums with strings or expanding enum properties to allow that enum or an arbitrary string.
I think I had a branch somewhere that exposed this from www
…
All in all — not a blocker for this to go.
|
||
try { | ||
const fileContents = await fs.readFile(filePath, 'utf8'); | ||
const parsedYaml = yaml.load(fileContents); |
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.
Yeah, I guess that schema validation would have the biggest benefit for a user here, it would catch all of the typos and so on. Let's move the schema definition to eas-build-job
and validate against it here.
⏩ The changelog entry check has been skipped since the "no changelog" label is present. |
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.
Awesome, thanks for applying suggested changes 🚀
Why
This adds a command to validate YAML in workflow configuration files.
Screenshots
Valid YAML output
Invalid YAML output
Test Plan
Create a .yml file and test it with
eas workflow:validate path/to/file.yml
. You should see output like the screenshots above.