Introduce sem validate FILE
to check pipeline files
#223
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.yml
from 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 FILE
as 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! ↩