-
Notifications
You must be signed in to change notification settings - Fork 82
271 lines (241 loc) · 8.75 KB
/
ci.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
name: CI
on:
schedule:
- cron: '00 2 * * *' # 02:00 UTC
push:
branches-ignore:
- "wip/**"
- "wip-**"
- "*/wip-**"
- "*/wip/**"
release:
types: [published]
workflow_dispatch:
inputs:
# Use 'inputs.<name>' when pasting into a bash `if`, like so:
# if [[ "${{ inputs.strip }}" == 'true' ]]; then ...
#
# When using to guard a step, use 'github.event.inputs.<name>', like so:
# if: ${{ github.event.inputs.<name> == 'true' }}
# or
# if: ${{ github.event.inputs.<name> != 'false' }}
# In the first case, the step will not run if there isn't any workflow dispatch.
# In the second case, the step will run if there isn't any workflow dispatch.
# As such, the recommendation is to use the `== true` if the default is
# false, and the `!= false` if the default is true.
strip:
description: "Strip executables"
required: false
type: boolean
default: false
sign-macos:
description: "Sign macOS executables"
required: false
type: boolean
default: false
build-arm-macos:
description: "Build ARM macOS executables"
required: false
type: boolean
default: false
dispatch-toitdocs:
description: "Dispatch toitdoc rebuild"
required: false
type: boolean
default: false
run-tests:
description: "Run tests"
required: false
type: boolean
default: true
test-more:
description: "Run more tests"
required: false
type: boolean
default: false
run-esp32-flow:
description: "Run the ESP32 flow"
required: false
type: boolean
default: true
do-release:
description: "Build release artifacts and upload with this version"
required: false
type: string
default:
enable-lto:
description: "Enable link-time optimizations"
required: false
type: boolean
default: false
env:
TOIT_VERSION: ${{ github.event.inputs.do-release || github.event.release.tag_name || '' }}
DO_RELEASE: ${{ github.event_name == 'release' || startsWith(github.event.inputs.do-release, 'v') }}
DO_MORE_TESTS: ${{ github.event_name == 'schedule' || github.event.inputs.test-more == 'true' }}
ESPTOOL_VERSION: "v4.8.1%2Btoitlang"
TEST_PI_HW: "true"
jobs:
prereqs:
runs-on: ubuntu-latest
steps:
- name: Set strategy variables
id: vars
run: |
# ubuntu-20.04 so that we don't depend on a recent glibc.
# macos-13, since it's still intel based.
if [[ "${{ github.ref }}" == 'refs/heads/master' || \
"${{ env.DO_RELEASE }}" == "true" || \
"${{ inputs.build-arm-macos }}" == "true" || \
"${{ inputs.sign-macos }}" == "true" \
]]; then
echo 'CONTAINERS=[ "ubuntu-20.04", "macos-13", "macos-latest", "windows-latest" ]' > $GITHUB_OUTPUT
else
echo 'CONTAINERS=[ "ubuntu-20.04", "macos-13", "windows-latest" ]' > $GITHUB_OUTPUT
fi
if [[ "${{ inputs.run-tests }}" != "false" ]]; then
echo 'SHARDS=[1, 2, 3, 4, 5]' >> $GITHUB_OUTPUT
echo 'EXTRA_INCLUDES=[{"container": "ubuntu-20.04", "shard": 6}, {"container": "ubuntu-20.04", "shard": 7}]' >> $GITHUB_OUTPUT
echo 'SHARD_COUNT=5' >> $GITHUB_OUTPUT
echo 'SHARD_COUNT_LINUX=7' >> $GITHUB_OUTPUT
else
echo 'SHARDS=[1]' >> $GITHUB_OUTPUT
echo 'EXTRA_INCLUDES=[]' >> $GITHUB_OUTPUT
echo 'SHARD_COUNT=1' >> $GITHUB_OUTPUT
fi
outputs:
CONTAINERS: ${{ steps.vars.outputs.CONTAINERS }}
SHARDS: ${{ steps.vars.outputs.SHARDS }}
EXTRA_INCLUDES: ${{ steps.vars.outputs.EXTRA_INCLUDES }}
SHARD_COUNT: ${{ steps.vars.outputs.SHARD_COUNT }}
SHARD_COUNT_LINUX: ${{ steps.vars.outputs.SHARD_COUNT_LINUX }}
TEST_PI_HW: ${{ env.TEST_PI_HW }}
esp32:
if: ${{ github.event.inputs.run-esp32-flow != 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up build environment
uses: ./actions/setup-build
with:
toit-dir: .
esp32: true
cache-key-prefix: esp32
# Build using make.
- name: make
run: |
ccache -s
source third_party/esp-idf/export.sh
# Install the Python packages necessary for MbedTLS after
# setting up the virtual Python environment.
pip install jsonschema jinja2
make esp32
make ESP32_CHIP=esp32c3 esp32
make ESP32_CHIP=esp32s2 esp32
make ESP32_CHIP=esp32s3 esp32
ccache -s
- name: Pack firmware artifacts
shell: bash
run: |
gzip --to-stdout build/esp32/firmware.envelope > build/firmware-esp32.gz
gzip --to-stdout build/esp32c3/firmware.envelope > build/firmware-esp32c3.gz
gzip --to-stdout build/esp32s2/firmware.envelope > build/firmware-esp32s2.gz
gzip --to-stdout build/esp32s3/firmware.envelope > build/firmware-esp32s3.gz
- name: Upload firmware artifacts
uses: actions/upload-artifact@v4
with:
name: firmwares
path: |
build/firmware-esp32.gz
build/firmware-esp32c3.gz
build/firmware-esp32s2.gz
build/firmware-esp32s3.gz
# The raspbian executable is also built on the 'cross' job, but we want to
# run the serial test as fast as possible and don't want to wait for the
# 'cross' job to finish.
rpi:
runs-on: ubuntu-latest
needs: prereqs
if: needs.prereqs.outputs.TEST_PI_HW == 'true'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set version
run: |
if [ -z "$TOIT_VERSION" ]; then
TOIT_VERSION=$(cmake -DPRINT_VERSION=1 -P tools/gitversion.cmake)
fi
echo "TOIT_GIT_VERSION=$TOIT_VERSION" >> $GITHUB_ENV
- name: Set up build environment
uses: ./actions/setup-build
with:
toit-dir: .
cache-key-prefix: cross-pi
- name: Make
# Note that the TOIT_GIT_VERSION is set. The make step will thus not
# compute the version from git.
run: |
make raspbian
- name: Pack artifacts
shell: bash
# Note that we use `cp -R` first, since that works on every platform.
run: |
cp -R ./build/raspbian/sdk ./build/raspbian/toit
tar -czf build/rpi.tar.gz -C ./build/raspbian --dereference toit
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: rpi-build
path: |
build/rpi.tar.gz
serial:
needs: [prereqs, rpi, esp32]
if: needs.prereqs.outputs.TEST_PI_HW == 'true'
runs-on: serial
steps:
- name: Clean workspace
run: |
rm -rf ${{ github.workspace }}/*
- uses: actions/checkout@v4
# We need a more recent version of cmake than is installed globally.
- name: Add local bin to PATH
run: |
echo "$HOME/local/bin" >> $GITHUB_PATH
# Download the Pi artifact.
- name: Download the SDK
uses: actions/download-artifact@v4
with:
name: rpi-build
- name: Unpack the Toit SDK
run: |
mkdir -p rpi
tar x -zf rpi.tar.gz -C rpi
- name: Download esptool
# The Toit SDK we got is not yet combined and thus missing the esptool.
run: |
export ESPTOOL_ARCH=linux-armv7
curl -O -L /~https://github.com/toitlang/esptool/releases/download/$ESPTOOL_VERSION/esptool-$ESPTOOL_ARCH.zip
unzip esptool-$ESPTOOL_ARCH.zip
cp esptool-$ESPTOOL_ARCH/esptool$EXTENSION rpi/toit/tools/esptool$EXTENSION
chmod +x rpi/toit/tools/esptool$EXTENSION
- name: Download ESP32 envelopes
uses: actions/download-artifact@v4
with:
name: firmwares
- name: Unpack the ESP32 firmware
run: |
gunzip firmware-esp32.gz
gunzip firmware-esp32s3.gz
- name: Test Raspberry Pi
env:
TOIT_EXE_HW: ${{ github.workspace }}/rpi/toit/bin/toit
ESP32_ENVELOPE: ${{ github.workspace }}/firmware-esp32
ESP32S3_ENVELOPE: ${{ github.workspace }}/firmware-esp32s3
run: |
# Get the pin configuration from the file in the runner's home.
source $HOME/pi-test.env
# Get the esp32 port and wifi configuration from the file in the runner's home.
source $HOME/esp32-test.env
make TOIT_EXE_HW=${{ github.workspace }}/rpi/toit/bin/toit test-hw