|
| 1 | +name: "CodeQL Advanced" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + schedule: |
| 9 | + - cron: '34 16 * * 3' |
| 10 | + |
| 11 | +jobs: |
| 12 | + analyze: |
| 13 | + name: Analyze (${{ matrix.language }}) |
| 14 | + #runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} |
| 15 | + runs-on: |
| 16 | + group: zephyr-runner-v2-linux-x64-4xlarge |
| 17 | + container: |
| 18 | + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 |
| 19 | + options: '--entrypoint /bin/bash' |
| 20 | + permissions: |
| 21 | + # required for all workflows |
| 22 | + security-events: write |
| 23 | + |
| 24 | + # required to fetch internal or private CodeQL packs |
| 25 | + packages: read |
| 26 | + |
| 27 | + # only required for workflows in private repositories |
| 28 | + actions: read |
| 29 | + contents: read |
| 30 | + |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + include: |
| 35 | + - language: c-cpp |
| 36 | + build-mode: manual |
| 37 | + - language: python |
| 38 | + build-mode: none |
| 39 | + env: |
| 40 | + LLVM_TOOLCHAIN_PATH: /usr/lib/llvm-16 |
| 41 | + steps: |
| 42 | + - name: Apply container owner mismatch workaround |
| 43 | + run: | |
| 44 | + # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not |
| 45 | + # match the container user UID because of the way GitHub |
| 46 | + # Actions runner is implemented. Remove this workaround when |
| 47 | + # GitHub comes up with a fundamental fix for this problem. |
| 48 | + git config --global --add safe.directory ${GITHUB_WORKSPACE} |
| 49 | +
|
| 50 | + - name: Clone cached Zephyr repository |
| 51 | + continue-on-error: true |
| 52 | + run: | |
| 53 | + git clone --shared /repo-cache/zephyrproject/zephyr . |
| 54 | + git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 57 | + with: |
| 58 | + ref: ${{ github.event.pull_request.head.sha }} |
| 59 | + fetch-depth: 0 |
| 60 | + persist-credentials: false |
| 61 | + |
| 62 | + - name: Environment Setup |
| 63 | + run: | |
| 64 | + if [ "${{github.event_name}}" = "pull_request" ]; then |
| 65 | + git config --global user.email "[email protected]" |
| 66 | + git config --global user.name "Zephyr Builder" |
| 67 | + rm -fr ".git/rebase-apply" |
| 68 | + rm -fr ".git/rebase-merge" |
| 69 | + git rebase origin/${BASE_REF} |
| 70 | + git clean -f -d |
| 71 | + git log --pretty=oneline | head -n 10 |
| 72 | + fi |
| 73 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 74 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 75 | +
|
| 76 | + west init -l . || true |
| 77 | + west config manifest.group-filter -- +ci,+optional |
| 78 | + west config --global update.narrow true |
| 79 | + 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) |
| 80 | + west forall -c 'git reset --hard HEAD' |
| 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 | + gcc --version |
| 88 | + cargo --version |
| 89 | + rustup target list --installed |
| 90 | + ls -la |
| 91 | + echo "github.ref: ${{ github.ref }}" |
| 92 | + echo "github.base_ref: ${{ github.base_ref }}" |
| 93 | + echo "github.ref_name: ${{ github.ref_name }}" |
| 94 | +
|
| 95 | +
|
| 96 | + - name: Initialize CodeQL |
| 97 | + uses: github/codeql-action/init@v3 |
| 98 | + with: |
| 99 | + languages: ${{ matrix.language }} |
| 100 | + build-mode: ${{ matrix.build-mode }} |
| 101 | + |
| 102 | + - if: matrix.build-mode == 'manual' |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + export ZEPHYR_BASE=${PWD} |
| 106 | + export ZEPHYR_TOOLCHAIN_VARIANT=zephyr |
| 107 | + west twister -p native_sim --build-only -v || true |
| 108 | +
|
| 109 | + - name: Perform CodeQL Analysis |
| 110 | + uses: github/codeql-action/analyze@v3 |
| 111 | + with: |
| 112 | + category: "/language:${{matrix.language}}" |
0 commit comments