|
| 1 | +name: Codechecker |
| 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 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + Codechecker: |
| 20 | + if: github.repository_owner == 'zephyrproject-rtos' |
| 21 | + permissions: |
| 22 | + pull-requests: write # to create/update pull request comments |
| 23 | + security-events: write |
| 24 | + runs-on: |
| 25 | + group: zephyr-runner-v2-linux-x64-4xlarge |
| 26 | + container: |
| 27 | + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 |
| 28 | + options: '--entrypoint /bin/bash' |
| 29 | + env: |
| 30 | + CCACHE_DIR: /node-cache/ccache-zephyr |
| 31 | + CCACHE_REMOTE_STORAGE: "redis://cache-*.keydb-cache.svc.cluster.local|shards=1,2,3" |
| 32 | + CCACHE_REMOTE_ONLY: "true" |
| 33 | + CCACHE_IGNOREOPTIONS: '-specs=* --specs=*' |
| 34 | + LLVM_TOOLCHAIN_PATH: /usr/lib/llvm-16 |
| 35 | + BASE_REF: ${{ github.base_ref }} |
| 36 | + steps: |
| 37 | + - name: Apply container owner mismatch workaround |
| 38 | + run: | |
| 39 | + # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not |
| 40 | + # match the container user UID because of the way GitHub |
| 41 | + # Actions runner is implemented. Remove this workaround when |
| 42 | + # GitHub comes up with a fundamental fix for this problem. |
| 43 | + git config --global --add safe.directory ${GITHUB_WORKSPACE} |
| 44 | +
|
| 45 | + - name: Print cloud service information |
| 46 | + run: | |
| 47 | + echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}" |
| 48 | + echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}" |
| 49 | + echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}" |
| 50 | +
|
| 51 | + - name: Clone cached Zephyr repository |
| 52 | + continue-on-error: true |
| 53 | + run: | |
| 54 | + git clone --shared /repo-cache/zephyrproject/zephyr . |
| 55 | + git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} |
| 56 | +
|
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + persist-credentials: false |
| 62 | + |
| 63 | + - name: Environment Setup |
| 64 | + run: | |
| 65 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 66 | + git config --global user.email "bot@zephyrproject.org" |
| 67 | + git config --global user.name "Zephyr Bot" |
| 68 | + rm -fr ".git/rebase-apply" |
| 69 | + rm -fr ".git/rebase-merge" |
| 70 | + git clean -f -d |
| 71 | + git log --pretty=oneline | head -n 10 |
| 72 | + west init -l . || true |
| 73 | + west config --global update.narrow true |
| 74 | + west config manifest.group-filter -- +ci,-optional |
| 75 | + # In some cases modules are left in a state where they can't be |
| 76 | + # updated (i.e. when we cancel a job and the builder is killed), |
| 77 | + # So first retry to update, if that does not work, remove all modules |
| 78 | + # and start over. (Workaround until we implement more robust module |
| 79 | + # west caching). |
| 80 | + west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west2.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject) |
| 81 | +
|
| 82 | + echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV |
| 83 | +
|
| 84 | + - name: Check Environment |
| 85 | + run: | |
| 86 | + cmake --version |
| 87 | + ${LLVM_TOOLCHAIN_PATH}/bin/clang --version |
| 88 | + gcc --version |
| 89 | + ls -la |
| 90 | +
|
| 91 | + - name: Run Tests with Twister |
| 92 | + id: twister |
| 93 | + run: | |
| 94 | + export ZEPHYR_BASE=${PWD} |
| 95 | + export ZEPHYR_TOOLCHAIN_VARIANT=zephyr |
| 96 | + export ZEPHYR_SCA_VARIANT=codechecker |
| 97 | + export CODECHECKER_CONFIG_FILE=$ZEPHYR_BASE/.codechecker.yml |
| 98 | + export CODECHECKER_CLEANUP=y |
| 99 | + export CODECHECKER_EXPORT=sarif |
| 100 | + export CODECHECKER_SKIP_FILE=$ZEPHYR_BASE/.github/codechecker/skipfile |
| 101 | +
|
| 102 | + pip install codechecker==v6.25.1 cppcheck sarif-tools jq |
| 103 | + sudo apt-get update |
| 104 | + sudo apt-get install -y jq |
| 105 | + export PATH=/usr/lib/llvm-16/bin/:$PATH |
| 106 | +
|
| 107 | + ./scripts/twister --jobs 16 -i --force-color -N -v --build-only --timeout-multiplier 2 -p qemu_x86 -T tests/kernel/threads/thread_apis/ |
| 108 | +
|
| 109 | + #sarif copy --output results.sarif $(find twister-out -name "codechecker.sarif") |
| 110 | + jq -s '{ "$schema": "https://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": map(.runs) | add }' $(find twister-out -name "codechecker.sarif") > results.sarif |
| 111 | +
|
| 112 | + - name: Upload SARIF as artifact |
| 113 | + if: always() && github.event_name == 'push' |
| 114 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 115 | + with: |
| 116 | + name: sarif |
| 117 | + if-no-files-found: ignore |
| 118 | + path: | |
| 119 | + build/sca/codechecker/codechecker.sarif |
| 120 | + results.sarif |
| 121 | +
|
| 122 | + - name: Upload Analysis Results |
| 123 | + if: always() |
| 124 | + uses: github/codeql-action/upload-sarif@v3 |
| 125 | + with: |
| 126 | + sarif_file: results.sarif |
0 commit comments