|
1 | | -name: CodeQL |
| 1 | +name: CodeQL (ESP-IDF C/C++) |
| 2 | + |
2 | 3 | on: |
3 | | - push: { branches: [main] } |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
4 | 6 | pull_request: |
5 | | - schedule: [{cron: '0 3 * * 1'}] |
| 7 | + branches: [ "main" ] |
| 8 | + schedule: |
| 9 | + - cron: "0 6 * * 1" # weekly |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + actions: read |
| 14 | + security-events: write |
6 | 15 |
|
7 | 16 | jobs: |
8 | | - analyze: |
| 17 | + analyze-espidf: |
9 | 18 | runs-on: ubuntu-latest |
10 | | - permissions: { security-events: write, contents: read } |
| 19 | + env: |
| 20 | + IDF_VERSION: v5.4.2 |
| 21 | + IDF_PATH: ${{ github.workspace }}/esp-idf # where we clone IDF |
| 22 | + IDF_TARGET: esp32p4 |
| 23 | + IDF_CCACHE_ENABLE: "0" # ensure CodeQL sees real compilations |
11 | 24 | steps: |
12 | | - - uses: actions/checkout@v4 |
13 | | - - uses: github/codeql-action/init@v3 |
14 | | - with: { languages: 'cpp' } |
15 | | - - uses: github/codeql-action/autobuild@v3 |
16 | | - - uses: github/codeql-action/analyze@v3 |
| 25 | + - name: Checkout (no LFS, with submodules) |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + lfs: false |
| 29 | + submodules: recursive |
| 30 | + |
| 31 | + # ---- CodeQL init in MANUAL BUILD mode ---- |
| 32 | + - name: Initialize CodeQL |
| 33 | + uses: github/codeql-action/init@v3 |
| 34 | + with: |
| 35 | + languages: cpp |
| 36 | + build-mode: manual |
| 37 | + |
| 38 | + # ---- Install ESP-IDF toolchain (Linux) ---- |
| 39 | + - name: Install system prerequisites for ESP-IDF |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y --no-install-recommends \ |
| 43 | + git wget flex bison gperf cmake ninja-build ccache libffi-dev \ |
| 44 | + libssl-dev dfu-util python3 python3-pip python3-venv |
| 45 | +
|
| 46 | + - name: Fetch ESP-IDF ${{ env.IDF_VERSION }} |
| 47 | + run: | |
| 48 | + git clone -b "${IDF_VERSION}" --recursive https://github.com/espressif/esp-idf.git "${IDF_PATH}" |
| 49 | +
|
| 50 | + - name: Install ESP-IDF tools (esp32p4) |
| 51 | + working-directory: ${{ env.IDF_PATH }} |
| 52 | + run: | |
| 53 | + ./install.sh esp32p4 |
| 54 | +
|
| 55 | + - name: Export ESP-IDF environment |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + set -e |
| 59 | + source "${IDF_PATH}/export.sh" |
| 60 | + idf.py --version |
| 61 | + python --version |
| 62 | + echo "ESP-IDF exported." |
| 63 | +
|
| 64 | + # ---- Project dependencies (your helper) ---- |
| 65 | + - name: Fetch external repos (project script) |
| 66 | + run: | |
| 67 | + python ./fetch_repos.py |
| 68 | +
|
| 69 | + # ---- Build the ESP-IDF app so CodeQL can observe compilation ---- |
| 70 | + - name: Build (ESP-IDF, esp32p4) |
| 71 | + shell: bash |
| 72 | + working-directory: platforms/tab5 |
| 73 | + run: | |
| 74 | + set -e |
| 75 | + source "${IDF_PATH}/export.sh" |
| 76 | + idf.py fullclean |
| 77 | + idf.py set-target "${IDF_TARGET}" |
| 78 | + # Ensure ccache is disabled via env; print config for logs |
| 79 | + echo "IDF_CCACHE_ENABLE=${IDF_CCACHE_ENABLE}" |
| 80 | + idf.py build |
| 81 | +
|
| 82 | + # ---- Run the analysis after the observed build ---- |
| 83 | + - name: Perform CodeQL Analysis |
| 84 | + uses: github/codeql-action/analyze@v3 |
| 85 | + with: |
| 86 | + category: "/language:cpp" |
0 commit comments