Skip to content

Commit 20d6d38

Browse files
committed
Check the sketches report in the integration test CI workflow
1 parent 9fa3d42 commit 20d6d38

File tree

3 files changed

+373
-0
lines changed

3 files changed

+373
-0
lines changed

.github/workflows/test-integration.yml

+79
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818
env:
1919
SKETCHES_REPORTS_PATH: sketches-reports
2020
TESTDATA_SKETCHES_PATH: .github/workflows/testdata/sketches
21+
TESTDATA_REPORTS_PATH: .github/workflows/testdata/reports
2122

2223
jobs:
2324
default-inputs:
@@ -87,6 +88,84 @@ jobs:
8788
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
8889
verbose: true
8990

91+
- name: Set report artifact name
92+
id: report-artifact-name
93+
run: |
94+
echo "::set-output name=report-artifact-name::${{ github.job }}"
95+
96+
- name: Save sketches report as workflow artifact
97+
uses: actions/upload-artifact@v2
98+
with:
99+
path: sketches-reports
100+
name: ${{ steps.report-artifact-name.outputs.report-artifact-name }}
101+
102+
outputs:
103+
report-artifact-name: ${{ steps.report-artifact-name.outputs.report-artifact-name }}
104+
105+
106+
check-sketches-reports:
107+
needs: all-inputs
108+
runs-on: ubuntu-latest
109+
110+
steps:
111+
# Checkout is needed to get the golden reports
112+
- name: Checkout local repo
113+
uses: actions/checkout@v2
114+
115+
- name: Download sketches reports artifact
116+
uses: actions/download-artifact@v2
117+
with:
118+
name: ${{ needs.all-inputs.outputs.report-artifact-name }}
119+
path: ${{ env.SKETCHES_REPORTS_PATH }}
120+
121+
- name: Compare generated sketches report to golden report
122+
run: |
123+
# The commit hash changes on every push, so it can't be compared against the golden report
124+
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
125+
COMMIT_HASH="${{ github.event.pull_request.head.sha }}"
126+
else
127+
COMMIT_HASH="$(git rev-parse HEAD)"
128+
fi
129+
130+
set +o errexit # Unset errexit so the results of all report comparisons are shown before exiting
131+
EXIT_STATUS=0
132+
while read -r reportPath; do
133+
echo "Sketches report $reportPath matches expected:"
134+
135+
(
136+
# Check static report components against golden reports
137+
jq \
138+
--null-input \
139+
--exit-status \
140+
--slurpfile generated "$reportPath" \
141+
--slurpfile golden "${{ env.TESTDATA_REPORTS_PATH }}/${{ needs.all-inputs.outputs.report-artifact-name }}/$(basename "$reportPath")" \
142+
'($generated|.[0].boards) == ($golden|.[0].boards)'
143+
) && (
144+
# Check the commit_hash value
145+
jq \
146+
--null-input \
147+
--exit-status \
148+
--slurpfile generated "$reportPath" \
149+
--arg commit_hash "$COMMIT_HASH" \
150+
'$generated|.[0].commit_hash == $commit_hash|.'
151+
) && (
152+
# Check the commit_url value
153+
jq \
154+
--null-input \
155+
--exit-status \
156+
--slurpfile generated "$reportPath" \
157+
--arg commit_url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${COMMIT_HASH}" \
158+
'$generated|.[0].commit_url == $commit_url|.'
159+
)
160+
161+
if [[ $? -ne 0 ]]; then
162+
echo "::error::Sketches report $reportPath mismatch."
163+
EXIT_STATUS=1
164+
fi
165+
done <<<"$(find "${{ env.SKETCHES_REPORTS_PATH }}" -type f -and -name '*.json')"
166+
167+
exit $EXIT_STATUS
168+
90169
91170
expected-failed-compilation:
92171
runs-on: ubuntu-latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"commit_hash": "d4343a2e7d8123726f2c53d2ac186df41b59e946",
3+
"commit_url": "https://github.com/arduino/compile-sketches/commit/d4343a2e7d8123726f2c53d2ac186df41b59e946",
4+
"boards": [
5+
{
6+
"board": "arduino:avr:uno",
7+
"sketches": [
8+
{
9+
"name": ".github/workflows/testdata/sketches/BareMinimum",
10+
"compilation_success": true,
11+
"sizes": [
12+
{
13+
"name": "flash",
14+
"maximum": 32256,
15+
"current": {
16+
"absolute": 444,
17+
"relative": 1.38
18+
},
19+
"previous": {
20+
"absolute": 444,
21+
"relative": 1.38
22+
},
23+
"delta": {
24+
"absolute": 0,
25+
"relative": 0.0
26+
}
27+
},
28+
{
29+
"name": "RAM for global variables",
30+
"maximum": 2048,
31+
"current": {
32+
"absolute": 9,
33+
"relative": 0.44
34+
},
35+
"previous": {
36+
"absolute": 9,
37+
"relative": 0.44
38+
},
39+
"delta": {
40+
"absolute": 0,
41+
"relative": 0.0
42+
}
43+
}
44+
],
45+
"warnings": {
46+
"current": {
47+
"absolute": 0
48+
},
49+
"previous": {
50+
"absolute": 0
51+
},
52+
"delta": {
53+
"absolute": 0
54+
}
55+
}
56+
},
57+
{
58+
"name": ".github/workflows/testdata/sketches/ServoLibrary",
59+
"compilation_success": true,
60+
"sizes": [
61+
{
62+
"name": "flash",
63+
"maximum": 32256,
64+
"current": {
65+
"absolute": 888,
66+
"relative": 2.75
67+
},
68+
"previous": {
69+
"absolute": 888,
70+
"relative": 2.75
71+
},
72+
"delta": {
73+
"absolute": 0,
74+
"relative": 0.0
75+
}
76+
},
77+
{
78+
"name": "RAM for global variables",
79+
"maximum": 2048,
80+
"current": {
81+
"absolute": 46,
82+
"relative": 2.25
83+
},
84+
"previous": {
85+
"absolute": 46,
86+
"relative": 2.25
87+
},
88+
"delta": {
89+
"absolute": 0,
90+
"relative": 0.0
91+
}
92+
}
93+
],
94+
"warnings": {
95+
"current": {
96+
"absolute": 0
97+
},
98+
"previous": {
99+
"absolute": 0
100+
},
101+
"delta": {
102+
"absolute": 0
103+
}
104+
}
105+
}
106+
],
107+
"sizes": [
108+
{
109+
"name": "flash",
110+
"maximum": 32256,
111+
"delta": {
112+
"absolute": {
113+
"minimum": 0,
114+
"maximum": 0
115+
},
116+
"relative": {
117+
"minimum": 0.0,
118+
"maximum": 0.0
119+
}
120+
}
121+
},
122+
{
123+
"name": "RAM for global variables",
124+
"maximum": 2048,
125+
"delta": {
126+
"absolute": {
127+
"minimum": 0,
128+
"maximum": 0
129+
},
130+
"relative": {
131+
"minimum": 0.0,
132+
"maximum": 0.0
133+
}
134+
}
135+
}
136+
],
137+
"warnings": {
138+
"delta": {
139+
"absolute": {
140+
"minimum": 0,
141+
"maximum": 0
142+
}
143+
}
144+
}
145+
}
146+
]
147+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"commit_hash": "d4343a2e7d8123726f2c53d2ac186df41b59e946",
3+
"commit_url": "https://github.com/arduino/compile-sketches/commit/d4343a2e7d8123726f2c53d2ac186df41b59e946",
4+
"boards": [
5+
{
6+
"board": "esp8266:esp8266:huzzah",
7+
"sketches": [
8+
{
9+
"name": ".github/workflows/testdata/sketches/BareMinimum",
10+
"compilation_success": true,
11+
"sizes": [
12+
{
13+
"name": "flash",
14+
"maximum": 1044464,
15+
"current": {
16+
"absolute": 256684,
17+
"relative": 24.58
18+
},
19+
"previous": {
20+
"absolute": 256684,
21+
"relative": 24.58
22+
},
23+
"delta": {
24+
"absolute": 0,
25+
"relative": 0.0
26+
}
27+
},
28+
{
29+
"name": "RAM for global variables",
30+
"maximum": 81920,
31+
"current": {
32+
"absolute": 26776,
33+
"relative": 32.69
34+
},
35+
"previous": {
36+
"absolute": 26776,
37+
"relative": 32.69
38+
},
39+
"delta": {
40+
"absolute": 0,
41+
"relative": 0.0
42+
}
43+
}
44+
],
45+
"warnings": {
46+
"current": {
47+
"absolute": 0
48+
},
49+
"previous": {
50+
"absolute": 0
51+
},
52+
"delta": {
53+
"absolute": 0
54+
}
55+
}
56+
},
57+
{
58+
"name": ".github/workflows/testdata/sketches/ServoLibrary",
59+
"compilation_success": true,
60+
"sizes": [
61+
{
62+
"name": "flash",
63+
"maximum": 1044464,
64+
"current": {
65+
"absolute": 256684,
66+
"relative": 24.58
67+
},
68+
"previous": {
69+
"absolute": 256684,
70+
"relative": 24.58
71+
},
72+
"delta": {
73+
"absolute": 0,
74+
"relative": 0.0
75+
}
76+
},
77+
{
78+
"name": "RAM for global variables",
79+
"maximum": 81920,
80+
"current": {
81+
"absolute": 26776,
82+
"relative": 32.69
83+
},
84+
"previous": {
85+
"absolute": 26776,
86+
"relative": 32.69
87+
},
88+
"delta": {
89+
"absolute": 0,
90+
"relative": 0.0
91+
}
92+
}
93+
],
94+
"warnings": {
95+
"current": {
96+
"absolute": 0
97+
},
98+
"previous": {
99+
"absolute": 0
100+
},
101+
"delta": {
102+
"absolute": 0
103+
}
104+
}
105+
}
106+
],
107+
"sizes": [
108+
{
109+
"name": "flash",
110+
"maximum": 1044464,
111+
"delta": {
112+
"absolute": {
113+
"minimum": 0,
114+
"maximum": 0
115+
},
116+
"relative": {
117+
"minimum": 0.0,
118+
"maximum": 0.0
119+
}
120+
}
121+
},
122+
{
123+
"name": "RAM for global variables",
124+
"maximum": 81920,
125+
"delta": {
126+
"absolute": {
127+
"minimum": 0,
128+
"maximum": 0
129+
},
130+
"relative": {
131+
"minimum": 0.0,
132+
"maximum": 0.0
133+
}
134+
}
135+
}
136+
],
137+
"warnings": {
138+
"delta": {
139+
"absolute": {
140+
"minimum": 0,
141+
"maximum": 0
142+
}
143+
}
144+
}
145+
}
146+
]
147+
}

0 commit comments

Comments
 (0)