466 lines (458 loc) 路 18.5 KB
/
test-sys.yaml
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
name: Runtime tests
env:
RUST_BACKTRACE: 1
on:
push:
branches:
- 'master'
- 'staging'
- 'trying'
tags:
# this is _not_ a regex, see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
jobs:
setup:
name: Set up
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.setup.outputs.VERSION }}
DOING_RELEASE: ${{ steps.setup.outputs.DOING_RELEASE }}
steps:
- name: Set up env vars
id: setup
shell: bash
run: |
VERSION=${GITHUB_REF/refs\/tags\//}
echo ::set-output name=VERSION::${VERSION}
DOING_RELEASE=$(echo $VERSION | grep -c '^[0-9]\+\.[0-9]\+\.[0-9]\+\(-\([a-zA-Z]\+\)\?[0-9]*\)\?$' || true)
echo ::set-output name=DOING_RELEASE::${DOING_RELEASE}
echo $VERSION
echo $DOING_RELEASE
test:
name: Test on ${{ matrix.build }}
runs-on: ${{ matrix.os }}
needs: setup
strategy:
fail-fast: false
matrix:
include:
- build: linux-x64
os: ubuntu-18.04
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
artifact_name: 'wasmer-linux-amd64'
cross_compilation_artifact_name: 'cross_compiled_from_linux'
run_test: true
run_test_capi: true
run_integration_tests: true
use_sccache: true
- build: macos-x64
os: macos-11
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz'
artifact_name: 'wasmer-darwin-amd64'
cross_compilation_artifact_name: 'cross_compiled_from_mac'
run_test: true
run_test_capi: true
use_sccache: true
run_integration_tests: true
run_ios_tests: true
- build: macos-arm64
os: macos-11.0
target: aarch64-apple-darwin
artifact_name: 'wasmer-darwin-arm64'
use_sccache: true
run_test: false
run_test_capi: false
- build: windows-x64
os: windows-2019
# llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/12.x/windows-amd64.tar.gz'
llvm_choco_version: 13.0.0
artifact_name: 'wasmer-windows-amd64'
cross_compilation_artifact_name: 'cross_compiled_from_win'
run_integration_tests: true
use_sccache: true
run_test: true
run_test_capi: false # We can't run yet the capi tests on Windows
#- build: linux-aarch64
# os: [self-hosted, linux, ARM64]
# random_sccache_port: true
# use_sccache: true
# llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/12.x/linux-aarch64.tar.gz'
# artifact_name: 'wasmer-linux-aarch64'
# run_integration_tests: false
- build: linux-musl-x64
os: ubuntu-latest
container: alpine:latest
artifact_name: 'wasmer-linux-musl-amd64'
run_test: true
run_test_capi: false # It can't run the capi tests because of a cc linker issue (`wasm_engine_new` is redefined)
run_integration_tests: false
use_sccache: false
container: ${{ matrix.container }}
env:
SCCACHE_AZURE_BLOB_CONTAINER: wasmerstoragesccacheblob
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@v2
- name: Set up libstdc++ on Linux
if: matrix.build == 'linux-x64'
run: |
sudo apt-get update -y
sudo apt-get install -y --allow-downgrades libstdc++6=8.4.0-1ubuntu1~18.04
sudo apt-get install --reinstall g++-8
- name: Install dependencies on Linux
if: matrix.build == 'linux-x64' || matrix.build == 'linux-musl-x64'
run: |
sudo apt-get update -y
sudo apt-get install -y libwayland-cursor0 libxkbcommon-dev libwayland-dev
- name: Set up base deps on musl
if: matrix.build == 'linux-musl-x64'
run: |
apk add build-base musl-dev curl make libtool libffi-dev gcc automake autoconf git openssl-dev g++
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.target }}
override: true
- uses: Swatinem/rust-cache@v1
if: matrix.use_sccache != true
- name: Install LLVM (Choco - Windows)
if: matrix.llvm_choco_version
shell: bash
run: |
choco install llvm --version ${{ matrix.llvm_choco_version }} --allow-downgrade
cd 'C:\Program Files\LLVM\'
LLVM_DIR=$(pwd)
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
- name: Install LLVM (macOS Apple Silicon)
if: matrix.os == 'macos-11.0' && !matrix.llvm_url
run: |
brew install llvm
- name: Install LLVM
if: matrix.llvm_url
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.llvm_url }} -L -o llvm.tar.xz
LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
mkdir ${LLVM_DIR}
tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
env:
LLVM_DIR: .llvm
- name: Set up dependencies for Mac OS
run: |
brew install automake
# using gnu-tar is a workaround for https://github.com/actions/cache/issues/403
brew install gnu-tar
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
if: matrix.os == 'macos-latest' || matrix.os == 'macos-11.0'
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ matrix.build }}-${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}-v1
- uses: actions/cache@v2
if: matrix.use_sccache
with:
path: ${{ runner.tool_cache }}/cargo-sccache
key: ${{ matrix.build }}-${{ matrix.target }}-sccache-bin-${{ env.CARGO_SCCACHE_VERSION }}-v1
- name: Install sccache
if: matrix.use_sccache
run: |
if [ ! -f '${{ runner.tool_cache }}/cargo-sccache/bin/sccache' ]; then
cargo install sccache --no-default-features --features=dist-client,azure --root '${{ runner.tool_cache }}/cargo-sccache'
fi
shell: bash
- name: Setup Rust target
run: |
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[build]
target = "${{ matrix.target }}"
EOF
if: matrix.target
- name: Set sccache port
if: matrix.use_sccache && matrix.random_sccache_port
run: |
netstat -aln | awk '
$6 == "LISTEN" {
if ($4 ~ "[.:][0-9]+$") {
n = split($4, a, /[:.]/);
port = a[n];
p[port] = 1
}
}
END {
for (i = 3000; i < 65000 && p[i]; i++){};
if (i == 65000) {exit 1};
print "SCCACHE_SERVER_PORT=" i
}
' >> $GITHUB_ENV
# echo "SCCACHE_SERVER_PORT=9000"
echo "Setting random sccache port to: $SCCACHE_SERVER_PORT"
shell: bash
- name: Start sccache
if: matrix.use_sccache
run: |
chmod +x '${{ runner.tool_cache }}/cargo-sccache/bin/sccache'
'${{ runner.tool_cache }}/cargo-sccache/bin/sccache' --start-server
'${{ runner.tool_cache }}/cargo-sccache/bin/sccache' -s
echo 'RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache' >> $GITHUB_ENV
shell: bash
- name: Test
run: |
make test
if: matrix.run_test
- name: Test C API
run: |
make test-capi
if: matrix.run_test_capi
- name: Build C API
run: |
make build-capi
- name: Build Wasmer binary
run: |
make build-wasmer
- name: Build Wapm binary
if: needs.setup.outputs.DOING_RELEASE == '1'
run: |
make build-wapm
- name: Install Nightly Rust for Headless
uses: actions-rs/toolchain@v1
with:
toolchain: 'nightly-2021-11-01'
target: ${{ matrix.target }}
override: true
components: "rust-src"
- name: Build Minimal Wasmer Headless
if: matrix.build != 'linux-musl-x64'
run: |
cargo install xargo
echo "" >> Cargo.toml
echo "[profile.release]" >> Cargo.toml
echo "opt-level = 'z'" >> Cargo.toml
echo "debug = false" >> Cargo.toml
echo "debug-assertions = false" >> Cargo.toml
echo "overflow-checks = false" >> Cargo.toml
echo "lto = true" >> Cargo.toml
echo "panic = 'abort'" >> Cargo.toml
echo "incremental = false" >> Cargo.toml
echo "codegen-units = 1" >> Cargo.toml
echo "rpath = false" >> Cargo.toml
make build-wasmer-headless-minimal
- name: Dist
run: |
make distribution
- name: Run integration tests (Windows)
shell: cmd
run: |
call refreshenv
set WASMER_DIR=%CD%\package
make test-integration
if: matrix.run_integration_tests && matrix.os == 'windows-2019'
- name: Run integration tests (Unix)
run: |
export WASMER_DIR=`pwd`/package
make test-integration
if: matrix.run_integration_tests && matrix.os != 'windows-2019'
- name: Run iOS integration tests
run: |
rustup target add aarch64-apple-ios x86_64-apple-ios
cargo install cargo-lipo
make test-integration-ios
if: matrix.run_ios_tests
- name: Cross compile from Linux
if: matrix.build == 'linux-x64'
shell: bash
run: |
ls target/release
alias wasmer=target/release/wasmer
./target/release/wasmer compile --target=x86_64-apple-darwin lib/c-api/examples/assets/qjs.wasm -o qjs_mac_from_linux.wjit
#./target/release/wasmer compile --target=x86_64-pc-windows-msvc lib/c-api/examples/assets/qjs.wasm -o qjs_win_from_linux.wjit
mkdir cross
cp qjs_mac_from_linux.wjit cross
#cp qjs_win_from_linux.wjit cross
cp target/release/wasmer cross
- name: Cross compile from Mac
if: matrix.os == 'macos-11'
shell: bash
run: |
ls target/release
alias wasmer=target/release/wasmer
./target/release/wasmer compile --target=x86_64-unknown-linux-gnu lib/c-api/examples/assets/qjs.wasm -o qjs_linux_from_mac.wjit
#./target/release/wasmer compile --target=x86_64-pc-windows-msvc lib/c-api/examples/assets/qjs.wasm -o qjs_win_from_mac.wjit
mkdir cross
cp qjs_linux_from_mac.wjit cross
#cp qjs_win_from_mac.wjit cross
cp target/release/wasmer cross
#- name: Cross compile from Windows
# if: matrix.os == 'windows-2019'
# shell: bash
# run: |
# alias wasmer=target/release/wasmer
# ./target/release/wasmer compile --target=x86_64-unknown-linux-gnu tests/integration/cli/assets/qjs.wasm -o qjs_linux_from_win.wjit
# ./target/release/wasmer compile --target=x86_64-apple-darwin tests/integration/cli/assets/qjs.wasm -o qjs_mac_from_win.wjit
# mkdir cross
# cp qjs_linux_from_win.wjit cross
# cp qjs_mac_from_win.wjit cross
# cp target/release/wasmer.exe cross
- name: Upload Cross Compiled Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.cross_compilation_artifact_name }}
path: cross
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifact_name }}
path: dist
if-no-files-found: error
retention-days: 1
test-cross-compile-on-linux:
name: Test cross-compile on linux
needs: [setup, test]
runs-on: ubuntu-latest
steps:
- name: Download Wasmer
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Run it
run: |
cp artifacts/cross_compiled_from_linux/wasmer .
chmod +x wasmer
OUTPUT=$(./wasmer run artifacts/cross_compiled_from_mac/qjs_linux_from_mac.wjit -- --eval "function greet(name) { return JSON.stringify('Hello, ' + name); }; print(greet('World'));")
[[ "$OUTPUT" == '"Hello, World"' ]]
#wasmer run artifacts/cross/cross_compiled_from_win/qjs_linux_from_win.wjit -- --eval "function greet(name) { return JSON.stringify('Hello, ' + name); }; print(greet('World'));"
test-cross-compile-on-mac:
name: Test cross-compile on macos
needs: [setup, test]
runs-on: macos-11
steps:
- name: Download Wasmer
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Run it
run: |
cp artifacts/cross_compiled_from_mac/wasmer .
chmod +x wasmer
OUTPUT=$(./wasmer run artifacts/cross_compiled_from_linux/qjs_mac_from_linux.wjit -- --eval "function greet(name) { return JSON.stringify('Hello, ' + name); }; print(greet('World'));")
[[ "$OUTPUT" == '"Hello, World"' ]]
#wasmer run artifacts/cross/cross_compiled_from_win/qjs_mac_from_win.wjit -- --eval "function greet(name) { return JSON.stringify('Hello, ' + name); }; print(greet('World'));"
#test-cross-compile-on-win:
# needs: [setup, test]
# runs-on: windows-2019
# steps:
# - name: Download Wasmer
# uses: actions/download-artifact@v2
# with:
# path: artifacts
# - name: Run it
# shell: bash
# run: |
# alias wasmer=artifacts/cross/cross_compiled_from_win/wasmer.exe
# wasmer run artifacts/cross/cross_compiled_from_linux/win_from_linux.wjit -- --eval "function greet(name) { return JSON.stringify('Hello, ' + name); }; print(greet('World'));"
# wasmer run artifacts/cross/cross_compiled_from_mac/win_from_mac.wjit -- --eval "function greet(name) { return JSON.stringify('Hello, ' + name); }; print(greet('World'));"
release:
needs: [setup, test, test-cross-compile-on-linux, test-cross-compile-on-mac] #, test-cross-compile-on-win]
runs-on: ubuntu-latest
if: needs.setup.outputs.DOING_RELEASE == '1'
steps:
- name: Download the Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.setup.outputs.VERSION }}
release_name: Release ${{ needs.setup.outputs.VERSION }}
draft: true
prerelease: false
- name: Upload Release Asset Windows Installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/wasmer-windows-amd64/WasmerInstaller.exe
asset_name: wasmer-windows.exe
asset_content_type: application/vnd.microsoft.portable-executable
- name: Upload Release Asset Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/wasmer-windows-amd64/wasmer.tar.gz
asset_name: wasmer-windows-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Linux amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/wasmer-linux-amd64/wasmer.tar.gz
asset_name: wasmer-linux-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Linux amd64 (musl)
id: upload-release-asset-linux-musl-amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/wasmer-linux-musl-amd64/wasmer.tar.gz
asset_name: wasmer-linux-musl-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Mac amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/wasmer-darwin-amd64/wasmer.tar.gz
asset_name: wasmer-darwin-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Mac arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/wasmer-darwin-arm64/wasmer.tar.gz
asset_name: wasmer-darwin-arm64.tar.gz
asset_content_type: application/gzip
#- name: Upload Release Asset Linux aarch64
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: artifacts/wasmer-linux-aarch64/wasmer.tar.gz
# asset_name: wasmer-linux-aarch64.tar.gz
# asset_content_type: application/gzip
audit:
name: Audit
env:
CARGO_AUDIT_VERSION: 0.16.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@master
with:
path: ${{ runner.tool_cache }}/cargo-audit
key: cargo-audit-bin-${{ env.CARGO_AUDIT_VERSION }}
- run: |
echo "'${{ runner.tool_cache }}/cargo-audit/bin'" >> $GITHUB_PATH
- run: |
cargo install cargo-audit --version ${{ env.CARGO_AUDIT_VERSION }} --root '${{ runner.tool_cache }}/cargo-audit'
cargo audit