|
| 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/mkl_umath |
| 17 | + ONEAPI_ROOT: /opt/intel/oneapi |
| 18 | + |
| 19 | +jobs: |
| 20 | + coverity-scan: |
| 21 | + if: github.repository == 'IntelPython/mkl_umath' |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 90 |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repo |
| 27 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 28 | + |
| 29 | + - name: Setup Python |
| 30 | + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 |
| 31 | + with: |
| 32 | + python-version: "3.12" |
| 33 | + architecture: x64 |
| 34 | + |
| 35 | + - name: Add Intel repository |
| 36 | + run: | |
| 37 | + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB |
| 38 | + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB |
| 39 | + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB |
| 40 | + sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" |
| 41 | + sudo apt-get update |
| 42 | +
|
| 43 | + - name: Install Intel oneAPI |
| 44 | + timeout-minutes: 25 |
| 45 | + run: | |
| 46 | + sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp |
| 47 | + sudo apt-get install -y intel-oneapi-mkl-devel |
| 48 | +
|
| 49 | + - name: Install mkl_umath dependencies |
| 50 | + run: pip install meson-python ninja cmake cython "numpy>=2" |
| 51 | + |
| 52 | + - name: Download Coverity Build Tool |
| 53 | + timeout-minutes: 15 |
| 54 | + env: |
| 55 | + COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 56 | + run: | |
| 57 | + curl --location --no-progress-meter --fail-with-body \ |
| 58 | + --retry 5 --retry-connrefused --retry-delay 5 \ |
| 59 | + --data-urlencode "token=${COVERITY_SCAN_TOKEN}" \ |
| 60 | + --data-urlencode "project=${COVERITY_PROJECT}" \ |
| 61 | + --output cov-analysis.tar.gz \ |
| 62 | + https://scan.coverity.com/download/linux64 |
| 63 | + mkdir -p cov-analysis |
| 64 | + tar -xzf cov-analysis.tar.gz --strip 1 -C cov-analysis |
| 65 | + echo "${PWD}/cov-analysis/bin" >> "$GITHUB_PATH" |
| 66 | +
|
| 67 | + - name: Build under cov-build |
| 68 | + timeout-minutes: 20 |
| 69 | + run: | |
| 70 | + # shellcheck disable=SC1091 |
| 71 | + source "${ONEAPI_ROOT}/setvars.sh" |
| 72 | + # Build with icx to match the shipped conda packages (both |
| 73 | + # conda-recipe and conda-recipe-cf use CC=icx). meson.build only |
| 74 | + # applies -fveclib=SVML, -fvectorize, -fimf-precision=high and |
| 75 | + # -fprotect-parens when the compiler id is Intel, so gcc would not |
| 76 | + # exercise that branch. |
| 77 | + export CC="${CMPLR_ROOT}/bin/icx" |
| 78 | + # icx is clang-based but, unlike gcc, is not auto-configured by the |
| 79 | + # Coverity front-end, so register it explicitly first. |
| 80 | + cov-configure --template --comptype clangcc --compiler "${CC}" |
| 81 | + # meson-python caches its build tree in build/; remove it so the |
| 82 | + # compiler really runs and Coverity has something to capture. |
| 83 | + rm -rf build |
| 84 | + cov-build --dir cov-int pip install . --no-build-isolation --no-deps 2>&1 | tee cov-build.log |
| 85 | + # The project has 4 C translation units (generated mkl_umath_loops.c, |
| 86 | + # ufuncsmodule.c, generated __umath_generated.c and Cython |
| 87 | + # _patch_numpy.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 | + timeout-minutes: 15 |
| 95 | + env: |
| 96 | + COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 97 | + COVERITY_SCAN_EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }} |
| 98 | + run: | |
| 99 | + tar -czf cov-int.tgz cov-int |
| 100 | + curl --no-progress-meter --fail-with-body \ |
| 101 | + --retry 5 --retry-connrefused --retry-delay 5 \ |
| 102 | + --form token="${COVERITY_SCAN_TOKEN}" \ |
| 103 | + --form email="${COVERITY_SCAN_EMAIL}" \ |
| 104 | + --form file=@cov-int.tgz \ |
| 105 | + --form version="${GITHUB_SHA}" \ |
| 106 | + --form description="GitHub Actions ${GITHUB_REF_NAME} (run ${GITHUB_RUN_ID})" \ |
| 107 | + --form project="${COVERITY_PROJECT}" \ |
| 108 | + https://scan.coverity.com/builds |
0 commit comments