Introduce sem validate FILE to check pipeline files#223
Draft
caius wants to merge 1 commit intosemaphoreci:masterfrom
Draft
Introduce sem validate FILE to check pipeline files#223caius wants to merge 1 commit intosemaphoreci:masterfrom
sem validate FILE to check pipeline files#223caius wants to merge 1 commit intosemaphoreci:masterfrom
Conversation
Author
|
Hey folks! I'm not expecting this to land as-is, I'd like to tidy up the DX of it for starters. (Exit code when YAML is invalid. Perhaps parse the schema violations and present a bit nicely?) Before I go too much further with this, is there much appetite to having this land upstream in |
Contributor
|
Thanks for submitting this @caius. I think this would be a really helpful addition to the CLI. A few notes that might make this a little bit better:
@DamjanBecirovic @radwo we should fix the API to expose errors in a more consumable format, like this: And then, displaying them in table should be easy enough, like this: |
When you're authoring files locally it's a pain pushing changes to double-check the YAML syntax is corrected, that you've nested the blocks correctly and that you've put your `run:` clause at the right level. Make it easy to validate the syntax of the file from local machines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I went looking in the cli for this feature and reached out to support, who pointed me at the /v1alpha/yaml API docs1 so I figured wrapping it in the cli would be useful as I keep trying to reach for it.
It's a painful feedback loop to copy/paste a
.semaphore/semaphore.ymlfrom one project to another and edit it, then remember there's some extra stuff from a second project you want to include, so you copy/paste that lot in. Then you push your changes and find a simple syntax error in the pipeline file. Being able to check that before pushing, even though it is limited in what it can check is still super useful and being able to do it from your dev machine is a super tight feedback loop.Initially I started trying to wedge this under
sem get pipeline validate FILEas it's a pipeline related task. That's not where it lives in the API though, so I moved it to a top level command just now.sem validate FILE.The output isn't great, it seems depending on whether it's parseable YAML or a schema error we can get back different error outputs. Following the lead of the UI, I'm just dumping the response back to the user with a quick note on 👍/👎 first.
Footnotes
Thanks Noelia and Marko! ↩