/
config.yml
507 lines (488 loc) · 17 KB
/
config.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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
version: 2.1
orbs:
win: circleci/windows@5.0
jobs:
# All checks on the codebase that can run in parallel to build_shared_library
libwasmvm_sanity:
docker:
- image: cimg/rust:1.73.0
steps:
- checkout
- run:
name: Show Rust version information
command: rustc --version; cargo --version; rustup --version
- run:
name: Add Rust components
command: rustup component add rustfmt
- restore_cache:
keys:
- cargocache-v3-libwasmvm_sanity-rust:1.73.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.73.0-
- run:
name: Ensure libwasmvm/bindings.h is up-to-date
working_directory: libwasmvm
command: |
cargo check
CHANGES_IN_REPO=$(git status --porcelain bindings.h)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
- run:
# It is easy to update libwasmvm/bindings.h as part of the development but forget `make update-bindings`
name: Ensure internal/api/bindings.h is up to date
command: diff libwasmvm/bindings.h internal/api/bindings.h
- run:
name: Check Rust formatting
working_directory: libwasmvm
command: cargo fmt -- --check
- run:
name: Run unit tests
working_directory: libwasmvm
command: cargo test
- run:
name: Build docs
working_directory: libwasmvm
command: cargo doc --no-deps
- run:
name: Test docs
working_directory: libwasmvm
command: |
sed -i '/^crate-type = \["cdylib"\]/d' Cargo.toml
cargo test --doc
- save_cache:
paths:
- ~/.cargo/registry
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-libwasmvm_sanity-rust:1.73.0-{{ checksum "libwasmvm/Cargo.lock" }}
libwasmvm_clippy:
parameters:
rust-version:
type: string
docker:
- image: rust:<< parameters.rust-version >>
steps:
- checkout
- run:
name: Version information
command: rustc --version && cargo --version
- restore_cache:
keys:
- v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-{{ checksum "libwasmvm/Cargo.lock" }}
- v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-
- run:
name: Add clippy component
command: rustup component add clippy
- run:
name: Run clippy
working_directory: libwasmvm
command: cargo clippy --all-targets -- -D warnings
- save_cache:
paths:
- ~/.cargo/registry
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-{{ checksum "libwasmvm/Cargo.lock" }}
# This performs all the Rust debug builds on Windows. Similar to libwasmvm_sanity
# but avoids duplicating things that are not platform dependent.
libwasmvm_sanity_windows:
executor:
name: win/default
shell: bash.exe
steps:
- checkout
- run:
name: Reset git config set by CircleCI to make Cargo work
command: git config --global --unset url.ssh://git@github.com.insteadof
- run:
name: Install Rust
command: |
set -o errexit
curl -sS --output rustup-init.exe https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.73.0 -y
echo 'export PATH="$PATH;$USERPROFILE/.cargo/bin"' >> "$BASH_ENV"
- run:
name: Show Rust version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cachev4-libwasmvm_sanity_windows-rust:1.73.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.73.0-
- run:
name: Run unit tests
working_directory: libwasmvm
command: cargo test
- save_cache:
paths:
# ".." is the easiest way to get $HOME here (pwd is $HOME\project)
- ../.cargo/registry
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
key: cachev4-libwasmvm_sanity_windows-rust:1.73.0-{{ checksum "libwasmvm/Cargo.lock" }}
libwasmvm_audit:
docker:
# The audit tool might use a more modern Rust version than the build jobs. See
# "Tooling Rust compiler" in docs/COMPILER_VERSIONS.md
- image: cimg/rust:1.75.0
steps:
- checkout
- run:
name: Install OpenSSL
command: |
sudo apt update
sudo apt install libssl-dev
- run:
name: Show Rust version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- v3-libwasmvm_audit-rust:1.75.0-{{ checksum "libwasmvm/Cargo.lock" }}
- v3-libwasmvm_audit-rust:1.75.0-
- run:
name: Install cargo-audit
command: cargo install --debug cargo-audit --version 0.17.6
- run:
name: Run cargo-audit
working_directory: libwasmvm
command: cargo audit
- save_cache:
paths:
- ~/.cargo/registry
key: v3-libwasmvm_audit-rust:1.75.0-{{ checksum "libwasmvm/Cargo.lock" }}
format-go:
docker:
- image: cimg/go:1.21.4
steps:
- run:
name: Install gofumpt
command: go install mvdan.cc/gofumpt@v0.4.0
- checkout
- run:
name: Check Go formatting with gofmt
command: |
[ "$(gofmt -l .)" = "" ] || (gofmt -d . && exit 1)
- run:
name: Check Go formatting with gofumpt
command: |
[ "$(gofumpt -l .)" = "" ] || (gofumpt -d . && exit 1)
# Build types and cosmwam package without cgo
wasmvm_no_cgo:
docker:
- image: cimg/go:1.21.4
steps:
- checkout
- run:
name: Build package "types" without cgo
command: CGO_ENABLED=0 go build ./types
- run:
name: Build package "cosmwasm" without cgo
command: CGO_ENABLED=0 go build .
- run:
name: Test package "types" without cgo
command: CGO_ENABLED=0 go test ./types
- run:
name: Test package "cosmwasm" without cgo
command: CGO_ENABLED=0 go test .
# Build types and cosmwasm with libwasmvm linking disabled
nolink_libwasmvm:
docker:
- image: cimg/go:1.21.4
steps:
- checkout
- run:
name: Build package "types" with libwasmvm linking disabled
command: go build -tags "nolink_libwasmvm" ./types
- run:
name: Build package "cosmwasm" with libwasmvm linking disabled
command: go build -tags "nolink_libwasmvm" .
- run:
name: Test package "types" with libwasmvm linking disabled
command: go test -tags "nolink_libwasmvm" ./types
- run:
name: Test package "cosmwasm" with libwasmvm linking disabled
command: go test -tags "nolink_libwasmvm" .
tidy-go:
docker:
- image: cimg/go:1.21.4
steps:
- checkout
- run:
name: Check go mod tidy
# Use --check or --exit-code when available (Go 1.22?)
# https://github.com/golang/go/issues/27005
command: |
go mod tidy
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
format-scripts:
docker:
- image: cimg/go:1.21.4
steps:
- run:
name: Install shfmt
command: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@v3.7.0
- checkout
- run:
name: Run shfmt
command: shfmt --diff .
lint-scripts:
docker:
- image: ubuntu:20.04
steps:
- run:
name: Install packages
command: |
apt update
apt install -y git shellcheck
- checkout
- run:
name: Run shellcheck
command: find . -name "*.sh" -exec shellcheck {} +
build_shared_library:
docker:
- image: cimg/rust:1.73.0
steps:
- checkout
- run:
name: Show version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-v3-build_shared_library-rust:1.73.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.73.0-
- run:
name: Create release build of libwasmvm
command: make build-rust
- persist_to_workspace:
root: ./internal/api
paths:
- libwasmvm.x86_64.so
- save_cache:
paths:
- ~/.cargo/registry
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-build_shared_library-rust:1.73.0-{{ checksum "libwasmvm/Cargo.lock" }}
# Test the Go project and run benchmarks
wasmvm_test:
docker:
- image: cimg/go:1.21.4
environment:
GORACE: "halt_on_error=1"
BUILD_VERSION: $(echo ${CIRCLE_SHA1} | cut -c 1-10)
steps:
- checkout
- attach_workspace:
at: /tmp/builds
- run:
name: Copy .so build
command: cp /tmp/builds/libwasmvm.x86_64.so ./internal/api
- run:
name: Build Go project
command: make build-go
- run:
name: Go integration tests
command: make test
- run:
name: Go tests with cgo and race condition safety checks
command: make test-safety
- run:
name: Go benchmarks
command: make bench
test_alpine_build:
machine:
image: ubuntu-2004:2022.10.1
steps:
- checkout
- run: make test-alpine
- run:
name: Debug build results
command: ls -l ./internal/api
deploy_to_git:
machine:
image: ubuntu-2004:2022.10.1
resource_class: xlarge
steps:
- add_ssh_keys:
fingerprints:
# Custom read/write deployment key with private key stored on CircleCI
# (see https://app.circleci.com/settings/project/github/CosmWasm/wasmvm/ssh and https://github.com/CosmWasm/wasmvm/settings/keys)
- "31:de:e5:84:1b:12:81:94:aa:06:50:c0:cb:bd:79:f0"
- checkout
- run:
name: Build shared library for Linux
command: make release-build-linux
- run:
name: Build shared library for macOS
command: make release-build-macos
# Shared libraries for Windows (.dll) currently do not work (https://github.com/CosmWasm/wasmvm/issues/389)
# and .dll builds are not deterministic.
# Deactivating this step to avoid polluting the git hostory.
#
# - run:
# name: Build shared library for Windows
# command: make release-build-windows
- run:
name: Debug build results
command: ls -l ./internal/api
- run:
name: Configure git user
# This is not a GitHub user and no permissions can be configured other than "push access", which
# we can configure for Deploy keys at https://github.com/CosmWasm/wasmvm/settings/keys
command: |
git config user.email "wasmvm@circleci.confio.example.com"
git config user.name "Deployer"
- run:
name: Check-in and push new libraries
command: |
git status
git add ./internal/api
git commit --allow-empty -m '[skip ci] Built release libraries'
git push origin $CIRCLE_BRANCH
build_static_lib:
machine:
image: ubuntu-2004:2022.10.1
resource_class: xlarge
steps:
- run:
name: Check Go version # needed for ghr installation
command: go version
- run:
name: Install ghr
command: |
go install github.com/tcnksm/ghr@v0.16.0
ghr --version
- checkout
- run:
name: Build static library for Alpine
command: make release-build-alpine
- run:
name: Build static library for MacOS
command: make release-build-macos-static
- run:
name: Debug build results
command: ls -l ./internal/api
# Deploy to GitHub releases on tag builds. At some point we might want to extract
# those steps into a separate job for better maintainability.
- when:
condition: << pipeline.git.tag >>
steps:
- run:
name: Collect artifacts
command: |
mkdir artifacts
# Static (from build)
cp ./internal/api/libwasmvm_muslc.x86_64.a artifacts/
cp ./internal/api/libwasmvm_muslc.aarch64.a artifacts/
cp ./internal/api/libwasmvmstatic_darwin.a artifacts/
# Shared (from git)
cp ./internal/api/libwasmvm.aarch64.so artifacts/
cp ./internal/api/libwasmvm.x86_64.so artifacts/
cp ./internal/api/libwasmvm.dylib artifacts/
- run:
name: Create checksums
working_directory: artifacts
command: sha256sum * > checksums.txt && cat checksums.txt
- run:
name: Publish artifacts on GitHub
command: |
TAG="$CIRCLE_TAG"
TITLE="$TAG"
BODY="Build artifacts generated at this tag."
# Check if tag is a version without suffix (e.g. -rc or -beta) and
# set prerelease flag accordingly
[[ "$TAG" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]] || PRERELEASE=-prerelease
ghr -t "$GITHUB_TOKEN" \
-u "$CIRCLE_PROJECT_USERNAME" -r "$CIRCLE_PROJECT_REPONAME" \
-c "$CIRCLE_SHA1" \
-n "$TITLE" -b "$BODY" \
-delete \
$PRERELEASE \
"$TAG" ./artifacts/
workflows:
version: 2
build_and_test:
jobs:
- libwasmvm_sanity
# Temporarily disabled. This check is still running on main.
# - libwasmvm_sanity_windows
- libwasmvm_clippy:
matrix:
parameters:
# Run with MSRV and some modern stable Rust
rust-version: ["1.73.0", "1.75.0"]
- libwasmvm_audit
- format-go
- wasmvm_no_cgo
- nolink_libwasmvm
- tidy-go
- format-scripts
- lint-scripts
- build_shared_library:
filters: # required since other jobs with tag filters require this one
tags:
only: /.*/
- wasmvm_test:
requires:
- build_shared_library
- build_static_lib:
requires:
- build_shared_library
filters:
# tags and branches are OR combined
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/
branches:
only:
# long living branches
- main
- 0.14-dev
# This is long running, so only double-check on merge commits
# ensures that all code works on alpine linux
- test_alpine_build:
filters:
tags:
ignore:
- /.*/
branches:
only:
# long living branches
- main
# Development
- GoIter-creation
# Run only on main, not on tags (auto-build on merge PR)
- deploy_to_git:
requires:
- libwasmvm_sanity
- format-go
- tidy-go
- format-scripts
- lint-scripts
- wasmvm_test
filters:
tags:
ignore:
- /.*/
branches:
only:
- main
- /^release\/.*/