Merge branch 'RfidResearchGroup:master' into spi_flash_v2
[RRG-proxmark3.git] / covsubmit.sh
blob579caf61d835b70e72a99239576d7da884e5c10d
1 #!/usr/bin/env bash
3 set -e
4 . .coverity.conf || exit 1
6 pre_submit_hook
8 echo "Checking upload permissions..."
10 if ! up_perm="$(wget https://scan.coverity.com/api/upload_permitted --post-data "token=${COVTOKEN}&project=${COVPROJECT}" -q -O -)"; then
11 echo "Coverity Scan API access denied: bad token?"
12 exit 1
15 # Really up_perm is a JSON response with either
16 # {upload_permitted:true} or {next_upload_permitted_at:<date>}
17 # We do some hacky string parsing instead of properly parsing it.
18 case "$up_perm" in
19 *upload_permitted*true*)
20 echo "Coverity Scan: upload permitted"
22 *next_upload_permitted_at*)
23 if [ -z "$COVERITY_DRYRUN" ]; then
24 echo "Coverity Scan: upload quota reached; stopping here"
25 # Exit success as this isn't a build error.
26 exit 0
27 else
28 echo "Coverity Scan: upload quota reached, continuing dry run"
32 echo "Coverity Scan upload check: unexpected result $up_perm"
33 exit 1
35 esac
39 ## delete all previous tarballs
40 rm -f proxmark3.all.*.tgz proxmark3.all.*.log
42 TODAY="$(date --date now +%Y%m%d.%H%M)"
43 VERSION="0.1.$TODAY"
44 DESCNAME="manual_by_$NICKNAME.$TODAY.$(git describe --dirty --always)"
45 FILENAME="proxmark3.all.$TODAY.tgz"
46 LOGFILENAME="${FILENAME/.tgz/.log}"
48 ## create tarball
49 tar cfz "$FILENAME" "$COVDIR" || exit $?
50 echo "Coverity build file is ready"
52 ## upload tarball to Coverity.com
53 curl --progress-bar --fail \
54 --form token="$COVTOKEN" \
55 --form email="$COVLOGIN" \
56 --form file="@$FILENAME" \
57 --form version="$VERSION" \
58 --form description="$DESCNAME" \
59 https://scan.coverity.com/builds?project="${COVPROJECT}" | tee -a "${LOGFILENAME}" ; test "${PIPESTATUS[0]}" -eq 0 || exit $?
60 echo "tarball uploaded to Coverity for analyse"
62 post_submit_hook