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'
19
24
- ' !.github/scripts/on-release.sh'
20
25
- ' !.github/scripts/tests_*'
21
26
- ' !.github/scripts/upload_*'
22
- pull_request :
23
27
24
28
concurrency :
25
29
group : build-${{github.event.pull_request.number || github.ref}}
26
30
cancel-in-progress : true
27
31
28
- jobs :
32
+ env :
33
+ MAX_CHUNKS : 15
29
34
35
+ jobs :
30
36
cmake-check :
31
37
name : Check cmake file
32
38
runs-on : ubuntu-latest
33
39
steps :
34
40
- uses : actions/checkout@v4
35
41
- run : bash ./.github/scripts/check-cmakelists.sh
36
42
43
+ gen-chunks :
44
+ name : Generate chunks
45
+ runs-on : ubuntu-latest
46
+ outputs :
47
+ build_all : ${{ steps.set-chunks.outputs.build_all }}
48
+ chunk_count : ${{ steps.set-chunks.outputs.chunk_count }}
49
+ chunks : ${{ steps.set-chunks.outputs.chunks }}
50
+ steps :
51
+ - name : Checkout repository
52
+ uses : actions/checkout@v4
53
+ with :
54
+ fetch-depth : 2
55
+
56
+ - name : Get changed files
57
+ id : changed-files
58
+ uses : tj-actions/changed-files@v44
59
+ with :
60
+ files_yaml : |
61
+ core:
62
+ - '.github/**'
63
+ - 'cores/**'
64
+ - 'package/**'
65
+ - 'tools/**'
66
+ - 'platform.txt'
67
+ - 'programmers.txt'
68
+ libraries:
69
+ - 'libraries/**/src/**'
70
+ - '!libraries/**/src/dummy.h'
71
+ examples:
72
+ - 'libraries/**/examples/**'
73
+
74
+ - name : Set chunks
75
+ id : set-chunks
76
+ env :
77
+ LIB_FILES : ${{ steps.changed-files.outputs.libraries_all_changed_files }}
78
+ EXAMPLES_FILES : ${{ steps.changed-files.outputs.examples_all_changed_files }}
79
+ run : |
80
+ build_all=false
81
+ is_pr=${{ github.event_name == 'pull_request' }}
82
+ core_changed=${{ steps.changed-files.outputs.core_any_changed == 'true' }}
83
+ lib_changed=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
84
+ examples_changed=${{ steps.changed-files.outputs.examples_any_changed == 'true' }}
85
+ chunks_count=0
86
+
87
+ if [[ $core_changed == 'true' ]] || [[ $is_pr != 'true' ]]; then
88
+ build_all=true
89
+ chunks_count=${{ env.MAX_CHUNKS }}
90
+ elif [[ $lib_changed == 'true' ]] || [[ $examples_changed == 'true' ]]; then
91
+ local sketches=""
92
+ local files="$LIB_FILES $EXAMPLES_FILES"
93
+ for file in $files; do
94
+ if [[ $file == "*.ino" ]]; then
95
+ # If file ends with .ino, add it to the list of sketches
96
+ sketches+="$file "
97
+ continue
98
+ elif [[ $(dirname $file) == "**/src" ]]; then
99
+ # If file is in a src directory, find all sketches in the parent/examples directory
100
+ local lib=$(dirname $(dirname $file))
101
+ sketches+=$(find $lib/examples -name *.ino)
102
+ else
103
+ # If file is in a example folder but it is not a sketch, find all sketches in the current directory
104
+ sketches+=$(find $(dirname $file) -name *.ino)
105
+ fi
106
+ done
107
+
108
+ # Remove duplicates
109
+ sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
110
+
111
+ for sketch in $sketches; do
112
+ echo $sketch >> sketches_found.txt
113
+ chunks_count=$((chunks_count+1))
114
+ done
115
+ else
116
+ echo "Unhandled change triggered the build. This should not happen."
117
+ exit 1
118
+ fi
119
+
120
+ if [[ $chunks_count -gt ${{ env.MAX_CHUNKS }} ]]; then
121
+ chunks_count=${{ env.MAX_CHUNKS }}
122
+ fi
123
+
124
+ chunks='["0"'
125
+ for i in $(seq 1 $chunks_count); do
126
+ chunks+=",\"$i\""
127
+ done
128
+ chunks+="]"
129
+
130
+ echo "build_all=$build_all" >> $GITHUB_OUTPUT
131
+ echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
132
+ echo "chunks=$chunks" >> $GITHUB_OUTPUT
133
+
134
+ - name : Upload sketches found
135
+ if : ${{ steps.set-chunks.outputs.build_all == 'false' }}
136
+ uses : actions/upload-artifact@v4
137
+ with :
138
+ name : sketches_found
139
+ path : sketches_found.txt
140
+ overwrite : true
141
+
37
142
# Ubuntu
38
143
build-arduino-linux :
39
144
name : Arduino ${{ matrix.chunk }} on ubuntu-latest
145
+ needs : gen-chunks
40
146
runs-on : ubuntu-latest
41
147
strategy :
42
148
fail-fast : false
43
149
matrix :
44
- chunk : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
150
+ chunk : ${{ fromJson(needs.gen-chunks.outputs.chunks) }}
45
151
46
152
steps :
47
153
- uses : actions/checkout@v4
@@ -62,8 +168,20 @@ jobs:
62
168
./tools/riscv32-*
63
169
./tools/xtensa-*
64
170
65
- - name : Build Sketches
66
- run : bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15 1
171
+ - name : Build all sketches
172
+ if : ${{ needs.gen-chunks.outputs.build_all == 'true' }}
173
+ run : bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ env.MAX_CHUNKS }} 1
174
+
175
+ - name : Download sketches found
176
+ if : ${{ needs.gen-chunks.outputs.build_all == 'false' }}
177
+ uses : actions/download-artifact@v4
178
+ with :
179
+ name : sketches_found
180
+ path : sketches_found.txt
181
+
182
+ - name : Build selected sketches
183
+ if : ${{ needs.gen-chunks.outputs.build_all == 'false' }}
184
+ run : bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ needs.gen-chunks.outputs.chunk_count }} 1 sketches_found.txt
67
185
68
186
# Upload cli compile json as artifact
69
187
- name : Upload cli compile json
0 commit comments