This repository has been archived by the owner on Jun 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
386 lines (381 loc) · 14.7 KB
/
main.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
name: tests and release builds
env:
RUST_BACKTRACE: 1
on:
workflow_dispatch:
inputs:
release:
description: 'Make release'
push:
branches:
- 'master'
- '**'
tags:
# this is _not_ a regex, see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- 'v[0-9]+.[0-9]+.[0-9]+*'
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 'v[0-9]\+\.[0-9]\+\.[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:
build: [linux, macos-x86_64, macos-aarch64, windows]
include:
- build: linux
os: ubuntu-latest
rust: stable
artifact_name: 'wapm-linux-amd64'
- build: macos-x86_64
os: macos-latest
rust: stable
target: x86_64-apple-darwin
artifact_name: 'wapm-darwin-amd64'
- build: macos-aarch64
os: macos-latest
rust: stable
target: aarch64-apple-darwin
artifact_name: 'wapm-darwin-aarch64'
- build: windows
os: windows-latest
rust: stable
artifact_name: 'wapm-windows-amd64'
#- build: linux-musl-x64
# os: ubuntu-latest
# container: alpine:latest
# rust: stable
# artifact_name: 'wapm-linux-musl-amd64'
# env:
# CARGO_SCCACHE_VERSION: 0.2.10
# SCCACHE_AZURE_BLOB_CONTAINER: ${{ secrets.SCCACHE_AZURE_BLOB_CONTAINER }}
# SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
steps:
- uses: actions/checkout@v2
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Configure cargo data directory
# After this point, all cargo registry and crate data is stored in
# $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files
# that are needed during the build process. Additionally, this works
# around a bug in the 'cache' action that causes directories outside of
# the workspace dir to be saved/restored incorrectly.
run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
# - name: Install sccache
# run: |
# echo "::add-path::${{ runner.tool_cache }}/cargo-sccache/bin"
# cargo install sccache --version ${{ env.CARGO_SCCACHE_VERSION }} --root ${{ runner.tool_cache }}/cargo-sccache
# - name: Start sccache
# run: |
# ${{ runner.tool_cache }}/cargo-sccache/bin/sccache --start-server
# ${{ runner.tool_cache }}/cargo-sccache/bin/sscache -s
# echo "::set-env name=RUSTC_WRAPPER::${{ runner.tool_cache }}/cargo-sccache/bin/sccache"
- name: Setup Rust target
if: matrix.target
run: |
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[build]
target = "${{ matrix.target }}"
EOF
#- 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++ libxkbcommon-dev wayland-dev
- name: Install Cmake (Windows)
if: matrix.os == 'windows-latest'
run: choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
- name: Install cmake (macOS)
if: matrix.target == 'x86_64-apple-darwin'
shell: bash
run: |
set -ex
curl -O https://cmake.org/files/v3.4/cmake-3.4.1-Darwin-x86_64.tar.gz
tar xf cmake-3.4.1-Darwin-x86_64.tar.gz
export CMAKE_BIN_PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin"
export PATH=$CMAKE_BIN_PATH:$PATH
- name: Install cmake (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
curl -O https://cmake.org/files/v3.4/cmake-3.4.1-Linux-x86_64.tar.gz
tar xf cmake-3.4.1-Linux-x86_64.tar.gz
export CMAKE_BIN_PATH="`pwd`/cmake-3.4.1-Linux-x86_64/CMake.app/Contents/bin"
export PATH=$CMAKE_BIN_PATH:$PATH
- name: Tests
if: matrix.target != 'aarch64-apple-darwin'
run: |
cargo test --verbose --features "update-notifications" -- --test-threads=1
- name: Integration Tests
if: matrix.target != 'aarch64-apple-darwin'
run: |
make integration-tests
- name: Tests (Wasm Interface)
if: matrix.target != 'aarch64-apple-darwin'
run: |
cargo test --manifest-path lib/wasm-interface/Cargo.toml
- name: Check
if: matrix.target != 'aarch64-apple-darwin'
run: |
cargo check --features "telemetry update-notifications"
- name: Build binary
run: |
make release
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifact_name }}
path: dist/wapm-cli.tar.gz
if-no-files-found: error
retention-days: 3
# - name: Cache
# uses: actions/cache@master
# with:
# # Note: crates from the git repo always get rebuilt
# # so we cache only those subdirectories of target/{debug|release} that
# # contain the build output for crates that come from the registry.
# path: |-
# .cargo_home
# target/*/.*
# target/*/build
# target/*/deps
# key: ${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }}
# restore-keys: |
# ${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }}
- name: Release wapm-toml to crates.io
if: (needs.setup.outputs.DOING_RELEASE == '1' || github.event.inputs.release != '') && matrix.os == 'ubuntu-latest'
continue-on-error: true
run: |
cargo publish --allow-dirty --manifest-path="wapm-toml/Cargo.toml" --token ${{ secrets.CRATES_IO_TOKEN }}
- name: Release to crates.io
if: (needs.setup.outputs.DOING_RELEASE == '1' || github.event.inputs.release != '') && matrix.os == 'ubuntu-latest'
continue-on-error: true
run: |
cargo publish --allow-dirty --token ${{ secrets.CRATES_IO_TOKEN }}
regression_tests:
strategy:
fail-fast: false
needs: [setup, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Wasmer
run: |
curl https://get.wasmer.io -sSfL | sh
- name: Download the Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Set up for tests
run: |
rm -f /home/runner/.wasmer/bin/wapm
tar -xzf `pwd`/artifacts/wapm-linux-amd64/wapm-cli.tar.gz
cp ./bin/wapm /home/runner/.wasmer/bin/wapm
chmod +x /home/runner/.wasmer/bin/wapm
- name: 'Regression test: multi-part-uploading works'
shell: bash
run: |
chmod +x end-to-end-tests/ci/chunked-upload.sh
./end-to-end-tests/ci/chunked-upload.sh
env:
WAPM_DEV_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }}
WAPM_DEV_USERNAME: ${{ secrets.WAPM_DEV_USERNAME }}
- name: 'Regression test: direct execution works'
shell: bash
run: |
chmod +x end-to-end-tests/ci/direct-execution.sh
./end-to-end-tests/ci/direct-execution.sh
- name: 'Regression test: Install, Uninstall, Run, and List'
shell: bash
run: |
chmod +x end-to-end-tests/ci/install.sh
./end-to-end-tests/ci/install.sh
- name: 'Regression test: verification and public key management'
shell: bash
run: |
chmod +x end-to-end-tests/ci/verification.sh
./end-to-end-tests/ci/verification.sh
# - name: 'Regression test: pkg_fs works globally and when installed locally'
# shell: bash
# run: |
# chmod +x end-to-end-tests/ci/package-fs-mapping.sh
# ./end-to-end-tests/ci/package-fs-mapping.sh
- name: 'Regression test: manifest validation rejects invalid manifests'
shell: bash
run: |
chmod +x end-to-end-tests/ci/manifest-validation.sh
./end-to-end-tests/ci/manifest-validation.sh
- name: 'Regression test: package fs and command rename'
shell: bash
run: |
chmod +x end-to-end-tests/ci/validate-global.sh
./end-to-end-tests/ci/validate-global.sh
- name: 'Regression test: Init a Manifest and Add some dependencies'
shell: bash
run: |
chmod +x end-to-end-tests/ci/init-and-add.sh
./end-to-end-tests/ci/init-and-add.sh
env:
WAPM_DEV_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }}
WAPM_DEV_USERNAME: ${{ secrets.WAPM_DEV_USERNAME }}
linux_aarch64:
name: Linux aarch64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.59
target: aarch64-unknown-linux-gnu
- name: Build cross image
run: |
docker build -t wasmer/aarch64 ${GITHUB_WORKSPACE}/.github/cross-linux-aarch64/
env:
CROSS_DOCKER_IN_DOCKER: true
- name: Build wapm binary
run: |
make release
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/aarch64 cross
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: --target aarch64-unknown-linux-gnu
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
TARGET: aarch64-unknown-linux-gnu
TARGET_DIR: target/aarch64-unknown-linux-gnu/release
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: 'wapm-linux-aarch64'
path: dist/wapm-cli.tar.gz
if-no-files-found: error
retention-days: 2
release:
needs: [setup, test, linux_aarch64] #, regression_tests]
runs-on: ubuntu-latest
if: needs.setup.outputs.DOING_RELEASE == '1' || github.event.inputs.release != ''
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
id: upload-release-asset-windows-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/wapm-windows-amd64/wapm-cli.tar.gz
asset_name: wapm-cli-windows-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Linux amd64
id: 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/wapm-linux-amd64/wapm-cli.tar.gz
asset_name: wapm-cli-linux-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Linux aarch64
id: 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/wapm-linux-aarch64/wapm-cli.tar.gz
asset_name: wapm-cli-linux-aarch64.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/wapm-linux-musl-amd64/wapm-cli.tar.gz
# asset_name: wapm-cli-linux-musl-amd64.tar.gz
# asset_content_type: application/gzip
- name: Upload Release Asset Mac amd64
id: upload-release-asset-mac-darwin-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/wapm-darwin-amd64/wapm-cli.tar.gz
asset_name: wapm-cli-darwin-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Mac aarch64
id: upload-release-asset-mac-darwin-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/wapm-darwin-aarch64/wapm-cli.tar.gz
asset_name: wapm-cli-darwin-aarch64.tar.gz
asset_content_type: application/gzip
lints:
name: Linting and Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Rust Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/
target/
key: ${{ runner.os }}-cargo-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Check Formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --verbose --check
- name: Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --verbose -- -D warnings