|
| 1 | +name: Arduino as ESP-IDF Component |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + idf_ver: |
| 7 | + description: "IDF Versions" |
| 8 | + default: "release-v5.3,release-v5.4,release-v5.5" |
| 9 | + type: "string" |
| 10 | + required: true |
| 11 | + idf_targets: |
| 12 | + description: "IDF Targets" |
| 13 | + default: "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" |
| 14 | + type: "string" |
| 15 | + required: true |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - master |
| 19 | + - release/* |
| 20 | + pull_request: |
| 21 | + paths: |
| 22 | + - "cores/**" |
| 23 | + - "libraries/**/*.cpp" |
| 24 | + - "libraries/**/*.c" |
| 25 | + - "libraries/**/*.h" |
| 26 | + - "libraries/**/*.ino" |
| 27 | + - "libraries/**/ci.json" |
| 28 | + - "idf_component_examples/**" |
| 29 | + - "idf_component.yml" |
| 30 | + - "Kconfig.projbuild" |
| 31 | + - "CMakeLists.txt" |
| 32 | + - ".github/workflows/build_component.yml" |
| 33 | + - ".github/scripts/check-cmakelists.sh" |
| 34 | + - ".github/scripts/on-push-idf.sh" |
| 35 | + - ".github/scripts/sketch_utils.sh" |
| 36 | + - "variants/esp32/**" |
| 37 | + - "variants/esp32c2/**" |
| 38 | + - "variants/esp32c3/**" |
| 39 | + - "variants/esp32c6/**" |
| 40 | + - "variants/esp32h2/**" |
| 41 | + - "variants/esp32p4/**" |
| 42 | + - "variants/esp32s2/**" |
| 43 | + - "variants/esp32s3/**" |
| 44 | + - "!*.md" |
| 45 | + - "!*.txt" |
| 46 | + - "!*.properties" |
| 47 | + |
| 48 | +concurrency: |
| 49 | + group: build-component-${{github.event.pull_request.number || github.ref}} |
| 50 | + cancel-in-progress: true |
| 51 | + |
| 52 | +jobs: |
| 53 | + cmake-check: |
| 54 | + name: Check CMakeLists |
| 55 | + runs-on: ubuntu-latest |
| 56 | + if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 59 | + - run: bash ./.github/scripts/check-cmakelists.sh |
| 60 | + |
| 61 | + set-matrix: |
| 62 | + name: Set Matrix |
| 63 | + runs-on: ubuntu-latest |
| 64 | + if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} |
| 65 | + outputs: |
| 66 | + idf_ver: ${{ steps.set-matrix.outputs.idf_ver }} |
| 67 | + idf_target: ${{ steps.set-matrix.outputs.idf_target }} |
| 68 | + steps: |
| 69 | + - name: Get IDF Version and Targets |
| 70 | + id: set-matrix |
| 71 | + run: | |
| 72 | + # Default values |
| 73 | + idf_ver="release-v5.3,release-v5.4,release-v5.5" |
| 74 | + idf_targets="esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" |
| 75 | +
|
| 76 | + # Override with inputs if provided |
| 77 | + if [[ -n "${{ inputs.idf_ver }}" ]]; then |
| 78 | + idf_ver="${{ inputs.idf_ver }}" |
| 79 | + fi |
| 80 | + if [[ -n "${{ inputs.idf_targets }}" ]]; then |
| 81 | + idf_targets="${{ inputs.idf_targets }}" |
| 82 | + fi |
| 83 | +
|
| 84 | + # Convert comma-separated strings to JSON arrays using a more robust method |
| 85 | + idf_ver_json=$(printf '%s\n' "$idf_ver" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) |
| 86 | + idf_targets_json=$(printf '%s\n' "$idf_targets" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) |
| 87 | +
|
| 88 | + # Debug: Print the JSON for verification |
| 89 | + echo "Debug - idf_ver_json: $idf_ver_json" |
| 90 | + echo "Debug - idf_targets_json: $idf_targets_json" |
| 91 | +
|
| 92 | + # Set outputs - ensure no extra whitespace |
| 93 | + printf "idf_ver=%s\n" "$idf_ver_json" >> $GITHUB_OUTPUT |
| 94 | + printf "idf_target=%s\n" "$idf_targets_json" >> $GITHUB_OUTPUT |
| 95 | +
|
| 96 | + build-esp-idf-component: |
| 97 | + name: Build IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }} |
| 98 | + runs-on: ubuntu-latest |
| 99 | + needs: set-matrix |
| 100 | + strategy: |
| 101 | + fail-fast: false |
| 102 | + matrix: |
| 103 | + # The version names here correspond to the versions of espressif/idf Docker image. |
| 104 | + # See https://hub.docker.com/r/espressif/idf/tags and |
| 105 | + # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html |
| 106 | + # for details. |
| 107 | + idf_ver: ${{ fromJson(needs.set-matrix.outputs.idf_ver) }} |
| 108 | + idf_target: ${{ fromJson(needs.set-matrix.outputs.idf_target) }} |
| 109 | + container: espressif/idf:${{ matrix.idf_ver }} |
| 110 | + steps: |
| 111 | + - name: Check out arduino-esp32 as a component |
| 112 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 113 | + with: |
| 114 | + submodules: recursive |
| 115 | + path: components/arduino-esp32 |
| 116 | + |
| 117 | + - name: Setup jq |
| 118 | + uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1 |
| 119 | + |
| 120 | + - name: Build |
| 121 | + env: |
| 122 | + IDF_TARGET: ${{ matrix.idf_target }} |
| 123 | + shell: bash |
| 124 | + run: | |
| 125 | + chmod a+x ./components/arduino-esp32/.github/scripts/* |
| 126 | + ./components/arduino-esp32/.github/scripts/on-push-idf.sh |
| 127 | +
|
| 128 | + - name: Upload generated sdkconfig files for debugging |
| 129 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 130 | + if: always() |
| 131 | + with: |
| 132 | + name: sdkconfig-${{ matrix.idf_ver }}-${{ matrix.idf_target }} |
| 133 | + path: ./components/arduino-esp32/idf_component_examples/**/sdkconfig |
0 commit comments