-
Notifications
You must be signed in to change notification settings - Fork 258
302 lines (264 loc) · 9.03 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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Rust
on:
push:
branches: ["main", "v*"]
# Also run on tag pushes, as the release.yml doesn't currently run tests
tags: ["v*"]
pull_request:
branches: ["main", "v*"]
# Serialize workflow runs per ref
# Cancel any outdated, in-flight runs for refs other than 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.79
jobs:
dependency-review:
name: Review new dependencies for known vulnerabilities
runs-on: "ubuntu-20.04"
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
lint-rust:
name: Lint Rust
runs-on: "ubuntu-20.04"
permissions:
## Allow this job to potentially cancel the running workflow (on failure)
actions: write
steps:
- uses: actions/checkout@v3
- name: setup dependencies
uses: ./.github/actions/spin-ci-dependencies
with:
rust: true
rust-wasm: true
rust-cache: true
- name: Run lints on main code
run: BUILD_SPIN_EXAMPLES=0 make lint
- name: Run lints on examples
run: BUILD_SPIN_EXAMPLES=0 make lint-rust-examples
## This is separated out to remove full integration tests dependencies on windows/mac builds
build-rust-ubuntu:
name: Build Spin Ubuntu
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: setup dependencies
uses: ./.github/actions/spin-ci-dependencies
with:
rust: true
rust-wasm: true
rust-cache: true
- name: Cargo Build
run: cargo build --workspace --release --all-targets --features openssl/vendored --features all-tests
env:
CARGO_INCREMENTAL: 0
- name: "Archive executable artifact"
uses: actions/upload-artifact@v3
with:
name: spin-ubuntu-latest
path: target/release/spin
build-spin-static:
name: Build Spin static
runs-on: ubuntu-20.04
strategy:
matrix:
config:
- {
arch: "aarch64",
target: "aarch64-unknown-linux-musl"
}
- {
arch: "amd64",
target: "x86_64-unknown-linux-musl"
}
steps:
- uses: actions/checkout@v3
- name: setup dependencies
uses: ./.github/actions/spin-ci-dependencies
with:
rust: true
rust-cross: true
rust-cache: true
- name: Cargo Build
run: cross build --target ${{ matrix.config.target }} --release --features openssl/vendored
env:
CARGO_INCREMENTAL: 0
BUILD_SPIN_EXAMPLES: 0
- name: "Archive executable artifact"
uses: actions/upload-artifact@v3
with:
name: spin-static-${{ matrix.config.arch }}
path: target/${{ matrix.config.target }}/release/spin
build-spin:
name: Build Spin
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-13, macos-14]
steps:
- uses: actions/checkout@v3
- name: setup dependencies
uses: ./.github/actions/spin-ci-dependencies
with:
rust: true
rust-wasm: true
rust-cache: true
openssl-windows: "${{ matrix.os == 'windows-latest' }}"
- name: Cargo Build
run: cargo build --workspace --release --all-targets
env:
CARGO_INCREMENTAL: 0
- name: "Archive executable artifact"
uses: actions/upload-artifact@v3
with:
name: spin-${{ matrix.os }}
path: target/release/spin${{ matrix.os == 'windows-latest' && '.exe' || '' }}
test-spin:
name: Test Spin
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: [ubuntu-22.04-4core-spin, macos-14]
steps:
- uses: actions/checkout@v3
- name: setup dependencies
uses: ./.github/actions/spin-ci-dependencies
with:
rust: true
rust-wasm: true
rust-cache: true
nomad: true
- name: Check disk space (Before)
run: df -h /
# Clear space on macOS runner which is prone to running out of space
- name: Free disk space
run: |
sudo rm -rf ~/.dotnet
sudo rm -rf /Library/Android
sudo rm -rf /Library/Developer/CoreSimulator
find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 | xargs rm -rf
continue-on-error: true
if: ${{ matrix.runner == 'macos-14' }}
- name: Check disk space (After)
run: df -h /
- name: Run Unit Tests
run: |
make test-unit
- name: Run Integration Tests
run: |
make test-integration
env:
SPIN_CONFORMANCE_TESTS_DOCKER_OPT_OUT: true
# Only run integration tests on macOS as they will be run on ubuntu separately
if: ${{ matrix.runner == 'macos-14' }}
all-integration-tests:
# run on a larger runner for more SSD/resource access
runs-on: ubuntu-22.04-4core-spin
if: ${{ github.repository_owner == 'fermyon' }}
steps:
- uses: actions/checkout@v3
# Install all the toolchain dependencies
- name: Install Rust wasm target
run: rustup target add wasm32-wasi && rustup target add wasm32-unknown-unknown
- uses: goto-bus-stop/setup-zig@v2
- uses: actions/setup-go@v4
with:
go-version: '1.20.1'
- uses: acifani/setup-tinygo@v2
with:
tinygo-version: '0.27.0'
- uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Install Grain
run: |
wget https://github.com/grain-lang/grain/releases/download/grain-v0.6.6/grain-linux-x64
chmod +x grain-linux-x64
mv grain-linux-x64 grain
echo "$PWD" >> $GITHUB_PATH
- name: Run Full Integration Tests
run: make test-integration-full
# This runs the same steps as the release build except for signing
ensure-release-builds:
name: Run release build steps
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- {
os: "ubuntu-20.04",
arch: "amd64",
extension: "",
# Ubuntu 22.04 no longer ships libssl1.1, so we statically
# link it here to preserve release binary compatibility.
extraArgs: "--features openssl/vendored",
target: "",
targetDir: "target/release",
}
- {
os: "ubuntu-20.04",
arch: "aarch64",
extension: "",
extraArgs: "--features openssl/vendored --target aarch64-unknown-linux-gnu",
target: "aarch64-unknown-linux-gnu",
targetDir: "target/aarch64-unknown-linux-gnu/release",
}
- {
os: "macos-13",
arch: "amd64",
extension: "",
extraArgs: "",
target: "",
targetDir: "target/release",
}
- {
os: "macos-14",
arch: "aarch64",
extension: "",
extraArgs: "",
target: "",
targetDir: "target/release",
}
- {
os: "windows-latest",
arch: "amd64",
extension: ".exe",
extraArgs: "",
target: "",
targetDir: "target/release",
}
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
shell: bash
run: |
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update
rustup default ${{ env.RUST_VERSION }}
- name: Install target
if: matrix.config.target != ''
shell: bash
run: rustup target add --toolchain ${{ env.RUST_VERSION }} ${{ matrix.config.target }}
- name: "Install Wasm Rust target"
run: rustup target add wasm32-wasi --toolchain ${{ env.RUST_VERSION }} && rustup target add wasm32-unknown-unknown --toolchain ${{ env.RUST_VERSION }}
- name: setup for cross-compiled linux aarch64 build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo '[target.aarch64-unknown-linux-gnu]' >> ${HOME}/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml
echo 'rustflags = ["-Ctarget-feature=+fp16"]' >> ${HOME}/.cargo/config.toml
- name: setup dependencies
uses: ./.github/actions/spin-ci-dependencies
with:
openssl-windows: "${{ matrix.os == 'windows-latest' }}"
- name: build release
shell: bash
run: cargo build --release ${{ matrix.config.extraArgs }}