Skip to content

Commit fed7651

Browse files
committed
task: coverity
1 parent 06bdaf1 commit fed7651

3 files changed

Lines changed: 140 additions & 0 deletions

File tree

.github/workflows/coverity.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Coverity Scan
2+
3+
on:
4+
schedule:
5+
- cron: "0 1 * * 1"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: coverity-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
COVERITY_PROJECT: IntelPython/dpctl
17+
ONEAPI_ROOT: /opt/intel/oneapi
18+
19+
jobs:
20+
coverity-scan:
21+
if: github.repository == 'IntelPython/dpctl'
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 150
24+
25+
steps:
26+
- name: Checkout repo
27+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28+
with:
29+
# versioneer needs the tags to compute the package version
30+
fetch-depth: 0
31+
32+
- name: Add Intel repository
33+
run: |
34+
wget -qO- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
35+
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
36+
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
37+
| sudo tee /etc/apt/sources.list.d/oneAPI.list
38+
sudo apt update
39+
40+
- name: Install latest Intel OneAPI
41+
run: |
42+
sudo apt install intel-oneapi-compiler-dpcpp-cpp
43+
sudo apt install intel-oneapi-tbb
44+
sudo apt install intel-oneapi-umf
45+
sudo apt install hwloc
46+
47+
- name: Install CMake and Ninja
48+
run: |
49+
sudo apt-get install ninja-build
50+
51+
- name: Setup Python
52+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
53+
with:
54+
python-version: '3.12'
55+
architecture: x64
56+
57+
- name: Install dpctl dependencies
58+
run: |
59+
pip install numpy cython setuptools"<80" scikit-build cmake ninja versioneer[toml]==0.29
60+
61+
- name: Report compiler version
62+
run: |
63+
source "${ONEAPI_ROOT}/setvars.sh"
64+
icpx --version
65+
66+
- name: Download Coverity Build Tool
67+
timeout-minutes: 15
68+
env:
69+
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
70+
run: |
71+
curl --location --no-progress-meter --fail-with-body \
72+
--retry 5 --retry-connrefused --retry-delay 5 \
73+
--data-urlencode "token=${COVERITY_SCAN_TOKEN}" \
74+
--data-urlencode "project=${COVERITY_PROJECT}" \
75+
--output cov-analysis.tar.gz \
76+
https://scan.coverity.com/download/linux64
77+
mkdir -p cov-analysis
78+
tar -xzf cov-analysis.tar.gz --strip 1 -C cov-analysis
79+
echo "${PWD}/cov-analysis/bin" >> "$GITHUB_PATH"
80+
81+
- name: Configure Coverity for the DPC++ compiler
82+
env:
83+
# icx/icpx are not in Coverity's list of known compilers, so the
84+
# clang-based templates below have to be accepted explicitly
85+
COVERITY_UNSUPPORTED: 1
86+
run: |
87+
source "${ONEAPI_ROOT}/setvars.sh"
88+
# Cython-generated sources and the pybind11 extensions go through
89+
# icpx, the sysroot/driver probing bits still use gcc
90+
cov-configure --gcc
91+
cov-configure --template --comptype clangcc --compiler icx
92+
cov-configure --template --comptype clangcxx --compiler icpx
93+
94+
- name: Build under cov-build
95+
timeout-minutes: 90
96+
env:
97+
COVERITY_UNSUPPORTED: 1
98+
run: |
99+
set -o pipefail
100+
source "${ONEAPI_ROOT}/setvars.sh"
101+
rm -rf _skbuild
102+
# --skip-editable: the in-place build_ext already compiled everything
103+
# Coverity needs to see, a pip install would only repeat it
104+
cov-build --dir cov-int \
105+
python scripts/build_locally.py --oneapi --skip-editable --verbose \
106+
2>&1 | tee cov-build.log
107+
if ! grep -qE "Emitted [1-9][0-9]* .*compilation unit" cov-build.log; then
108+
echo "::error::Coverity captured 0 compilation units — the C++ build did not run under cov-build."
109+
exit 1
110+
fi
111+
112+
- name: Upload Coverity build log
113+
if: always()
114+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
115+
with:
116+
name: coverity-build-log
117+
path: |
118+
cov-build.log
119+
cov-int/build-log.txt
120+
retention-days: 7
121+
if-no-files-found: warn
122+
123+
- name: Submit results to Coverity Scan
124+
timeout-minutes: 15
125+
env:
126+
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
127+
COVERITY_SCAN_EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }}
128+
run: |
129+
tar -czf cov-int.tgz cov-int
130+
curl --no-progress-meter --fail-with-body \
131+
--retry 5 --retry-connrefused --retry-delay 5 \
132+
--form token="${COVERITY_SCAN_TOKEN}" \
133+
--form email="${COVERITY_SCAN_EMAIL}" \
134+
--form file=@cov-int.tgz \
135+
--form version="${GITHUB_SHA}" \
136+
--form description="GitHub Actions ${GITHUB_REF_NAME} (run ${GITHUB_RUN_ID})" \
137+
--form project="${COVERITY_PROJECT}" \
138+
https://scan.coverity.com/builds

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424

2525
### Maintenance
2626
* Updated pybind11 version used by `dpctl` and examples [gh-2357](https://github.com/IntelPython/dpctl/pull/2357)
27+
* Added a weekly `Coverity Scan` workflow that builds `dpctl` with the DPC++ compiler under `cov-build` and submits the results to Coverity Scan
2728

2829
## [0.22.1] - Apr. 24, 2026
2930

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Coverage Status](https://coveralls.io/repos/github/IntelPython/dpctl/badge.svg?branch=master)](https://coveralls.io/github/IntelPython/dpctl?branch=master)
55
![Generate Documentation](https://github.com/IntelPython/dpctl/actions/workflows/generate-docs.yml/badge.svg?branch=master)
66
[![Join the chat at https://matrix.to/#/#Data-Parallel-Python_community:gitter.im](https://badges.gitter.im/Join%20Chat.svg)](https://app.gitter.im/#/room/#Data-Parallel-Python_community:gitter.im)
7+
[![Coverity Scan Build Status](https://scan.coverity.com/projects/intelpython-dpctl/badge.svg)](https://scan.coverity.com/projects/intelpython-dpctl)
78
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/IntelPython/dpctl/badge)](https://securityscorecards.dev/viewer/?uri=github.com/IntelPython/dpctl)
89

910
<img align="left" src="https://spec.oneapi.io/oneapi-logo-white-scaled.jpg" alt="oneAPI logo" width="75"/>

0 commit comments

Comments
 (0)