-
Notifications
You must be signed in to change notification settings - Fork 84
187 lines (169 loc) · 5.9 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
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}, {"container": "ubuntu-20.04", "shard": 8}]' >> $GITHUB_OUTPUT
echo 'SHARD_COUNT=5' >> $GITHUB_OUTPUT
echo 'SHARD_COUNT_LINUX=8' >> $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 }}
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]
if: needs.prereqs.outputs.TEST_PI_HW == 'true'
runs-on: serial
steps:
- name: Clean workspace
run: |
rm -rf ${{ github.workspace }}/*
- uses: actions/checkout@v4
# Download the pi artifact.
- uses: actions/download-artifact@v4
with:
name: rpi-build
- name: Unpack Raspberry Pi
run: |
mkdir -p rpi
tar x -zf rpi.tar.gz -C rpi
- name: Test Raspberry Pi
run: |
# Get the pin configuration from the file in the runner's home.
source $HOME/pi-test.env
make PI_TOIT_EXE=${{ github.workspace }}/rpi/toit/bin/toit test-serial