-
-
Notifications
You must be signed in to change notification settings - Fork 14
408 lines (358 loc) · 13.1 KB
/
test-integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
name: Run integration tests
on:
create:
pull_request:
paths:
- ".github/workflows/test-integration.yml"
- ".github/workflows/testdata/**"
- "poetry.lock"
- "pyproject.toml"
- "action.yml"
- "compilesketches/**"
push:
paths:
- ".github/workflows/test-integration.yml"
- ".github/workflows/testdata/**"
- "poetry.lock"
- "pyproject.toml"
- "action.yml"
- "compilesketches/**"
repository_dispatch:
schedule:
# Run periodically to catch breakage caused by external changes.
- cron: "0 12 * * THU"
workflow_dispatch:
env:
SKETCHES_REPORTS_PATH: sketches-reports
TESTDATA_PLATFORMS_PATH: .github/workflows/testdata/platforms
TESTDATA_SKETCHES_PATH: .github/workflows/testdata/sketches
TESTDATA_REPORTS_PATH: .github/workflows/testdata/reports
jobs:
run-determination:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Determine if the rest of the workflow should run
id: determination
run: |
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
if [[
"${{ github.event_name }}" != "create" ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
]]; then
# Run the other jobs.
RESULT="true"
else
# There is no need to run the other jobs.
RESULT="false"
fi
echo "result=$RESULT" >> $GITHUB_OUTPUT
default-inputs:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Servo library
uses: actions/checkout@v4
with:
repository: arduino-libraries/servo
ref: 1.1.7
- name: Checkout local repo
uses: actions/checkout@v4
with:
# Must be checked out to a subfolder to not interfere with the checked out library under test
path: extras/compile-sketches
- name: Run action with default input values
# Use action from local path
uses: ./extras/compile-sketches
all-inputs:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- fqbn: arduino:avr:uno
artifact-name-suffix: arduino-avr-uno
platforms: |
- name: arduino:avr
version: 1.8.3
libraries: |
- name: Servo
version: 1.1.7
# Board that requires Boards Manager URL
- fqbn: esp8266:esp8266:huzzah
artifact-name-suffix: esp8266-esp8266-huzzah
platforms: |
- name: esp8266:esp8266
source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
version: 2.7.4
libraries: |
# The official Servo library is not compatible with ESP8266, but that platform has a bundled Servo lib
# so there are no library dependencies
[]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run action
# Use action from local path
uses: ./
with:
cli-version: 0.15.1
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: ${{ matrix.board.platforms }}
fqbn: ${{ matrix.board.fqbn }}
libraries: ${{ matrix.board.libraries }}
sketch-paths: |
- ${{ env.TESTDATA_SKETCHES_PATH }}/BareMinimum
- ${{ env.TESTDATA_SKETCHES_PATH }}/ServoLibrary
- ${{ env.TESTDATA_SKETCHES_PATH }}/TestCompileFlags
cli-compile-flags: |
- --build-property
- compiler.cpp.extra_flags="-DSTRING_MACRO="hello world"" -DINT_MACRO=2 -DFLAG_MACRO
- --export-binaries
enable-deltas-report: true
enable-warnings-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
verbose: true
- name: Verify --export-binaries flag was used by compilation command
run: |
[ -d ${{ env.TESTDATA_SKETCHES_PATH }}/BareMinimum/build ]
- name: Set report artifact name
id: report-artifact-prefix
run: |
echo "report-artifact-prefix=${{ github.job }}" >> "$GITHUB_OUTPUT"
- name: Save sketches report as workflow artifact
uses: actions/upload-artifact@v4
with:
path: sketches-reports
name: ${{ steps.report-artifact-prefix.outputs.report-artifact-prefix }}-${{ matrix.board.artifact-name-suffix }}
outputs:
report-artifact-prefix: ${{ steps.report-artifact-prefix.outputs.report-artifact-prefix }}
multiple-steps:
name: multiple-steps (${{ matrix.board.source-type }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- source-type: manager
fqbn: arduino:avr:uno
platforms: |
- name: arduino:avr
version: 1.8.3
libraries: |
- name: Servo
version: 1.1.7
- source-type: path
fqbn: arduino:avr:uno
platforms: |
- name: arduino:avr
version: 1.8.3
- source-path: extras/ArduinoCore-avr
name: arduino:avr
libraries: |
- source-path: ./
name: Servo
- source-type: repo
fqbn: arduino:avr:uno
platforms: |
- name: arduino:avr
version: 1.8.3
- source-url: https://github.com/arduino/ArduinoCore-avr.git
name: arduino:avr
version: 1.8.3
libraries: |
- source-url: https://github.com/arduino-libraries/Servo.git
name: Servo
version: 1.1.7
- source-type: archive
fqbn: arduino:avr:uno
platforms: |
- name: arduino:avr
version: 1.8.3
- source-url: https://github.com/arduino/ArduinoCore-avr/archive/refs/tags/1.8.3.zip
name: arduino:avr
libraries: |
- source-url: https://github.com/arduino-libraries/Servo/archive/refs/tags/1.1.7.zip
name: Servo
steps:
- name: Checkout library
uses: actions/checkout@v4
with:
repository: arduino-libraries/Servo
ref: 1.1.7
- name: Checkout platform
if: matrix.board.source-type == 'path'
uses: actions/checkout@v4
with:
repository: arduino/ArduinoCore-avr
ref: 1.8.3
path: extras/ArduinoCore-avr
- name: Checkout local repo
uses: actions/checkout@v4
with:
path: extras/compile-sketches
- name: Run action
# Use action from local path
uses: ./extras/compile-sketches
with:
platforms: ${{ matrix.board.platforms }}
fqbn: ${{ matrix.board.fqbn }}
libraries: ${{ matrix.board.libraries }}
sketch-paths: |
- examples/Sweep
- name: Run action again
uses: ./extras/compile-sketches
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: ${{ matrix.board.platforms }}
fqbn: ${{ matrix.board.fqbn }}
libraries: ${{ matrix.board.libraries }}
sketch-paths: |
- examples/Sweep
python-package-dependency:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout local repo
uses: actions/checkout@v4
- name: Install Python package dependency
run: |
pip install \
--ignore-installed \
--user \
cowsay
- name: Run action with board that has external Python package dependency
# Use action from local path
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: |
- name: arduino:avr
- source-path: ${{ env.TESTDATA_PLATFORMS_PATH }}/PythonPackageDependent
name: PythonPackageDependent:avr
fqbn: PythonPackageDependent:avr:package_dependent
libraries: |
[]
sketch-paths: |
- ${{ env.TESTDATA_SKETCHES_PATH }}/BareMinimum
# Targeted testing for ESP32 boards platform support.
pyserial-dependency:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout local repo
uses: actions/checkout@v4
- name: Install pyserial
run: |
# Use of pip3 and omission of recommended flags done to reproduce established use pattern:
# https://github.com/arduino-libraries/ArduinoIoTCloud/blob/1.11.0/.github/workflows/compile-examples.yml#L206
pip3 install pyserial
- name: Run action with board that has pyserial dependency
# Use action from local path
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: |
- name: arduino:avr
- source-path: ${{ env.TESTDATA_PLATFORMS_PATH }}/PyserialDependent
name: PyserialDependent:avr
fqbn: PyserialDependent:avr:pyserial_dependent
libraries: |
[]
sketch-paths: |
- ${{ env.TESTDATA_SKETCHES_PATH }}/BareMinimum
check-sketches-reports:
needs:
- run-determination
- all-inputs
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
steps:
# Checkout is needed to get the golden reports
- name: Checkout local repo
uses: actions/checkout@v4
- name: Download sketches reports artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: ${{ env.SKETCHES_REPORTS_PATH }}
pattern: ${{ needs.all-inputs.outputs.report-artifact-prefix }}*
- name: Compare generated sketches report to golden report
run: |
# The commit hash changes on every push, so it can't be compared against the golden report
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
COMMIT_HASH="${{ github.event.pull_request.head.sha }}"
else
COMMIT_HASH="$(git rev-parse HEAD)"
fi
set +o errexit # Unset errexit so the results of all report comparisons are shown before exiting
EXIT_STATUS=0
while read -r reportPath; do
echo "Sketches report $reportPath matches expected:"
(
# Check static report components against golden reports
jq \
--null-input \
--exit-status \
--slurpfile \
generated \
"$reportPath" \
--slurpfile \
golden \
"${{ env.TESTDATA_REPORTS_PATH }}/${{ needs.all-inputs.outputs.report-artifact-prefix }}/$(basename "$reportPath")" \
'($generated|.[0].boards) == ($golden|.[0].boards)'
) && (
# Check the commit_hash value
jq \
--null-input \
--exit-status \
--slurpfile generated "$reportPath" \
--arg commit_hash "$COMMIT_HASH" \
'$generated|.[0].commit_hash == $commit_hash|.'
) && (
# Check the commit_url value
jq \
--null-input \
--exit-status \
--slurpfile generated "$reportPath" \
--arg commit_url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${COMMIT_HASH}" \
'$generated|.[0].commit_url == $commit_url|.'
)
if [[ $? -ne 0 ]]; then
echo "::error::Sketches report $reportPath mismatch."
EXIT_STATUS=1
fi
done <<<"$(find "${{ env.SKETCHES_REPORTS_PATH }}" -type f -and -name '*.json')"
exit $EXIT_STATUS
expected-failed-compilation:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout local repo
uses: actions/checkout@v4
- name: Compile sketch that is expected to error
id: compile-sketches
continue-on-error: true
uses: ./
with:
fqbn: arduino:avr:uno
github-token: ${{ secrets.GITHUB_TOKEN }}
libraries: |
[]
sketch-paths: |
- ${{ env.TESTDATA_SKETCHES_PATH }}/Error
- name: Fail the job if the action run succeeded
if: steps.compile-sketches.outcome == 'success'
run: |
echo "::error::The action run was expected to fail, but passed!"
exit 1