1
- name : ESP32 Arduino CI
1
+ name : Compilation Tests
2
2
3
3
on :
4
4
workflow_dispatch :
5
5
push :
6
6
branches :
7
7
- master
8
8
- release/*
9
+ pull_request :
9
10
paths :
10
11
- ' cores/**'
11
12
- ' libraries/**'
13
+ - ' !libraries/**.md'
14
+ - ' !libraries/**.txt'
15
+ - ' !libraries/**.properties'
16
+ - ' !libraries/**.py'
12
17
- ' package/**'
13
18
- ' tools/**.py'
14
19
- ' platform.txt'
15
20
- ' programmers.txt'
21
+ - ' idf_component.yml'
22
+ - ' Kconfig.projbuild'
23
+ - ' package.json'
16
24
- ' .github/workflows/push.yml'
17
25
- ' .github/scripts/**'
18
26
- ' !.github/scripts/find_*'
19
27
- ' !.github/scripts/on-release.sh'
20
28
- ' !.github/scripts/tests_*'
21
29
- ' !.github/scripts/upload_*'
22
- pull_request :
23
30
24
31
concurrency :
25
32
group : build-${{github.event.pull_request.number || github.ref}}
26
33
cancel-in-progress : true
27
34
28
- jobs :
35
+ env :
36
+ MAX_CHUNKS : 15
29
37
38
+ jobs :
30
39
cmake-check :
31
40
name : Check cmake file
32
41
runs-on : ubuntu-latest
33
42
steps :
34
43
- uses : actions/checkout@v4
35
44
- run : bash ./.github/scripts/check-cmakelists.sh
36
45
46
+ gen-chunks :
47
+ name : Generate chunks
48
+ runs-on : ubuntu-latest
49
+ outputs :
50
+ build_all : ${{ steps.set-chunks.outputs.build_all }}
51
+ build_static_sketches : ${{ steps.set-chunks.outputs.build_static_sketches }}
52
+ build_idf : ${{ steps.set-chunks.outputs.build_idf }}
53
+ build_platformio : ${{ steps.set-chunks.outputs.build_platformio }}
54
+ chunk_count : ${{ steps.set-chunks.outputs.chunk_count }}
55
+ chunks : ${{ steps.set-chunks.outputs.chunks }}
56
+ steps :
57
+ - name : Checkout repository
58
+ uses : actions/checkout@v4
59
+ with :
60
+ fetch-depth : 2
61
+
62
+ - name : Get changed files
63
+ id : changed-files
64
+ uses : tj-actions/changed-files@v44
65
+ with :
66
+ files_yaml : |
67
+ core:
68
+ - '.github/**'
69
+ - '!.github/scripts/install-platformio-esp32.sh'
70
+ - 'cores/**'
71
+ - 'package/**'
72
+ - 'tools/**'
73
+ - '!tools/platformio-build.py'
74
+ - 'platform.txt'
75
+ - 'programmers.txt'
76
+ libraries:
77
+ - 'libraries/**/examples/**'
78
+ - 'libraries/**/src/**'
79
+ static_sketeches:
80
+ - 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino'
81
+ - 'libraries/BLE/examples/Server/Server.ino'
82
+ - 'libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino'
83
+ - 'libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino'
84
+ - 'libraries/NetworkClientSecure/src/**'
85
+ - 'libraries/BLE/src/**'
86
+ - 'libraries/Insights/src/**'
87
+ idf:
88
+ - 'idf_component.yml'
89
+ - 'Kconfig.projbuild'
90
+ platformio:
91
+ - 'package.json'
92
+ - '.github/scripts/install-platformio-esp32.sh'
93
+ - 'tools/platformio-build.py'
94
+
95
+ - name : Set chunks
96
+ id : set-chunks
97
+ env :
98
+ LIB_FILES : ${{ steps.changed-files.outputs.libraries_all_changed_files }}
99
+ run : |
100
+ build_all=false
101
+ chunks_count=0
102
+ is_pr=${{ github.event_name == 'pull_request' }}
103
+
104
+ build_platformio=${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
105
+ build_idf=${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
106
+ build_static_sketches=${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
107
+
108
+ core_changed=${{ steps.changed-files.outputs.core_any_changed == 'true' }}
109
+ lib_changed=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
110
+
111
+ if [[ $core_changed == 'true' ]] || [[ $is_pr != 'true' ]]; then
112
+ echo "Core files changed or not a PR. Building all."
113
+ build_all=true
114
+ chunks_count=${{ env.MAX_CHUNKS }}
115
+ elif [[ $lib_changed == 'true' ]]; then
116
+ echo "Libraries changed. Building only affected sketches."
117
+ sketches=""
118
+ for file in $LIB_FILES; do
119
+ if [[ $file == *.ino ]]; then
120
+ # If file ends with .ino, add it to the list of sketches
121
+ echo "Sketch found: $file"
122
+ sketches+="$file "
123
+ elif [[ $(basename $(dirname $file)) == "src" ]]; then
124
+ # If file is in a src directory, find all sketches in the parent/examples directory
125
+ echo "Library src file found: $file"
126
+ lib=$(dirname $(dirname $file))
127
+ lib_sketches=$(find $lib/examples -name *.ino)
128
+ sketches+="$lib_sketches "
129
+ echo "Library sketches: $lib_sketches"
130
+ else
131
+ # If file is in a example folder but it is not a sketch, find all sketches in the current directory
132
+ echo "File in example folder found: $file"
133
+ sketch=$(find $(dirname $file) -name *.ino)
134
+ sketches+="$sketch "
135
+ echo "Sketch in example folder: $sketch"
136
+ fi
137
+ echo ""
138
+ done
139
+ else
140
+ echo "Unhandled change triggered the build. This should not happen."
141
+ exit 1
142
+ fi
143
+
144
+ if [[ -n $sketches ]]; then
145
+ # Remove duplicates
146
+ sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
147
+ for sketch in $sketches; do
148
+ echo $sketch >> sketches_found.txt
149
+ chunks_count=$((chunks_count+1))
150
+ done
151
+ echo "Number of sketches found: $chunks_count"
152
+ echo "Sketches: $sketches"
153
+
154
+ if [[ $chunks_count -gt ${{ env.MAX_CHUNKS }} ]]; then
155
+ echo "More sketches than the allowed number of chunks found. Limiting to ${{ env.MAX_CHUNKS }} chunks."
156
+ chunks_count=${{ env.MAX_CHUNKS }}
157
+ fi
158
+ fi
159
+
160
+ chunks='["0"'
161
+ for i in $(seq 1 $(( $chunks_count - 1 )) ); do
162
+ chunks+=",\"$i\""
163
+ done
164
+ chunks+="]"
165
+
166
+ echo "build_all=$build_all" >> $GITHUB_OUTPUT
167
+ echo "build_static_sketches=$build_static_sketches" >> $GITHUB_OUTPUT
168
+ echo "build_idf=$build_idf" >> $GITHUB_OUTPUT
169
+ echo "build_platformio=$build_platformio" >> $GITHUB_OUTPUT
170
+ echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
171
+ echo "chunks=$chunks" >> $GITHUB_OUTPUT
172
+
173
+ - name : Upload sketches found
174
+ if : ${{ steps.set-chunks.outputs.build_all == 'false' }}
175
+ uses : actions/upload-artifact@v4
176
+ with :
177
+ name : sketches_found
178
+ path : sketches_found.txt
179
+ overwrite : true
180
+ if-no-files-found : error
181
+
37
182
# Ubuntu
38
183
build-arduino-linux :
39
184
name : Arduino ${{ matrix.chunk }} on ubuntu-latest
185
+ needs : gen-chunks
40
186
runs-on : ubuntu-latest
41
187
strategy :
42
188
fail-fast : false
43
189
matrix :
44
- chunk : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
190
+ chunk : ${{ fromJson(needs.gen-chunks.outputs.chunks) }}
45
191
46
192
steps :
47
193
- uses : actions/checkout@v4
@@ -62,8 +208,19 @@ jobs:
62
208
./tools/riscv32-*
63
209
./tools/xtensa-*
64
210
65
- - name : Build Sketches
66
- run : bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15 1
211
+ - name : Build all sketches
212
+ if : ${{ needs.gen-chunks.outputs.build_all == 'true' }}
213
+ run : bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ env.MAX_CHUNKS }} 1
214
+
215
+ - name : Download sketches found
216
+ if : ${{ needs.gen-chunks.outputs.build_all == 'false' }}
217
+ uses : actions/download-artifact@v4
218
+ with :
219
+ name : sketches_found
220
+
221
+ - name : Build selected sketches
222
+ if : ${{ needs.gen-chunks.outputs.build_all == 'false' }}
223
+ run : bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ needs.gen-chunks.outputs.chunk_count }} 1 sketches_found.txt
67
224
68
225
# Upload cli compile json as artifact
69
226
- name : Upload cli compile json
76
233
# Windows and MacOS
77
234
build-arduino-win-mac :
78
235
name : Arduino on ${{ matrix.os }}
236
+ needs : gen-chunks
237
+ if : ${{ needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_static_sketches == 'true' }}
79
238
runs-on : ${{ matrix.os }}
80
239
strategy :
81
240
fail-fast : false
@@ -93,6 +252,11 @@ jobs:
93
252
# PlatformIO on Windows, Ubuntu and Mac
94
253
build-platformio :
95
254
name : PlatformIO on ${{ matrix.os }}
255
+ needs : gen-chunks
256
+ if : |
257
+ needs.gen-chunks.outputs.build_all == 'true' ||
258
+ needs.gen-chunks.outputs.build_static_sketches == 'true' ||
259
+ needs.gen-chunks.outputs.build_platformio == 'true'
96
260
runs-on : ${{ matrix.os }}
97
261
strategy :
98
262
fail-fast : false
@@ -109,6 +273,8 @@ jobs:
109
273
110
274
build-esp-idf-component :
111
275
name : Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
276
+ needs : gen-chunks
277
+ if : ${{ needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_idf == 'true' }}
112
278
runs-on : ubuntu-20.04
113
279
strategy :
114
280
fail-fast : false
0 commit comments