|  | 
|  | 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 | +permissions: | 
|  | 49 | +  contents: read | 
|  | 50 | + | 
|  | 51 | +concurrency: | 
|  | 52 | +  group: build-component-${{github.event.pull_request.number || github.ref}} | 
|  | 53 | +  cancel-in-progress: true | 
|  | 54 | + | 
|  | 55 | +jobs: | 
|  | 56 | +  cmake-check: | 
|  | 57 | +    name: Check CMakeLists | 
|  | 58 | +    runs-on: ubuntu-latest | 
|  | 59 | +    if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} | 
|  | 60 | +    steps: | 
|  | 61 | +      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | 
|  | 62 | +      - run: bash ./.github/scripts/check-cmakelists.sh | 
|  | 63 | + | 
|  | 64 | +  set-matrix: | 
|  | 65 | +    name: Set Matrix | 
|  | 66 | +    runs-on: ubuntu-latest | 
|  | 67 | +    if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} | 
|  | 68 | +    outputs: | 
|  | 69 | +      idf_ver: ${{ steps.set-matrix.outputs.idf_ver }} | 
|  | 70 | +      idf_target: ${{ steps.set-matrix.outputs.idf_target }} | 
|  | 71 | +    steps: | 
|  | 72 | +      - name: Get IDF Version and Targets | 
|  | 73 | +        id: set-matrix | 
|  | 74 | +        run: | | 
|  | 75 | +          # Default values | 
|  | 76 | +          idf_ver="release-v5.3,release-v5.4,release-v5.5" | 
|  | 77 | +          idf_targets="esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" | 
|  | 78 | +
 | 
|  | 79 | +          # Override with inputs if provided | 
|  | 80 | +          if [[ -n "${{ inputs.idf_ver }}" ]]; then | 
|  | 81 | +            idf_ver="${{ inputs.idf_ver }}" | 
|  | 82 | +          fi | 
|  | 83 | +          if [[ -n "${{ inputs.idf_targets }}" ]]; then | 
|  | 84 | +            idf_targets="${{ inputs.idf_targets }}" | 
|  | 85 | +          fi | 
|  | 86 | +
 | 
|  | 87 | +          # Convert comma-separated strings to JSON arrays using a more robust method | 
|  | 88 | +          idf_ver_json=$(printf '%s\n' "$idf_ver" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) | 
|  | 89 | +          idf_targets_json=$(printf '%s\n' "$idf_targets" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) | 
|  | 90 | +
 | 
|  | 91 | +          # Debug: Print the JSON for verification | 
|  | 92 | +          echo "Debug - idf_ver_json: $idf_ver_json" | 
|  | 93 | +          echo "Debug - idf_targets_json: $idf_targets_json" | 
|  | 94 | +
 | 
|  | 95 | +          # Set outputs - ensure no extra whitespace | 
|  | 96 | +          printf "idf_ver=%s\n" "$idf_ver_json" >> $GITHUB_OUTPUT | 
|  | 97 | +          printf "idf_target=%s\n" "$idf_targets_json" >> $GITHUB_OUTPUT | 
|  | 98 | +
 | 
|  | 99 | +  build-esp-idf-component: | 
|  | 100 | +    name: Build IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }} | 
|  | 101 | +    runs-on: ubuntu-latest | 
|  | 102 | +    needs: set-matrix | 
|  | 103 | +    strategy: | 
|  | 104 | +      fail-fast: false | 
|  | 105 | +      matrix: | 
|  | 106 | +        # The version names here correspond to the versions of espressif/idf Docker image. | 
|  | 107 | +        # See https://hub.docker.com/r/espressif/idf/tags and | 
|  | 108 | +        # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html | 
|  | 109 | +        # for details. | 
|  | 110 | +        idf_ver: ${{ fromJson(needs.set-matrix.outputs.idf_ver) }} | 
|  | 111 | +        idf_target: ${{ fromJson(needs.set-matrix.outputs.idf_target) }} | 
|  | 112 | +    container: espressif/idf:${{ matrix.idf_ver }} | 
|  | 113 | +    steps: | 
|  | 114 | +      - name: Check out arduino-esp32 as a component | 
|  | 115 | +        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | 
|  | 116 | +        with: | 
|  | 117 | +          submodules: recursive | 
|  | 118 | +          path: components/arduino-esp32 | 
|  | 119 | + | 
|  | 120 | +      # Need to install jq in the container to be able to use it in the script | 
|  | 121 | +      - name: Setup jq | 
|  | 122 | +        uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1 | 
|  | 123 | + | 
|  | 124 | +      - name: Build | 
|  | 125 | +        env: | 
|  | 126 | +          IDF_TARGET: ${{ matrix.idf_target }} | 
|  | 127 | +        shell: bash | 
|  | 128 | +        run: | | 
|  | 129 | +          chmod a+x ./components/arduino-esp32/.github/scripts/* | 
|  | 130 | +          ./components/arduino-esp32/.github/scripts/on-push-idf.sh | 
|  | 131 | +
 | 
|  | 132 | +      - name: Upload generated sdkconfig files for debugging | 
|  | 133 | +        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | 
|  | 134 | +        if: always() | 
|  | 135 | +        with: | 
|  | 136 | +          name: sdkconfig-${{ matrix.idf_ver }}-${{ matrix.idf_target }} | 
|  | 137 | +          path: ./components/arduino-esp32/idf_component_examples/**/sdkconfig | 
0 commit comments