|
| 1 | +name: Coverity Code Scanning |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - v*-branch |
| 10 | + - collab-* |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + CoverityScanCode: |
| 19 | + if: github.repository_owner == 'zephyrproject-rtos' |
| 20 | + runs-on: |
| 21 | + group: zephyr-runner-v2-linux-x64-4xlarge |
| 22 | + container: |
| 23 | + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.28.0.20250523 |
| 24 | + options: '--entrypoint /bin/bash' |
| 25 | + steps: |
| 26 | + - name: Print cloud service information |
| 27 | + run: | |
| 28 | + echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}" |
| 29 | + echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}" |
| 30 | + echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}" |
| 31 | +
|
| 32 | + - name: Apply container owner mismatch workaround |
| 33 | + run: | |
| 34 | + # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not |
| 35 | + # match the container user UID because of the way GitHub |
| 36 | + # Actions runner is implemented. Remove this workaround when |
| 37 | + # GitHub comes up with a fundamental fix for this problem. |
| 38 | + git config --global --add safe.directory ${GITHUB_WORKSPACE} |
| 39 | +
|
| 40 | + - name: Clone cached Zephyr repository |
| 41 | + continue-on-error: true |
| 42 | + run: | |
| 43 | + git clone --shared /repo-cache/zephyrproject/zephyr . |
| 44 | + git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} |
| 45 | +
|
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 48 | + with: |
| 49 | + ref: ${{ github.event.pull_request.head.sha }} |
| 50 | + fetch-depth: 0 |
| 51 | + persist-credentials: false |
| 52 | + |
| 53 | + - name: Environment Setup |
| 54 | + run: | |
| 55 | + if [ "${{github.event_name}}" = "pull_request" ]; then |
| 56 | + git config --global user.email "bot@zephyrproject.org" |
| 57 | + git config --global user.name "Zephyr Builder" |
| 58 | + rm -fr ".git/rebase-apply" |
| 59 | + rm -fr ".git/rebase-merge" |
| 60 | + git rebase origin/${BASE_REF} |
| 61 | + git clean -f -d |
| 62 | + git log --pretty=oneline | head -n 10 |
| 63 | + fi |
| 64 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 65 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 66 | +
|
| 67 | + west init -l . || true |
| 68 | + west config manifest.group-filter -- +ci,+optional |
| 69 | + west config --global update.narrow true |
| 70 | + west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject) |
| 71 | + west forall -c 'git reset --hard HEAD' |
| 72 | +
|
| 73 | + echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV |
| 74 | +
|
| 75 | + - name: Check Environment |
| 76 | + run: | |
| 77 | + cmake --version |
| 78 | + gcc --version |
| 79 | + cargo --version |
| 80 | + rustup target list --installed |
| 81 | + ls -la |
| 82 | + echo "github.ref: ${{ github.ref }}" |
| 83 | + echo "github.base_ref: ${{ github.base_ref }}" |
| 84 | + echo "github.ref_name: ${{ github.ref_name }}" |
| 85 | +
|
| 86 | + - name: SCA Setup |
| 87 | + uses: zephyrproject-rtos/action-sca-setup@main |
| 88 | + with: |
| 89 | + tool-name: coverity |
| 90 | + install-dir: coverity |
| 91 | + s3-access-key-id: ${{ secrets.TOOLDIST_ACCESS_KEY }} |
| 92 | + s3-secret-access-key: ${{ secrets.TOOLDIST_SECRET_ACCESS_KEY }} |
| 93 | + |
| 94 | + - name: Set Up Python 3.12 |
| 95 | + uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 |
| 96 | + with: |
| 97 | + python-version: 3.12 |
| 98 | + cache: pip |
| 99 | + cache-dependency-path: scripts/requirements-actions.txt |
| 100 | + |
| 101 | + - name: install-packages |
| 102 | + run: | |
| 103 | + pip install -r scripts/requirements-actions.txt --require-hashes |
| 104 | +
|
| 105 | + - name: Check Env |
| 106 | + run: | |
| 107 | + export COVERITY_OUTPUT_DIR=${PWD}/cov-int |
| 108 | + ./scripts/twister -j 16 -p qemu_x86 -T tests/kernel/threads --build-only -v -xZEPHYR_SCA_VARIANT=coverity |
| 109 | +
|
| 110 | + tar -cJvf coverity-results.tar.xz cov-int |
| 111 | +
|
| 112 | + ver=`git describe` |
| 113 | + echo "PAYLOAD_VERSION=${ver}" >> $GITHUB_ENV |
| 114 | + echo "PAYLOAD_DESC=${ver}" >> $GITHUB_ENV |
| 115 | +
|
| 116 | + - name: Analyze |
| 117 | + uses: zephyrproject-rtos/action-sca-setup/analyze@main |
| 118 | + with: |
| 119 | + tool-name: coverity |
| 120 | + payload: coverity-results.tar.xz |
| 121 | + service: https://scan.coverity.com/builds?project=Zephyr+Testing |
| 122 | + user: ${{ secrets.COVERITY_USER }} |
| 123 | + token: ${{ secrets.COVERITY_TOKEN }} |
| 124 | + version: ${{ env.PAYLOAD_VERSION }} |
| 125 | + description: ${{ env.PAYLOAD_DESC }} |
0 commit comments