Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/scripts/on-push-idf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for example in $idf_component_examples; do
fi
fi

idf.py -C "$example" set-target "$IDF_TARGET"
idf.py --preview -C "$example" set-target "$IDF_TARGET"

has_requirements=$(${CHECK_REQUIREMENTS} "$example" "$example/sdkconfig")
if [ "$has_requirements" -eq 0 ]; then
Expand All @@ -29,5 +29,5 @@ for example in $idf_component_examples; do
fi

printf "\n\033[95mBuilding %s\033[0m\n\n" "$example"
idf.py -C "$example" -DEXTRA_COMPONENT_DIRS="$PWD/components" build
idf.py --preview -C "$example" -DEXTRA_COMPONENT_DIRS="$PWD/components" build
done
95 changes: 67 additions & 28 deletions .github/workflows/build_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
description: "IDF Targets"
default: "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4"
type: "string"
required: true
required: false
push:
branches:
- master
Expand Down Expand Up @@ -66,49 +66,88 @@ jobs:
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 }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Get IDF Version and Targets
- name: Get Matrix Combinations
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"
# Define version-specific target configurations
get_targets_for_version() {
case "$1" in
"release-v5.3")
echo "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4"
;;
"release-v5.4")
echo "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4"
;;
"release-v5.5")
echo "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c5,esp32c6,esp32h2,esp32p4"
;;
*)
echo ""
;;
esac
}

# Default versions if not provided via inputs
DEFAULT_VERSIONS="release-v5.3,release-v5.4,release-v5.5"

# Override with inputs if provided
# Use inputs if provided, otherwise use defaults
if [[ -n "${{ inputs.idf_ver }}" ]]; then
idf_ver="${{ inputs.idf_ver }}"
fi
if [[ -n "${{ inputs.idf_targets }}" ]]; then
idf_targets="${{ inputs.idf_targets }}"
VERSIONS="${{ inputs.idf_ver }}"
else
VERSIONS="$DEFAULT_VERSIONS"
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 .)
# Generate matrix combinations
echo '{"include": [' > matrix.json
first=true
IFS=',' read -ra VERSION_ARRAY <<< "$VERSIONS"

for version in "${VERSION_ARRAY[@]}"; do
# Trim whitespace
version=$(echo "$version" | xargs)

# Get targets for this version
if [[ -n "${{ inputs.idf_targets }}" ]]; then
# Use provided targets for all versions
targets="${{ inputs.idf_targets }}"
else
# Use version-specific targets
targets=$(get_targets_for_version "$version")
fi

if [[ -n "$targets" ]]; then
IFS=',' read -ra TARGET_ARRAY <<< "$targets"
for target in "${TARGET_ARRAY[@]}"; do
# Trim whitespace
target=$(echo "$target" | xargs)

if [ "$first" = true ]; then
first=false
else
echo ',' >> matrix.json
fi
echo "{\"idf_ver\": \"$version\", \"idf_target\": \"$target\"}" >> matrix.json
done
fi
done
echo ']}' >> matrix.json

# Debug: Print the JSON for verification
echo "Debug - idf_ver_json: $idf_ver_json"
echo "Debug - idf_targets_json: $idf_targets_json"
# Debug: Print the matrix for verification
echo "Debug - Generated matrix:"
cat matrix.json | jq .

# 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
# Set output
printf "matrix=%s\n" "$(cat matrix.json | jq -c .)" >> $GITHUB_OUTPUT

build-esp-idf-component:
name: Build IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
runs-on: ubuntu-latest
needs: set-matrix
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) }}
matrix: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
container: espressif/idf:${{ matrix.idf_ver }}
steps:
- name: Check out arduino-esp32 as a component
Expand Down