profclems / glab

The GitLab CLI tool. Archived: now officially adopted by GitLab as the official CLI tool and maintained at https://gitlab.com/gitlab-org/cli. See https://github.com/profclems/glab/issues/983
https://glab.readthedocs.io/
MIT License
2.08k stars 163 forks source link

`glab ci lint` provides `0` exit code #985

Open bryant-finney opened 2 years ago

bryant-finney commented 2 years ago

Description

When using glab client to lint my CI configuration, I expect the command's exit code to reflect the linting results. However, the command returns a 0 exit code, even on linting failure.

Expected Behavior vs Actual Behavior and Steps to Reproduce

$ echo "gibberish" >junk.yml && glab ci lint junk.yml
Getting contents in junk.yml
Validating...
junk.yml is invalid
1 Invalid configuration format

$ echo $?        # expected result != 0
0

Related issue: #911

Possible Fix

curl and httpie both provide flags to return a non-zero exit code based on the HTTP status: --fail and --check-status, respectively. Because this would maintain backwards compatibility, implementing a similar optional argument might make the most sense.

Environment

$ glab --version
glab version 1.21.1 (2021-09-29)

$ cat /etc/os-release 
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.15.2
PRETTY_NAME="Alpine Linux v3.15"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

# same behavior on host
$ glab --version
glab version 1.22.0 (2022-01-10)

$ sw_vers && uname -rmv
ProductName:    macOS
ProductVersion: 12.3
BuildVersion:   21E230
21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:35:58 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T6000 arm64
clemsbot commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. We haven't had the time to address it yet, but we want to keep it open. This message is just a reminder for us to help triage issues.

johnmarcou commented 2 years ago

Same issue here. Workaround:

glab ci lint | grep Valid! && echo continue-with-other-commands