Pipeline linting throws exit code 0 upon failure
Description
When glab ci lint
cannot validate a CI pipeline, it throws exit code 0. Exit code 0 implies success, this makes it more difficult to use in CI jobs (ironically).
Expected Behavior vs Actual Behavior
One expects a non-zero exit code upon failure, instead glab ci lint
will give a zero exit code every time.
Possible Fix
I have fixed the issue here, merge request incoming.
if lint.Status == "invalid" {
fmt.Fprintln(out, c.Red(path+" is invalid"))
for i, err := range lint.Errors {
i++
fmt.Fprintln(out, i, err)
}
// Returning the error to cobra here causes the process to exit with code 0, so we exit manually.
os.Exit(1)
}
Steps to Reproduce
cd $repo_with_valid_gitlab_ci_yaml
glab ci lint
echo $?
sed -i 's|:|;|g' .gitlab-ci.yml
glab ci lint
echo $?
Your Environment
- Version used (Run
glab --version
):glab version 1.22.0-96-g676b7c7 (2022-09-14)
- Operating System and version:
Linux 5.17.9 x86_64 GNU/Linux