Test different header and source names #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Arduino as ESP-IDF Component | |
on: | |
workflow_dispatch: | |
inputs: | |
idf_ver: | |
description: "IDF Versions" | |
default: "release-v5.3,release-v5.4,release-v5.5" | |
type: "string" | |
required: true | |
idf_targets: | |
description: "IDF Targets" | |
default: "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" | |
type: "string" | |
required: true | |
push: | |
branches: | |
- master | |
- release/* | |
pull_request: | |
paths: | |
- "cores/**" | |
- "libraries/**/*.cpp" | |
- "libraries/**/*.c" | |
- "libraries/**/*.h" | |
- "idf_component_examples/**" | |
- "idf_component.yml" | |
- "Kconfig.projbuild" | |
- "CMakeLists.txt" | |
- ".github/workflows/build_component.yml" | |
- ".github/scripts/check-cmakelists.sh" | |
- ".github/scripts/on-push-idf.sh" | |
- ".github/scripts/sketch_utils.sh" | |
- ".github/scripts/get_affected.py" | |
- "variants/esp32/**" | |
- "variants/esp32c2/**" | |
- "variants/esp32c3/**" | |
- "variants/esp32c5/**" | |
- "variants/esp32c6/**" | |
- "variants/esp32h2/**" | |
- "variants/esp32p4/**" | |
- "variants/esp32s2/**" | |
- "variants/esp32s3/**" | |
- "!*.md" | |
- "!*.txt" | |
- "!*.properties" | |
permissions: | |
contents: read | |
concurrency: | |
group: build-component-${{github.event.pull_request.number || github.ref}} | |
cancel-in-progress: true | |
jobs: | |
cmake-check: | |
name: Check CMakeLists | |
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 | |
set-matrix: | |
name: Set Matrix | |
runs-on: ubuntu-latest | |
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} | |
outputs: | |
idf_ver: ${{ steps.set-matrix.outputs.idf_ver }} | |
idf_target: ${{ steps.set-matrix.outputs.idf_target }} | |
should_build: ${{ steps.affected-examples.outputs.should_build }} | |
steps: | |
- name: Install universal-ctags | |
uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # v1.5.3 | |
with: | |
packages: libicu74 libjansson4 libxml2 libyaml-0-2 universal-ctags | |
version: 1 | |
execute_install_scripts: true | |
- 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 | |
- name: Get affected examples | |
id: affected-examples | |
env: | |
IS_PR: ${{ github.event_name == 'pull_request' }} | |
run: | | |
which ctags-universal | |
python3 ./.github/scripts/get_affected.py --debug --component ${{ steps.changed-files.outputs.all_changed_files }} > affected_examples.txt | |
- name: Upload affected examples | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: affected_examples | |
path: affected_examples.txt | |
if-no-files-found: error | |
- name: Upload debug artifacts | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: get_affected_debug | |
path: | | |
ctags_defs_by_qname.json | |
ctags_header_to_qnames.json | |
ctags_tags.jsonl | |
dependencies.json | |
dependencies_reverse.json | |
if-no-files-found: warn | |
- name: Get IDF Version and Targets | |
id: set-matrix | |
run: | | |
# Default values | |
idf_ver="release-v5.3,release-v5.4,release-v5.5" | |
idf_targets="esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" | |
# Override with inputs if provided | |
if [[ -n "${{ inputs.idf_ver }}" ]]; then | |
idf_ver="${{ inputs.idf_ver }}" | |
fi | |
if [[ -n "${{ inputs.idf_targets }}" ]]; then | |
idf_targets="${{ inputs.idf_targets }}" | |
fi | |
# Convert comma-separated strings to JSON arrays using a more robust method | |
idf_ver_json=$(printf '%s\n' "$idf_ver" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) | |
idf_targets_json=$(printf '%s\n' "$idf_targets" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) | |
# Debug: Print the JSON for verification | |
echo "Debug - idf_ver_json: $idf_ver_json" | |
echo "Debug - idf_targets_json: $idf_targets_json" | |
# Set outputs - ensure no extra whitespace | |
printf "idf_ver=%s\n" "$idf_ver_json" >> $GITHUB_OUTPUT | |
printf "idf_target=%s\n" "$idf_targets_json" >> $GITHUB_OUTPUT | |
build-esp-idf-component: | |
name: Build IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }} | |
runs-on: ubuntu-latest | |
needs: set-matrix | |
if: ${{ needs.set-matrix.outputs.should_build == '1' }} | |
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: ${{ fromJson(needs.set-matrix.outputs.idf_ver) }} | |
idf_target: ${{ fromJson(needs.set-matrix.outputs.idf_target) }} | |
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 | |
# Need to install jq in the container to be able to use it in the script | |
- name: Setup jq | |
uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1 | |
- name: Download affected examples | |
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 | |
with: | |
name: affected_examples | |
- 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 affected_examples.txt | |
- name: Upload generated sdkconfig files for debugging | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
if: always() | |
with: | |
name: sdkconfig-${{ matrix.idf_ver }}-${{ matrix.idf_target }} | |
path: ./components/arduino-esp32/idf_component_examples/**/sdkconfig |