|
| 1 | +name: Eclair 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 | + EclairScanCode: |
| 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 | + permissions: |
| 26 | + pull-requests: write # to create/update pull request comments |
| 27 | + security-events: write |
| 28 | + steps: |
| 29 | + - name: Print cloud service information |
| 30 | + run: | |
| 31 | + echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}" |
| 32 | + echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}" |
| 33 | + echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}" |
| 34 | +
|
| 35 | + - name: Apply container owner mismatch workaround |
| 36 | + run: | |
| 37 | + # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not |
| 38 | + # match the container user UID because of the way GitHub |
| 39 | + # Actions runner is implemented. Remove this workaround when |
| 40 | + # GitHub comes up with a fundamental fix for this problem. |
| 41 | + git config --global --add safe.directory ${GITHUB_WORKSPACE} |
| 42 | +
|
| 43 | + - name: Clone cached Zephyr repository |
| 44 | + continue-on-error: true |
| 45 | + run: | |
| 46 | + git clone --shared /repo-cache/zephyrproject/zephyr . |
| 47 | + git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} |
| 48 | +
|
| 49 | + - name: Checkout |
| 50 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 51 | + with: |
| 52 | + ref: ${{ github.event.pull_request.head.sha }} |
| 53 | + fetch-depth: 0 |
| 54 | + persist-credentials: false |
| 55 | + |
| 56 | + - name: Environment Setup |
| 57 | + run: | |
| 58 | + if [ "${{github.event_name}}" = "pull_request" ]; then |
| 59 | + git config --global user.email "[email protected]" |
| 60 | + git config --global user.name "Zephyr Builder" |
| 61 | + rm -fr ".git/rebase-apply" |
| 62 | + rm -fr ".git/rebase-merge" |
| 63 | + git rebase origin/${BASE_REF} |
| 64 | + git clean -f -d |
| 65 | + git log --pretty=oneline | head -n 10 |
| 66 | + fi |
| 67 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 68 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 69 | +
|
| 70 | + west init -l . || true |
| 71 | + west config manifest.group-filter -- +ci,+optional |
| 72 | + west config --global update.narrow true |
| 73 | + 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) |
| 74 | + west forall -c 'git reset --hard HEAD' |
| 75 | +
|
| 76 | + echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV |
| 77 | +
|
| 78 | + - name: Check Environment |
| 79 | + run: | |
| 80 | + cmake --version |
| 81 | + gcc --version |
| 82 | + cargo --version |
| 83 | + rustup target list --installed |
| 84 | + ls -la |
| 85 | + echo "github.ref: ${{ github.ref }}" |
| 86 | + echo "github.base_ref: ${{ github.base_ref }}" |
| 87 | + echo "github.ref_name: ${{ github.ref_name }}" |
| 88 | +
|
| 89 | + - name: SCA Setup |
| 90 | + uses: zephyrproject-rtos/action-sca-setup@main |
| 91 | + with: |
| 92 | + tool-name: eclair |
| 93 | + install-dir: eclair |
| 94 | + s3-access-key-id: ${{ secrets.TOOLDIST_ACCESS_KEY }} |
| 95 | + s3-secret-access-key: ${{ secrets.TOOLDIST_SECRET_ACCESS_KEY }} |
| 96 | + license-server: ${{ secrets.TOOLDIST_ECLAIR_LICENSE_SERVER }} |
| 97 | + |
| 98 | + - name: Set Up Python 3.12 |
| 99 | + uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 |
| 100 | + with: |
| 101 | + python-version: 3.12 |
| 102 | + cache: pip |
| 103 | + cache-dependency-path: scripts/requirements-actions.txt |
| 104 | + |
| 105 | + - name: install-packages |
| 106 | + run: | |
| 107 | + pip install -r scripts/requirements-actions.txt --require-hashes |
| 108 | + sudo apt-get update |
| 109 | + sudo apt-get install -y jq |
| 110 | +
|
| 111 | + - name: Scan code with Eclair |
| 112 | + run: | |
| 113 | + ./scripts/twister -j 16 -p qemu_x86 -T samples/synchronization -i --build-only -v -xZEPHYR_SCA_VARIANT=eclair -x=USE_CCACHE=0 -xECLAIR_REPORTS_SARIF=1 |
| 114 | + jq -s '{ "$schema": "https://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": map(.runs) | add }' $(find twister-out -name "reports.sarif") > results.sarif |
| 115 | +
|
| 116 | + ver=`git describe` |
| 117 | + echo "PAYLOAD_VERSION=${ver}" >> $GITHUB_ENV |
| 118 | + echo "PAYLOAD_DESC=${ver}" >> $GITHUB_ENV |
| 119 | +
|
| 120 | + - name: Upload SARIF as artifact |
| 121 | + if: always() && github.event_name == 'push' |
| 122 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 123 | + with: |
| 124 | + name: sarif |
| 125 | + if-no-files-found: ignore |
| 126 | + path: | |
| 127 | + results.sarif |
| 128 | +
|
| 129 | + - name: Upload Analysis Results |
| 130 | + if: always() |
| 131 | + uses: github/codeql-action/upload-sarif@v3 |
| 132 | + with: |
| 133 | + sarif_file: results.sarif |
0 commit comments