-
-
Notifications
You must be signed in to change notification settings - Fork 16
203 lines (172 loc) · 6.48 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
name: Run integration tests
on:
pull_request:
paths:
- '.github/workflows/test-integration.yml'
- '.github/workflows/testdata/**'
- 'action.yml'
- 'action-setup.sh'
- 'compilesketches/**'
push:
paths:
- '.github/workflows/test-integration.yml'
- '.github/workflows/testdata/**'
- 'action.yml'
- 'action-setup.sh'
- 'compilesketches/**'
env:
SKETCHES_REPORTS_PATH: sketches-reports
TESTDATA_SKETCHES_PATH: .github/workflows/testdata/sketches
TESTDATA_REPORTS_PATH: .github/workflows/testdata/reports
jobs:
default-inputs:
runs-on: ubuntu-latest
steps:
- name: Checkout Servo library
uses: actions/checkout@v2
with:
repository: arduino-libraries/servo
ref: 1.1.7
- name: Checkout local repo
uses: actions/checkout@v2
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:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- fqbn: 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
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@v2
- name: Run action
# Use action from local path
uses: ./
with:
cli-version: 0.15.1
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-name
run: |
echo "::set-output name=report-artifact-name::${{ github.job }}"
- name: Save sketches report as workflow artifact
uses: actions/upload-artifact@v2
with:
path: sketches-reports
name: ${{ steps.report-artifact-name.outputs.report-artifact-name }}
outputs:
report-artifact-name: ${{ steps.report-artifact-name.outputs.report-artifact-name }}
check-sketches-reports:
needs: all-inputs
runs-on: ubuntu-latest
steps:
# Checkout is needed to get the golden reports
- name: Checkout local repo
uses: actions/checkout@v2
- name: Download sketches reports artifact
uses: actions/download-artifact@v2
with:
name: ${{ needs.all-inputs.outputs.report-artifact-name }}
path: ${{ env.SKETCHES_REPORTS_PATH }}
- 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-name }}/$(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:
runs-on: ubuntu-latest
steps:
- name: Checkout local repo
uses: actions/checkout@v2
- name: Compile sketch that is expected to error
id: compile-sketches
continue-on-error: true
uses: ./
with:
fqbn: arduino:avr:uno
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