Skip to content

Commit 95645a2

Browse files
committed
task: coverity scanning
1 parent 9165494 commit 95645a2

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

.github/workflows/coverity.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Coverity Scan
2+
3+
# Public static analysis via the free Coverity Scan service (scan.coverity.com,
4+
# operated by Black Duck). Coverity is a compiled-language analyzer: it must wrap
5+
# the real C build with `cov-build`, so this workflow installs the Meson build
6+
# stack, compiles the extension under capture, and uploads the result.
7+
#
8+
# One-time setup (done once per project, outside this workflow):
9+
# 1. Register IntelPython/mkl_fft at https://scan.coverity.com/github
10+
# (the project name must match COVERITY_PROJECT below).
11+
# 2. Add two repository secrets (Settings -> Secrets and variables -> Actions):
12+
# COVERITY_SCAN_TOKEN - the project token from the Project Settings tab
13+
# COVERITY_SCAN_EMAIL - a maintainer email for build notifications
14+
#
15+
# Free-tier quota for a project under 100K LOC is 28 builds/week, max 4/day, so
16+
# this runs on a weekly schedule plus on demand rather than per-push.
17+
18+
on:
19+
schedule:
20+
- cron: "0 1 * * 1" # Mondays 01:00 UTC; well under the free build quota
21+
workflow_dispatch:
22+
23+
permissions:
24+
contents: read
25+
26+
concurrency:
27+
group: coverity-${{ github.ref }}
28+
cancel-in-progress: true
29+
30+
env:
31+
COVERITY_PROJECT: IntelPython/mkl_fft
32+
33+
jobs:
34+
coverity-scan:
35+
# Forks lack the COVERITY_SCAN_* secrets; only run on the canonical repo.
36+
if: github.repository == 'IntelPython/mkl_fft'
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Checkout repo
41+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Setup Python
46+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
47+
with:
48+
python-version: "3.12"
49+
architecture: x64
50+
51+
# Meson locates MKL through its CMake config (see meson.build), so the
52+
# mkl-devel wheel is enough -- no MKLROOT or oneAPI install required.
53+
- name: Install mkl_fft dependencies
54+
run: pip install meson-python ninja cmake cython "numpy>=2" mkl-devel
55+
56+
- name: Download Coverity Build Tool
57+
env:
58+
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
59+
run: |
60+
curl --location --no-progress-meter \
61+
--data-urlencode "token=${COVERITY_SCAN_TOKEN}" \
62+
--data-urlencode "project=${COVERITY_PROJECT}" \
63+
--output cov-analysis.tar.gz \
64+
https://scan.coverity.com/download/linux64
65+
# An invalid token/project returns a small HTML error page, not the
66+
# multi-hundred-MB tarball. Fail loudly with a clear hint if so.
67+
if [ "$(stat -c '%s' cov-analysis.tar.gz)" -lt 1000000 ]; then
68+
echo "::error::Coverity build tool download failed. Verify the COVERITY_SCAN_TOKEN secret and that the registered project name matches '${COVERITY_PROJECT}'."
69+
head -c 512 cov-analysis.tar.gz || true
70+
exit 1
71+
fi
72+
mkdir -p cov-analysis
73+
tar -xzf cov-analysis.tar.gz --strip 1 -C cov-analysis
74+
echo "${PWD}/cov-analysis/bin" >> "$GITHUB_PATH"
75+
76+
- name: Configure Coverity for GCC
77+
run: cov-configure --gcc
78+
79+
- name: Build under cov-build
80+
run: |
81+
# Meson caches its build tree in build/ and skips compiling when it is
82+
# up to date, which would leave Coverity with nothing to capture and
83+
# get the upload rejected. Remove it to force a real rebuild.
84+
rm -rf build
85+
cov-build --dir cov-int pip install -e . --no-build-isolation --no-deps 2>&1 | tee cov-build.log
86+
# The extension has 2 C translation units (the generated mklfft.c and
87+
# the Cython-generated _pydfti.c); bail out if none were captured.
88+
if ! grep -qE "Emitted [1-9][0-9]* .*compilation unit" cov-build.log; then
89+
echo "::error::Coverity captured 0 compilation units — the C build did not run under cov-build."
90+
exit 1
91+
fi
92+
93+
- name: Submit results to Coverity Scan
94+
env:
95+
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
96+
COVERITY_SCAN_EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }}
97+
run: |
98+
tar -czf cov-int.tgz cov-int
99+
curl --no-progress-meter \
100+
--form token="${COVERITY_SCAN_TOKEN}" \
101+
--form email="${COVERITY_SCAN_EMAIL}" \
102+
--form file=@cov-int.tgz \
103+
--form version="${GITHUB_SHA}" \
104+
--form description="GitHub Actions ${GITHUB_REF_NAME} (run ${GITHUB_RUN_ID})" \
105+
--form project="${COVERITY_PROJECT}" \
106+
https://scan.coverity.com/builds

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[![Editable build using pip and pre-release NumPy](https://github.com/IntelPython/mkl_fft/actions/workflows/build_pip.yml/badge.svg)](https://github.com/IntelPython/mkl_fft/actions/workflows/build_pip.yml)
33
[![Conda package with conda-forge channel only](https://github.com/IntelPython/mkl_fft/actions/workflows/conda-package-cf.yml/badge.svg)](https://github.com/IntelPython/mkl_fft/actions/workflows/conda-package-cf.yml)
44
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/IntelPython/mkl_fft/badge)](https://securityscorecards.dev/viewer/?uri=github.com/IntelPython/mkl_fft)
5+
[![Coverity Scan Build Status](https://scan.coverity.com/projects/33202/badge.svg)](https://scan.coverity.com/projects/intelpython-mkl_fft)
56

67
## `mkl_fft` -- a NumPy-based Python interface to Intel® oneAPI Math Kernel Library (oneMKL) Fourier Transform Functions
78

0 commit comments

Comments
 (0)