forked from zephyrproject-rtos/gsoc-2022-arduino-core
-
-
Notifications
You must be signed in to change notification settings - Fork 16
225 lines (200 loc) · 7.95 KB
/
package_core.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
name: Package, test and upload core
on:
- push
- pull_request
jobs:
package-core:
name: Build and package core
runs-on: ubuntu-latest
env:
ZEPHYR_SDK_INSTALL_DIR: /opt/zephyr-sdk-0.16.8
CCACHE_IGNOREOPTIONS: -specs=*
outputs:
CORE_TAG: ${{ env.CORE_TAG }}
CORE_ARTIFACT: ${{ env.CORE_ARTIFACT }}
BOARD_NAMES: ${{ env.BOARD_NAMES }}
steps:
- name: Install toolchain
working-directory: /opt
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends git cmake wget python3-pip ninja-build ccache
wget -nv https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz
tar xf zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz && cd zephyr-sdk-0.16.8 && ./setup.sh -t arm-zephyr-eabi -c
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Initialize
run: |
./extra/bootstrap.sh -o=--filter=tree:0
echo "CORE_TAG=$(git describe --always)" >> "$GITHUB_ENV"
echo "CORE_ARTIFACT=ArduinoCore-zephyr-$(git describe --always)" >> "$GITHUB_ENV"
echo "BOARD_NAMES=[ $(cat boards.txt | grep '^[^#]*\.build\.variant' | cut -d '.' -f 1 | xargs printf '"%s",' | sed -e 's/,$//') ]" >> "$GITHUB_ENV"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
verbose: 1
- name: Build variants
run: |
./extra/build_all.sh -f
- name: Package
run: |
./extra/package.sh ${{ env.CORE_TAG }}
mv ../${{ env.CORE_ARTIFACT }}.tar.bz2 .
- name: Archive core
uses: actions/upload-artifact@v4
with:
name: ${{ env.CORE_ARTIFACT }}
path: ${{ env.CORE_ARTIFACT }}.tar.bz2
test-core:
name: Test ${{ matrix.board }} board
runs-on: ubuntu-latest
needs: package-core
strategy:
matrix:
board: ${{ fromJSON( needs.package-core.outputs.BOARD_NAMES ) }}
fail-fast: false
env:
FQBN: arduino:zephyr:${{ matrix.board }}
REPORT_FILE: arduino-zephyr-${{ matrix.board }}.json
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ needs.package-core.outputs.CORE_ARTIFACT }}
- name: Set up core
run: |
tar xf ${{ needs.package-core.outputs.CORE_ARTIFACT }}.tar.bz2
- name: Create Blink sketch
run: |
mkdir Blink/
wget -nv https://raw.githubusercontent.com/arduino/arduino-examples/refs/heads/main/examples/01.Basics/Blink/Blink.ino -P Blink/
- name: Compile Blink for ${{ matrix.board }}
uses: pillo79/compile-sketches@main
with:
fqbn: ${{ env.FQBN }}
platforms: |
# Use Board Manager to install the latest release of Arduino Zephyr Boards to get the toolchain
- name: "arduino:zephyr"
source-url: "https://downloads.arduino.cc/packages/package_zephyr_index.json"
- name: "arduino:zephyr"
source-path: "ArduinoCore-zephyr"
sketch-paths: Blink
verbose: 'false'
enable-deltas-report: 'false'
enable-warnings-report: 'true'
enable-warnings-log: 'true'
- name: Clean up log
run: |
sed -i -e 's!/home/runner/.arduino15/packages/arduino/hardware/zephyr/[^/]*/!!g' sketches-reports/${REPORT_FILE}
cat sketches-reports/${REPORT_FILE} | jq -cr ". += { job_id: ${{ github.job }} }" > ${REPORT_FILE} && mv ${REPORT_FILE} sketches-reports/
- uses: actions/upload-artifact@v4
with:
name: test-report-${{ needs.package-core.outputs.CORE_TAG }}-${{ matrix.board }}
path: sketches-reports/*
collect-logs:
name: Test summary
runs-on: ubuntu-latest
needs:
- package-core
- test-core
if: ${{ !cancelled() && needs.package-core.result == 'success' }}
env:
BOARD_NAMES: ${{ needs.package-core.outputs.BOARD_NAMES }}
steps:
- uses: actions/download-artifact@v4
with:
path: .
pattern: test-report-*
merge-multiple: true
- run: |
echo "### Core test results" >> "$GITHUB_STEP_SUMMARY"
for BOARD in $(echo $BOARD_NAMES | jq -cr '.[]'); do
FQBN="arduino:zephyr:$BOARD"
REPORT_FILE="arduino-zephyr-$BOARD.json"
if [ ! -f $REPORT_FILE ]; then
echo ":x: $BOARD - No report found?" >> "$GITHUB_STEP_SUMMARY"
else
REPORT=$(jq -cr '.boards[0].sketches[0]' $REPORT_FILE)
JOB_ID=$(echo $REPORT | jq -cr '.job_id')
JOB_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${JOB_ID}#step:5:2"
if ! $(echo $REPORT | jq -cr '.compilation_success') ; then
echo ":x: [$BOARD]($JOB_URL) - **Build failed**" >> "$GITHUB_STEP_SUMMARY"
else
WARNINGS=$(echo $REPORT | jq -cr '.warnings.current.absolute // 0')
if [ $WARNINGS -eq 0 ]; then
echo ":white_check_mark: [$BOARD](${JOB_URL}) - Build successful" >> "$GITHUB_STEP_SUMMARY"
else
echo "<details><summary>:warning: [$BOARD]($JOB_URL) - $WARNINGS Warnings:</summary>" >> "$GITHUB_STEP_SUMMARY"
echo >> "$GITHUB_STEP_SUMMARY"
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
echo $REPORT | jq -cr '.warnings_log[]' >> "$GITHUB_STEP_SUMMARY"
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
echo >> "$GITHUB_STEP_SUMMARY"
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
fi
fi
fi
done
- name: Clean up intermediate artifacts
uses: geekyeggo/[email protected]
with:
name: test-report-*
failOnError: false
publish-core:
name: Publish core
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.repository == 'arduino/ArduinoCore-zephyr' }}
needs:
- package-core
- test-core
environment: production
permissions:
id-token: write
contents: read
env:
CORE_ARTIFACT: ${{ needs.package-core.outputs.CORE_ARTIFACT }}
ARTIFACT_FILE: ${{ needs.package-core.outputs.CORE_ARTIFACT }}.tar.bz2
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ env.CORE_ARTIFACT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.IAM_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload artifact
run: aws s3 cp ${{ env.ARTIFACT_FILE }} s3://${{ secrets.S3_BUCKET }}/
publish-json:
name: Publish json
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.repository == 'arduino/ArduinoCore-zephyr' }}
needs:
- package-core
- publish-core
env:
CORE_ARTIFACT: ${{ needs.package-core.outputs.CORE_ARTIFACT }}
ARTIFACT_FILE: ${{ needs.package-core.outputs.CORE_ARTIFACT }}.tar.bz2
CORE_TAG: ${{ needs.package-core.outputs.CORE_TAG }}
PACKAGE_INDEX_JSON: zephyr-core-${{ needs.package-core.outputs.CORE_TAG }}.json
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ env.CORE_ARTIFACT }}
- uses: actions/checkout@v4
with:
sparse-checkout: |
extra/gen_package_index_json.sh
extra/zephyr-core-template.json
# uses: ARTIFACT_FILE CORE_TAG PACKAGE_INDEX_JSON
- name: Prepare package index snippet
run: |
find
ls -l ${{ env.ARTIFACT_FILE }}
./extra/gen_package_index_json.sh
- name: Archive package index snippet
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_INDEX_JSON }}
path: ${{ env.PACKAGE_INDEX_JSON }}