| 1 |
name: Coverity |
| 2 |
|
| 3 |
# Coverity Scan gives relatively low-quality reports and has strict |
| 4 |
# rate limits, so we only run it on the main branch on a schedule. |
| 5 |
on: |
| 6 |
schedule: |
| 7 |
- cron: '31 3 * * 1' # Monday at 3h31 UTC |
| 8 |
workflow_dispatch: |
| 9 |
|
| 10 |
jobs: |
| 11 |
Coverity: |
| 12 |
runs-on: ubuntu-24.04 |
| 13 |
|
| 14 |
env: |
| 15 |
ac_cv_func_arc4random_buf: "no" |
| 16 |
CVT_PROJECT: besser82/libxcrypt |
| 17 |
|
| 18 |
# Coverity doesn't have official Github Actions integration yet. |
| 19 |
# The steps below were kitbashed together from the contents of |
| 20 |
# https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh |
| 21 |
# plus some notions from |
| 22 |
# https://github.com/ruby/actions-coverity-scan/blob/master/.github/workflows/coverity-scan.yml |
| 23 |
steps: |
| 24 |
- name: Check for authorization |
| 25 |
env: |
| 26 |
CVT_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 27 |
run: | |
| 28 |
if [ -z "$CVT_TOKEN" ]; then |
| 29 |
printf '\033[33;1mCoverity Scan token not available.\033[0m\n' |
| 30 |
exit 1 |
| 31 |
fi |
| 32 |
AUTH_RES=$(curl -s --form project="$CVT_PROJECT" \ |
| 33 |
--form token="$CVT_TOKEN" \ |
| 34 |
https://scan.coverity.com/api/upload_permitted) |
| 35 |
if [ "$AUTH_RES" = "Access denied" ]; then |
| 36 |
printf '\033[33;1mCoverity Scan API access denied.\033[0m\n' |
| 37 |
printf 'Check project name and access token.\n' |
| 38 |
exit 1 |
| 39 |
else |
| 40 |
AUTH=$(printf '%s' "$AUTH_RES" | ruby -e " |
| 41 |
require 'rubygems' |
| 42 |
require 'json' |
| 43 |
puts JSON[STDIN.read]['upload_permitted'] |
| 44 |
") |
| 45 |
if [ "$AUTH" = "true" ]; then |
| 46 |
echo ok |
| 47 |
exit 0 |
| 48 |
else |
| 49 |
WHEN=$(printf '%s' "$AUTH_RES" | ruby -e " |
| 50 |
require 'rubygems' |
| 51 |
require 'json' |
| 52 |
puts JSON[STDIN.read]['next_upload_permitted_at'] |
| 53 |
") |
| 54 |
printf '\033[33;1mCoverity Scan access blocked until %s.\033[0m\n' \ |
| 55 |
"$WHEN" |
| 56 |
exit 1 |
| 57 |
fi |
| 58 |
fi |
| 59 |
|
| 60 |
- name: Checkout repository |
| 61 |
uses: actions/checkout@v4 |
| 62 |
|
| 63 |
- name: Install packages |
| 64 |
run: sudo apt-get install libltdl-dev |
| 65 |
|
| 66 |
- name: Download Coverity Build Tool |
| 67 |
env: |
| 68 |
CVT_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 69 |
run: | |
| 70 |
echo Downloading Coverity tools... |
| 71 |
# Put the tools in the parent directory so the build can't |
| 72 |
# clobber them by accident. |
| 73 |
cd .. |
| 74 |
curl --no-progress-meter -o cov-analysis-linux64.tar.gz \ |
| 75 |
--form token="$CVT_TOKEN" \ |
| 76 |
--form project="$CVT_PROJECT" \ |
| 77 |
https://scan.coverity.com/download/cxx/linux64 |
| 78 |
echo Extracting... |
| 79 |
mkdir cov-analysis-linux64 |
| 80 |
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64 |
| 81 |
echo done. |
| 82 |
if [ -f cov-analysis-linux64/VERSION ]; then |
| 83 |
echo ::group::Coverity tool versions |
| 84 |
echo + cat cov-analysis-linux64/VERSION |
| 85 |
echo |
| 86 |
cat cov-analysis-linux64/VERSION |
| 87 |
echo ::endgroup:: |
| 88 |
fi |
| 89 |
|
| 90 |
- name: Versions of build tools |
| 91 |
id: build-tools |
| 92 |
run: ./build-aux/ci/ci-log-dependency-versions |
| 93 |
|
| 94 |
- name: Get nprocs |
| 95 |
run: echo "NPROCS=$((`nproc --all 2>/dev/null || sysctl -n hw.ncpu` * 2))" | tee $GITHUB_ENV |
| 96 |
|
| 97 |
- name: Cache bootstrap |
| 98 |
id: cache |
| 99 |
uses: actions/cache@v4 |
| 100 |
with: |
| 101 |
path: | |
| 102 |
INSTALL |
| 103 |
Makefile.in |
| 104 |
aclocal.m4 |
| 105 |
config.h.in |
| 106 |
configure |
| 107 |
autom4te.cache/** |
| 108 |
build-aux/m4/libtool.m4 |
| 109 |
build-aux/m4/ltoptions.m4 |
| 110 |
build-aux/m4/ltsugar.m4 |
| 111 |
build-aux/m4/ltversion.m4 |
| 112 |
build-aux/m4/lt~obsolete.m4 |
| 113 |
build-aux/m4-autogen/** |
| 114 |
key: autoreconf-${{ steps.build-tools.outputs.autotools-ver }}-${{ hashFiles('autogen.sh', 'configure.ac', 'Makefile.am', 'build-aux/m4/*.m4', 'build-aux/m4-autogen/**') }} |
| 115 |
|
| 116 |
- name: Bootstrap |
| 117 |
if: steps.cache.outputs.cache-hit != 'true' |
| 118 |
run: ./autogen.sh |
| 119 |
|
| 120 |
- name: Configure |
| 121 |
run: ./configure --disable-werror --enable-obsolete-api --enable-hashes=all |
| 122 |
|
| 123 |
- name: Prepare build script |
| 124 |
run: | |
| 125 |
echo '#! /bin/sh' > cov_make.sh |
| 126 |
echo "make -j${{ env.NPROCS }} all" >> cov_make.sh |
| 127 |
echo "make -j${{ env.NPROCS }} test-programs" >> cov_make.sh |
| 128 |
chmod +x cov_make.sh |
| 129 |
|
| 130 |
- name: Build |
| 131 |
run: | |
| 132 |
export PATH=$(cd .. && pwd)/cov-analysis-linux64/bin:$PATH |
| 133 |
cov-build --dir cov-int ./cov_make.sh |
| 134 |
cov-import-scm --dir cov-int --scm git --log cov-int/scm_log.txt |
| 135 |
|
| 136 |
- name: Upload analysis results |
| 137 |
env: |
| 138 |
CVT_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 139 |
CVT_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }} |
| 140 |
run: | |
| 141 |
tar czvf cov-int.tar.gz cov-int |
| 142 |
printf 'Uploading Coverity Scan Analysis results...\n' |
| 143 |
response=$(curl -s --write-out '\n%{http_code}\n' \ |
| 144 |
--form project="$CVT_PROJECT" \ |
| 145 |
--form token="$CVT_TOKEN" \ |
| 146 |
--form email="$CVT_EMAIL" \ |
| 147 |
--form [email protected] \ |
| 148 |
--form version="${GITHUB_REF}" \ |
| 149 |
--form description="${GITHUB_SHA}" \ |
| 150 |
https://scan.coverity.com/builds) |
| 151 |
status_code=$(echo "$response" | sed -n '$p') |
| 152 |
if [ "$status_code" = "200" ] || [ "$status_code" = "201" ] ; then |
| 153 |
printf 'Upload complete.\n' |
| 154 |
exit 0 |
| 155 |
else |
| 156 |
TEXT=$(echo "$response" | sed '$d') |
| 157 |
printf '\033[33;1mCoverity Scan upload failed:\033[0m\n%s.\n' "$TEXT" |
| 158 |
exit 1 |
| 159 |
fi |
| 160 |
|
| 161 |
- name: Detailed error logs |
| 162 |
if: failure() |
| 163 |
run: ./build-aux/ci/ci-log-logfiles |