Skip to content

Enable Coverity scan for C++#2533

Open
napetrov wants to merge 1 commit intouxlfoundation:mainfrom
napetrov:ycwecc-codex/enable-coverity-scan-for-c++-code
Open

Enable Coverity scan for C++#2533
napetrov wants to merge 1 commit intouxlfoundation:mainfrom
napetrov:ycwecc-codex/enable-coverity-scan-for-c++-code

Conversation

@napetrov
Copy link
Copy Markdown
Contributor

Description

Updates coverity job to instrument scikit build
test scan - https://scan.coverity.com/projects/napetrov-daal4py?tab=overview

PR should start as a draft, then move to ready for review state after CI is passed and all applicable checkboxes are closed.
This approach ensures that reviewers don't spend extra time asking for regular requirements.

You can remove a checkbox as not applicable only if it doesn't relate to this PR in any way.
For example, PR with docs update doesn't require checkboxes for performance while PR with any change in actual code should have checkboxes and justify how this code change is expected to affect performance (or justification should be self-evident).

Checklist to comply with before moving PR from draft:

PR completeness and readability

  • I have reviewed my changes thoroughly before submitting this pull request.

Testing

  • I have run it locally and tested the changes extensively.

@napetrov napetrov added the enhancement New feature or request label Jun 11, 2025
Comment thread .ci/pipeline/nightly.yml
Comment thread .ci/pipeline/nightly.yml Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
azure 79.87% <ø> (ø)
github ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@icfaust
Copy link
Copy Markdown
Contributor

icfaust commented Jun 11, 2025

/azp run Nightly

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@napetrov
Copy link
Copy Markdown
Contributor Author

Coverity job will not be passing secret to forks. so i do have test project - https://scan.coverity.com/projects/napetrov-daal4py?tab=overview

Previously cov-build only ran --no-command --fs-capture-search which
captures Python/header files but misses C++ compilation artifacts.

This change adds a full C++ build step to the Coverity scan:
1. Set up conda environment with dal-devel (matches Jupyter nightly job)
2. Run cov-build with the actual build command (python setup.py build_ext)

This ensures C++ extension code is instrumented by Coverity and
analyzed at https://scan.coverity.com/projects/napetrov-daal4py
@napetrov napetrov force-pushed the ycwecc-codex/enable-coverity-scan-for-c++-code branch from bfee4f1 to 5c39770 Compare March 7, 2026 02:20
@napetrov napetrov marked this pull request as ready for review March 7, 2026 04:29
Copilot AI review requested due to automatic review settings March 7, 2026 04:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the nightly Coverity CI job to properly instrument the C++ build by setting up a Conda environment, installing dependencies, and running the cov-build command with the setup.py build_ext --inplace invocation, enabling Coverity to capture the C++ compilation for static analysis.

Changes:

  • Adds a Conda environment setup (with dal-devel and impi-devel) before the Coverity scan
  • Sets DALROOT from the conda prefix
  • Adds a cov-build-instrumented python setup.py build_ext --inplace step so Coverity can intercept C++ compilation

Comment thread .ci/pipeline/nightly.yml
. /usr/share/miniconda/etc/profile.d/conda.sh
conda activate CB
pip install -r dependencies-dev
export DALROOT=$CONDA_PREFIX
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup.py build_ext command will fail at startup because MPIROOT and I_MPI_ROOT are not set, and NO_DIST is not exported before invoking the Coverity build. When impi-devel is installed via conda, neither MPIROOT nor I_MPI_ROOT is automatically exported into the environment. setup.py checks for these at module load time (lines 101–106) and raises a ValueError if distributed mode is not disabled. You need to either export NO_DIST=1 before the cov-build invocation, or set MPIROOT=$CONDA_PREFIX (as done in conda-recipe/build.sh line 35).

Suggested change
export DALROOT=$CONDA_PREFIX
export DALROOT=$CONDA_PREFIX
export MPIROOT=$CONDA_PREFIX

Copilot uses AI. Check for mistakes.
Comment thread .ci/pipeline/nightly.yml
pip install -r dependencies-dev
export DALROOT=$CONDA_PREFIX
$(COVERITY_TOOL_HOME)/bin/cov-build --dir cov-int --no-command --fs-capture-search .
$(COVERITY_TOOL_HOME)/bin/cov-build --dir cov-int -- python setup.py build_ext --inplace
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup.py build_ext --inplace will not trigger the custom onedal_run() CMake build steps because build_ext is not registered in the cmdclass dict (only build and develop are, see setup.py line 618). Without the CMake step, the required oneDAL C++ libraries (e.g., _onedal_py_host*.so) will be missing, causing the Cython compilation to fail. The Jupyter job in the same file uses ./conda-recipe/build.sh (which calls python setup.py install) to correctly trigger the full build chain. Consider using python setup.py install or ./conda-recipe/build.sh instead, or alternatively register a custom build_ext command that also runs the CMake steps.

Suggested change
$(COVERITY_TOOL_HOME)/bin/cov-build --dir cov-int -- python setup.py build_ext --inplace
$(COVERITY_TOOL_HOME)/bin/cov-build --dir cov-int -- python setup.py install

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants