Skip to content

fix

fix #674

Workflow file for this run

name: Compilation Tests
on:
workflow_dispatch:
inputs:
log_level:
description: "Log level"
default: "none"
type: "choice"
required: true
options:
- "none"
- "error"
- "warn"
- "info"
- "debug"
- "verbose"
run_codeql:
description: "Enable CodeQL Analysis"
default: false
type: "boolean"
required: true
schedule:
# Every Sunday at 2:00 UTC run a build with verbose log level
- cron: "0 2 * * SUN"
push:
branches:
- master
- release/*
pull_request:
paths:
- "cores/**"
- "libraries/**/*.cpp"
- "libraries/**/*.c"
- "libraries/**/*.h"
- "libraries/**/*.hpp"
- "libraries/**/*.ino"
- "libraries/**/ci.json"
- "package/**"
- "idf_component_examples/**"
- "tools/get.*"
- "platform.txt"
- "programmers.txt"
- "idf_component.yml"
- "Kconfig.projbuild"
- "package.json"
- "CMakeLists.txt"
- ".github/workflows/push.yml"
- ".github/scripts/check-cmakelists.sh"
- ".github/scripts/install-*"
- ".github/scripts/on-push-idf.sh"
- ".github/scripts/on-push.sh"
- ".github/scripts/set_push_chunks.sh"
- ".github/scripts/sketch_utils.sh"
- "variants/esp32/**"
- "variants/esp32c2/**"
- "variants/esp32c3/**"
- "variants/esp32c6/**"
- "variants/esp32h2/**"
- "variants/esp32p4/**"
- "variants/esp32s2/**"
- "variants/esp32s3/**"
- "!*.md"
- "!*.txt"
- "!*.properties"
concurrency:
group: build-${{github.event.pull_request.number || github.ref}}
cancel-in-progress: true
env:
MAX_CHUNKS: 15
RUN_CODEQL: ${{ github.event_name == 'schedule' || github.event_name == 'pull_request' || inputs.run_codeql }}
jobs:
cmake-check:
name: Check cmake file
runs-on: ubuntu-latest
if: ${{ !github.event_name == 'pull_request' || !startsWith(github.head_ref, 'release/') }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: bash ./.github/scripts/check-cmakelists.sh
gen-chunks:
name: Generate chunks
runs-on: ubuntu-latest
if: ${{ !github.event_name == 'pull_request' || !startsWith(github.head_ref, 'release/') }}
outputs:
build_all: ${{ steps.set-chunks.outputs.build_all }}
build_libraries: ${{ steps.set-chunks.outputs.build_libraries }}
build_static_sketches: ${{ steps.set-chunks.outputs.build_static_sketches }}
build_idf: ${{ steps.set-chunks.outputs.build_idf }}
chunk_count: ${{ steps.set-chunks.outputs.chunk_count }}
chunks: ${{ steps.set-chunks.outputs.chunks }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
with:
files_yaml: |
core:
- '.github/**'
- '!.github/scripts/on-push-idf.sh'
- 'cores/**'
- 'package/**'
- 'tools/**'
- 'platform.txt'
- 'programmers.txt'
- "variants/**"
- "!variants/esp32c2/**"
libraries:
- 'libraries/**/examples/**'
- 'libraries/**/src/**'
networking:
- 'libraries/Network/src/**'
fs:
- 'libraries/FS/src/**'
static_sketeches:
- 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino'
- 'libraries/BLE/examples/Server/Server.ino'
- 'libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino'
- 'libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino'
- 'libraries/NetworkClientSecure/src/**'
- 'libraries/BLE/src/**'
- 'libraries/Insights/src/**'
idf:
- '.github/scripts/on-push-idf.sh'
- 'idf_component.yml'
- 'Kconfig.projbuild'
- 'CMakeLists.txt'
- "idf_component_examples/**"
- "variants/esp32c2/**"
- name: Set chunks
id: set-chunks
env:
LIB_FILES: ${{ steps.changed-files.outputs.libraries_all_changed_files }}
IS_PR: ${{ github.event_name == 'pull_request' }}
MAX_CHUNKS: ${{ env.MAX_CHUNKS }}
BUILD_IDF: ${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
BUILD_LIBRARIES: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
BUILD_STATIC_SKETCHES: ${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
FS_CHANGED: ${{ steps.changed-files.outputs.fs_any_changed == 'true' }}
NETWORKING_CHANGED: ${{ steps.changed-files.outputs.networking_any_changed == 'true' }}
CORE_CHANGED: ${{ steps.changed-files.outputs.core_any_changed == 'true' }}
LIB_CHANGED: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
run: |
bash ./.github/scripts/set_push_chunks.sh
- name: Upload sketches found
if: ${{ steps.set-chunks.outputs.build_all == 'false' && steps.set-chunks.outputs.build_libraries == 'true' }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: sketches_found
path: sketches_found.txt
overwrite: true
if-no-files-found: error
# Ubuntu
build-arduino-linux:
name: Arduino ${{ matrix.chunk }} on ubuntu-latest
if: ${{ needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_libraries == 'true' }}
needs: gen-chunks
runs-on: ubuntu-latest
env:
ARDUINO_CLI_FORCE_CLEAN: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && needs.gen-chunks.outputs.build_all != 'true') || inputs.run_codeql }}
strategy:
fail-fast: false
matrix:
chunk: ${{ fromJson(needs.gen-chunks.outputs.chunks) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.0.4
with:
python-version: "3.x"
- name: Get libs cache
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: libs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package/package_esp32_index.template.json', 'tools/get.py') }}
path: |
./tools/dist
./tools/esp32-arduino-libs
./tools/esptool
./tools/mk*
./tools/openocd-esp32
./tools/riscv32-*
./tools/xtensa-*
- name: Set Log Level
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "LOG_LEVEL=${{ github.event.inputs.log_level }}" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" == "schedule" ]; then
echo "LOG_LEVEL=verbose" >> $GITHUB_ENV
else
echo "LOG_LEVEL=none" >> $GITHUB_ENV
fi
- name: Initialize CodeQL
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
env:
# Build mode manual takes roughly double the time to run.
# For PRs that build all sketches, we use none to speed up the build.
BUILD_MODE: ${{ (needs.gen-chunks.outputs.build_all == 'true' && github.event_name != 'pull_request') && 'manual' || 'none' }}
with:
languages: cpp
build-mode: ${{ env.BUILD_MODE }}
config-file: ./.github/codeql/codeql-config.yml
- name: Build all sketches
if: ${{ needs.gen-chunks.outputs.build_all == 'true' }}
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ env.MAX_CHUNKS }} 1 ${{ env.LOG_LEVEL }}
- name: Download sketches found
if: ${{ needs.gen-chunks.outputs.build_all == 'false' && needs.gen-chunks.outputs.build_libraries == 'true' }}
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: sketches_found
- name: Build selected sketches
if: ${{ needs.gen-chunks.outputs.build_all == 'false' && needs.gen-chunks.outputs.build_libraries == 'true' }}
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ needs.gen-chunks.outputs.chunk_count }} 1 ${{ env.LOG_LEVEL }} sketches_found.txt
- name: Run CodeQL Analysis
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
category: "Arduino Linux Chunk ${{ matrix.chunk }}"
output: sarif-results
upload: failure-only
- name: Filter CodeQL Results
uses: advanced-security/filter-sarif@v1
if: ${{ env.RUN_CODEQL }}
with:
patterns: |
+**/*
-tools/**
input: sarif-results/cpp.sarif
output: sarif-results/cpp.sarif
- name: Upload filtered SARIF
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
sarif_file: sarif-results/cpp.sarif
category: "Arduino Linux Chunk ${{ matrix.chunk }}"
#Upload cli compile json as artifact
- name: Upload cli compile json
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: pr_cli_compile_${{ matrix.chunk }}
path: cli_compile_${{ matrix.chunk }}.json
overwrite: true
# Windows and MacOS
build-arduino-win-mac:
name: Arduino on ${{ matrix.os }}
needs: gen-chunks
if: ${{ needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_static_sketches == 'true' }}
runs-on: ${{ matrix.os }}
env:
ARDUINO_CLI_FORCE_CLEAN: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && needs.gen-chunks.outputs.build_all != 'true') || inputs.run_codeql }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macOS-latest]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.0.4
with:
python-version: "3.x"
- name: Initialize CodeQL
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
languages: cpp
build-mode: manual
config-file: ./.github/codeql/codeql-config.yml
- name: Build Sketches
run: bash ./.github/scripts/on-push.sh
- name: Run CodeQL Analysis
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
category: "Arduino ${{ matrix.os }}"
output: sarif-results
upload: failure-only
- name: Filter CodeQL Results
uses: advanced-security/filter-sarif@v1
if: ${{ env.RUN_CODEQL }}
with:
patterns: |
+**/*
-tools/**
input: sarif-results/cpp.sarif
output: sarif-results/cpp.sarif
- name: Upload filtered SARIF
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
sarif_file: sarif-results/cpp.sarif
category: "Arduino ${{ matrix.os }}"
build-esp-idf-component:
name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
needs: gen-chunks
if: |
needs.gen-chunks.outputs.build_all == 'true' ||
needs.gen-chunks.outputs.build_libraries == 'true' ||
needs.gen-chunks.outputs.build_idf == 'true'
runs-on: ubuntu-latest
env:
ESP_IDF_FORCE_CLEAN: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && needs.gen-chunks.outputs.build_all != 'true') || inputs.run_codeql }}
strategy:
fail-fast: false
matrix:
# The version names here correspond to the versions of espressif/idf Docker image.
# See https://hub.docker.com/r/espressif/idf/tags and
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
# for details.
idf_ver: ["release-v5.4"]
idf_target:
[
"esp32",
"esp32s2",
"esp32s3",
"esp32c2",
"esp32c3",
"esp32c6",
"esp32h2",
"esp32p4"
]
container: espressif/idf:${{ matrix.idf_ver }}
steps:
- name: Check out arduino-esp32 as a component
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
path: components/arduino-esp32
- name: Setup jq
uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1
- name: Initialize CodeQL
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
languages: cpp
build-mode: manual
source-root: components/arduino-esp32
config-file: ./components/arduino-esp32/.github/codeql/codeql-config.yml
- name: Build
env:
IDF_TARGET: ${{ matrix.idf_target }}
shell: bash
run: |
chmod a+x ./components/arduino-esp32/.github/scripts/*
./components/arduino-esp32/.github/scripts/on-push-idf.sh
- name: Run CodeQL Analysis
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
category: "Arduino as IDF Component for ${{ matrix.idf_target }}"
output: sarif-results
upload: failure-only
- name: Filter CodeQL Results
uses: advanced-security/filter-sarif@v1
if: ${{ env.RUN_CODEQL }}
with:
patterns: |
+**/*
-tools/**
-idf_component_examples/**/managed_components/**
-idf_component_examples/**/build/**
input: sarif-results/cpp.sarif
output: sarif-results/cpp.sarif
- name: Upload filtered SARIF
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
if: ${{ env.RUN_CODEQL }}
with:
sarif_file: sarif-results/cpp.sarif
category: "Arduino as IDF Component for ${{ matrix.idf_target }}"
- name: Upload generated sdkconfig files for debugging
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: sdkconfig-${{ matrix.idf_target }}
path: ./components/arduino-esp32/idf_component_examples/**/sdkconfig
# Save artifacts to gh-pages
save-master-artifacts:
name: Save master artifacts
needs: build-arduino-linux
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
# Check out repository
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{secrets.GITHUB_TOKEN}}
fetch-depth: "0"
- name: Switch branch
run: git checkout remotes/origin/gh-pages
- name: Download sketches reports artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
pattern: pr_cli_compile_*
merge-multiple: true
path: master_cli_compile
- name: List files in the directory
run: ls -R
- name: Commit json files to gh-pages if on master
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
continue-on-error: true
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add --all
git commit -m "Updated cli compile json files"
git push origin HEAD:gh-pages
#Upload PR number as artifact
upload-pr-number:
name: Upload PR number
if: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'release/') }}
runs-on: ubuntu-latest
steps:
- name: Save the PR number in an artifact
shell: bash
env:
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt
- name: Upload PR number
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: pr_number
path: ./pr_num.txt
overwrite: true