-
Notifications
You must be signed in to change notification settings - Fork 7
192 lines (169 loc) · 5.63 KB
/
build.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
# Copyright (C) 2023 Toitware ApS.
#
# Use of this source code is governed by a BSD0-style license that can be
# found in the LICENSE_BSD0 file.
name: Build
on:
workflow_dispatch:
inputs:
toit-version:
description: Toit SDK version to check out
required: true
type: string
branch:
description: Branch to check out (overrides toit-version)
required: false
type: string
default: ""
upload-release:
description: Upload release artifacts
required: true
type: boolean
default: false
variant:
description: Variant to build
required: false
type: string
gist:
description: Link to gist with variant files
required: false
type: string
jobs:
build:
name: "Build for SDK ${{ github.event.inputs.toit-version }}"
runs-on: ubuntu-latest
steps:
- name: Show inputs
run: echo "${{ toJSON(github.event.inputs) }}"
- uses: actions/checkout@v4
- name: Set the git version
run: |
echo "TOIT_GIT_VERSION=${{ github.event.inputs.toit-version }}" >> $GITHUB_ENV
- name: Fetch the Toit repository
run: |
# We allow the workflow dispatch to override the checked out branch.
# Note that we set the TOIT_GIT_VERSION env variable. The checked out branch
# thus doesn't influence the version of the SDK we build.
REF=${{ github.event.inputs.branch }}
if [[ -z "$REF" ]]; then
REF=${{ github.event.inputs.toit-version }}
fi
make TOIT_VERSION=$REF download-toit
- name: Setup build dependencies
uses: ./toit/actions/setup-build
with:
toit-dir: toit
esp32: true
- name: Ccache stats before SDK build
run: |
ccache -s
- name: Increase ccache max size
run: |
echo "CCACHE_MAXSIZE=600M" >> $GITHUB_ENV
- name: Build the host SDK
run: |
make build-host
- name: Ccache stats after SDK build
run: |
ccache -s
- name: Build the envelope tool
run: |
build/host/sdk/bin/toit pkg install --project-root=tools
build/host/sdk/bin/toit compile -o build/envelope-tool tools/main.toit
- name: Setting the variants
run: |
VARIANTS=${{ github.event.inputs.variant }}
if [ -z "$VARIANTS" ]; then
if ! [ -z "${{ github.event.inputs.gist }}" ]; then
VARIANTS="gist"
else
VARIANTS=$(build/envelope-tool list)
if [ $? -ne 0 ]; then
echo "Failed to list variants"
exit 1
fi
fi
fi
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "VARIANTS<<$EOF" >> $GITHUB_ENV
echo "$VARIANTS" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
echo "VARIANTS_ROOT=variants" >> $GITHUB_ENV
- name: Download Gist
if: ${{ github.event.inputs.gist }}
run: |
GIST=${{ github.event.inputs.gist }}
mkdir -p "gist-variant/$VARIANTS"
build/envelope-tool download-gist -o "gist-variant/$VARIANTS" "$GIST"
echo "VARIANTS_ROOT=gist-variant" >> $GITHUB_ENV
find gist-variant
- name: Synthesize the variants
run: |
build/envelope-tool synthesize \
--ignore-errors \
--toit-root=toit \
--output-root=synthesized \
--sdk-path=build/host/sdk \
--variants-root=$VARIANTS_ROOT \
--build-root=build \
$VARIANTS
- name: Ccache stats before variants build
run: |
ccache -s
- name: Build the variants
run: |
for variant in $VARIANTS; do
mkdir -p build/$variant
if [ -e synthesized/$variant/failed ]; then
echo "Skipping $variant to due failed synthesis."
touch build/$variant/failed
continue
fi
ccache -s
(cd synthesized/$variant && make) || touch build/$variant/failed
done
- name: Ccache stats after variants build
run: |
ccache -s
- name: Prepare envelopes for upload
run: |
mkdir envelopes
for variant in $VARIANTS; do
if [ -e build/$variant/failed ]; then
echo "Skipping $variant"
continue
fi
cp build/$variant/firmware.envelope envelopes/firmware-$variant.envelope
gzip -9 envelopes/firmware-$variant.envelope
done
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
envelopes
- name: Release
if: ${{ github.event.inputs.upload-release == 'true' }}
uses: ncipollo/release-action@v1
with:
artifacts: |
envelopes/*
body: |
Envelopes for Toit SDK ${{ github.event.inputs.toit-version }}
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.toit-version }}
commit: main
- name: Report failed builds
if: ${{ github.event.inputs.upload-release == 'true' }}
run: |
build_failed=false
for variant in $VARIANTS; do
if [ -e build/$variant/failed ]; then
echo "Build of $variant failed"
build_failed=true
fi
done
if [ "$build_failed" = true ]; then
exit 1
fi