Skip to content

Commit 80d9e99

Browse files
task: capture SYCL sources in the Coverity scan
2 parents 3c889e6 + ca106bd commit 80d9e99

1 file changed

Lines changed: 42 additions & 15 deletions

File tree

‎.github/workflows/coverity.yml‎

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
with:
2929
# versioneer needs the tags to compute the package version
3030
fetch-depth: 0
31+
persist-credentials: false
3132

3233
- name: Add Intel repository
3334
run: |
@@ -79,33 +80,57 @@ jobs:
7980
echo "${PWD}/cov-analysis/bin" >> "$GITHUB_PATH"
8081
8182
- 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
8683
run: |
8784
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
9085
cov-configure --gcc
91-
cov-configure --template --comptype clangcc --compiler icx
92-
cov-configure --template --comptype clangcxx --compiler icpx
86+
# Generic clang templates can't parse SYCL headers, see https://github.com/IntelPython/dpctl/pull/2401
87+
comptypes="$(cov-configure --list-compiler-types | cut -d, -f1)"
88+
comptype=""
89+
for candidate in intel_oneapi_icx intel_oneapi_icx:linux intel_icx:linux; do
90+
if grep -qxF "${candidate}" <<< "${comptypes}"; then
91+
comptype="${candidate}"
92+
break
93+
fi
94+
done
95+
if [ -z "${comptype}" ]; then
96+
echo "::error::No Intel oneAPI compiler type in this cov-analysis; refusing to fall back to the generic Clang configuration."
97+
exit 1
98+
fi
99+
echo "Using Coverity compiler type: ${comptype}"
100+
cov-configure --template --comptype "${comptype}" --compiler icx
101+
cov-configure --template --comptype "${comptype}" --compiler icpx
93102
94103
- name: Build under cov-build
95104
timeout-minutes: 90
96-
env:
97-
COVERITY_UNSUPPORTED: 1
98105
run: |
99106
set -o pipefail
100107
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
108+
# --skip-editable: build_ext --inplace already compiled everything
104109
cov-build --dir cov-int \
105110
python scripts/build_locally.py --oneapi --skip-editable --verbose \
106111
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."
112+
{
113+
echo "### Coverity capture"
114+
echo '```'
115+
grep -E "Emitted .*compilation unit|are ready for analysis" cov-build.log || true
116+
echo '```'
117+
} >> "$GITHUB_STEP_SUMMARY"
118+
# Gate on per-source emits, not the P% total, see https://github.com/IntelPython/dpctl/pull/2401
119+
log=cov-int/build-log.txt
120+
compiled="$(grep -oP '\[STATUS\] Compiling \K\S+' "${log}" | grep -F "${GITHUB_WORKSPACE}/" | grep -vF /CMakeFiles/ | sort -u || true)"
121+
# Unanchored: parallel compiles can splice output onto the same log line
122+
emitted="$(grep -oP "Emit for file '\K[^']+(?=' \(TU [0-9]+\) complete\.)" "${log}" | sort -u || true)"
123+
missing="$(comm -23 <(echo "${compiled}") <(echo "${emitted}"))"
124+
total="$(grep -c . <<< "${compiled}" || true)"
125+
nmissing="$(grep -c . <<< "${missing}" || true)"
126+
echo "Coverity emitted $(( total - nmissing )) of ${total} project sources" | tee -a "$GITHUB_STEP_SUMMARY"
127+
if [ "${total}" -eq 0 ]; then
128+
echo "::error::No project sources were compiled under cov-build."
129+
exit 1
130+
fi
131+
if [ "${nmissing}" -gt 0 ]; then
132+
echo "${missing}"
133+
echo "::error::Coverity did not emit ${nmissing} of ${total} project sources (listed above)."
109134
exit 1
110135
fi
111136
@@ -121,6 +146,8 @@ jobs:
121146
if-no-files-found: warn
122147

123148
- name: Submit results to Coverity Scan
149+
# A branch submit would replace master's results on the Scan dashboard
150+
if: github.ref == 'refs/heads/master'
124151
timeout-minutes: 15
125152
env:
126153
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}

0 commit comments

Comments
 (0)