Skip to content

Commit 43ec5ea

Browse files
committed
fix
1 parent 8a9ae64 commit 43ec5ea

File tree

3 files changed

+72
-46
lines changed

3 files changed

+72
-46
lines changed

.github/workflows/cron.yml

+4-46
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ on:
1515
workflow_dispatch:
1616
inputs:
1717
idf_branch:
18-
# This input can be an escaped JSON list of strings e.g. [\"release/v5.1\"] or "all" to build all branches.
18+
# This input can be a comma-separated list of strings (e.g. "release/v5.1,release/v5.3") or "all" to build all branches.
1919
# For IDF versions before v5.1, "all" is not supported. Use a specific branch instead.
2020
description: 'IDF branch to build (check workflow file for instructions on how to use this input)'
2121
required: true
2222
default: 'all'
2323
target:
24-
# This input can be an escaped JSON list of strings e.g. [\"esp32\", \"esp32s2\"] or "all" to build all targets.
24+
# This input can be a comma-separated list of strings (e.g. "esp32,esp32s2") or "all" to build all targets.
2525
# For IDF versions before v5.1, "all" is not supported. Use a specific target list instead.
2626
description: 'Target to build (check workflow file for instructions on how to use this input)'
2727
required: true
@@ -39,53 +39,11 @@ jobs:
3939
matrix: ${{ steps.gen-matrix.outputs.matrix }}
4040
branches: ${{ steps.gen-matrix.outputs.branches }}
4141
steps:
42+
- uses: actions/checkout@v4
4243
- name: Generate matrix
4344
id: gen-matrix
4445
run: |
45-
# Change this based on the IDF branches we want to build
46-
all_branches="[\"release/v5.1\"]"
47-
48-
# Change this based on the COMMON targets for all branches we want to build.
49-
common_targets="[\"esp32\", \"esp32s2\", \"esp32s3\", \"esp32c2\", \"esp32c3\", \"esp32c6\", \"esp32h2\"]"
50-
51-
# For additional targets per branch, add them here
52-
additional_targets="[{\"idf_branch\": \"release/v5.3\", \"target\": \"esp32p4\"}]"
53-
54-
branches="${{ github.event.inputs.idf_branch }}"
55-
targets="${{ github.event.inputs.target }}"
56-
57-
if [ -z "$branches" ] || [ "$branches" == "all" ]; then
58-
branches=$all_branches
59-
fi
60-
61-
if [ -z "$targets" ]; then
62-
targets="all"
63-
fi
64-
65-
echo "Inputs:"
66-
echo "idf_branch: ${{ github.event.inputs.idf_branch }}"
67-
echo "target: ${{ github.event.inputs.target }}"
68-
69-
matrix="{"
70-
matrix+="\"idf_branch\": $branches,"
71-
72-
if [ "$targets" == "all" ]; then
73-
matrix+="\"target\": $common_targets,"
74-
matrix+="\"include\": "
75-
# Add all additional targets that are in the selected branches
76-
matrix+=$(echo $additional_targets | jq --argjson branches "$branches" '[.[] | select(.idf_branch as $branch | $branches | index($branch))]')
77-
else
78-
matrix+="\"target\": $targets"
79-
fi
80-
81-
matrix+="}"
82-
83-
echo "Branches: $branches"
84-
echo "Targets: $targets"
85-
echo "Matrix:"
86-
echo "$matrix" | jq .
87-
echo "matrix=$matrix" >> $GITHUB_OUTPUT
88-
echo "branches=$branches" >> $GITHUB_OUTPUT
46+
bash ./tools/cron-gen-matrix.sh "${{ github.event.inputs.idf_branch }}" "${{ github.event.inputs.target }}"
8947
9048
build-libs:
9149
name: Build with IDF ${{ matrix.idf_branch }} for ${{ matrix.target }}

tools/cron-gen-matrix.sh

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ ! $# -eq 2 ]; then
6+
echo "Bad number of arguments: $#" >&2
7+
echo "Usage: $0 <branches> <targets>" >&2
8+
exit 1
9+
fi
10+
11+
if ! [ -x "$(command -v jq)" ]; then
12+
echo "ERROR: jq is not installed! Please install jq first."
13+
exit 1
14+
fi
15+
16+
if ! [ -x "$(command -v sed)" ]; then
17+
echo "ERROR: sed is not installed! Please install sed first."
18+
exit 1
19+
fi
20+
21+
echo "Inputs:"
22+
echo "idf_branch: $1"
23+
echo "target: $2"
24+
25+
# Change this based on the IDF branches we want to build
26+
all_branches="[\"release/v5.1\"]"
27+
28+
# Change this based on the COMMON targets for all branches we want to build.
29+
common_targets="[\"esp32\", \"esp32s2\", \"esp32s3\", \"esp32c2\", \"esp32c3\", \"esp32c6\", \"esp32h2\"]"
30+
31+
# For additional targets per branch, add them here
32+
additional_targets="[{\"idf_branch\": \"release/v5.3\", \"target\": \"esp32p4\"}]"
33+
34+
if [ -z "$1" ] || [ "$1" == "all" ]; then
35+
branches=$all_branches
36+
else
37+
branches=$(echo "$1" | sed 's/ *, */,/g' | sed 's/^/["/' | sed 's/$/"]/' | sed 's/,/","/g')
38+
fi
39+
40+
if [ -z "$2" ] || [ "$2" == "all" ]; then
41+
targets="all"
42+
else
43+
targets=$(echo "$2" | sed 's/ *, */,/g' | sed 's/^/["/' | sed 's/$/"]/' | sed 's/,/","/g')
44+
fi
45+
46+
matrix="{"
47+
matrix+="\"idf_branch\": $branches,"
48+
49+
if [ "$targets" == "all" ]; then
50+
matrix+="\"target\": $common_targets,"
51+
matrix+="\"include\": "
52+
# Add all additional targets that are in the selected branches
53+
matrix+=$(echo $additional_targets | jq --argjson branches "$branches" '[.[] | select(.idf_branch as $branch | $branches | index($branch))]')
54+
else
55+
matrix+="\"target\": $targets"
56+
fi
57+
58+
matrix+="}"
59+
60+
echo "Matrix:"
61+
echo "$matrix" | jq .
62+
63+
if [ ! -x $GITHUB_OUTPUT ]; then
64+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
65+
echo "branches=$branches" >> $GITHUB_OUTPUT
66+
fi

tools/cron.sh

+2
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ if [ -z "$TARGETS" ]; then
44
TARGETS="all"
55
fi
66

7+
export IDF_CCACHE_ENABLE=1
8+
79
bash ./build.sh -e -t $TARGETS

0 commit comments

Comments
 (0)