Skip to content

Commit 3349520

Browse files
dschogitster
authored andcommitted
coverity: detect and report when the token or project is incorrect
When trying to obtain the MD5 of the Coverity Scan Tool (in order to decide whether a cached version can be used or a new version has to be downloaded), it is possible to get a 401 (Authorization required) due to either an incorrect token, or even more likely due to an incorrect Coverity project name. Seeing an authorization failure that is caused by an incorrect project name was somewhat surprising to me when developing the Coverity workflow, as I found such a failure suggestive of an incorrect token instead. So let's provide a helpful error message about that specifically when encountering authentication issues. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c13d2ad commit 3349520

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.github/workflows/coverity.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,18 @@ jobs:
8080
--fail \
8181
--form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
8282
--form project="$COVERITY_PROJECT" \
83-
--form md5=1) &&
83+
--form md5=1)
84+
case $? in
85+
0) ;; # okay
86+
22) # 40x, i.e. access denied
87+
echo "::error::incorrect token or project?" >&2
88+
exit 1
89+
;;
90+
*) # other error
91+
echo "::error::Failed to retrieve MD5" >&2
92+
exit 1
93+
;;
94+
esac
8495
echo "hash=$MD5" >>$GITHUB_OUTPUT
8596
8697
# Try to cache the tool to avoid downloading 1GB+ on every run.

0 commit comments

Comments
 (0)