Skip to content

Commit 3662cd2

Browse files
committed
Merge remote-tracking branch 'upstream/main' into golang-ci
2 parents fe74a1c + 6480176 commit 3662cd2

File tree

110 files changed

+7682
-3951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+7682
-3951
lines changed

.circleci/config.yml

+131-48
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ jobs:
77
# All checks on the codebase that can run in parallel to build_shared_library
88
libwasmvm_sanity:
99
docker:
10-
- image: cimg/rust:1.60.0
10+
- image: cimg/rust:1.74.0
1111
steps:
1212
- checkout
1313
- run:
1414
name: Show Rust version information
1515
command: rustc --version; cargo --version; rustup --version
1616
- run:
1717
name: Add Rust components
18-
command: rustup component add clippy rustfmt
18+
command: rustup component add rustfmt
1919
- restore_cache:
2020
keys:
21-
- cargocache-v3-libwasmvm_sanity-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
22-
- cargocache-v3-libwasmvm_sanity-rust:1.60.0-
21+
- cargocache-v3-libwasmvm_sanity-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
22+
- cargocache-v3-libwasmvm_sanity-rust:1.74.0-
2323
- run:
2424
name: Ensure libwasmvm/bindings.h is up-to-date
2525
working_directory: libwasmvm
@@ -39,10 +39,6 @@ jobs:
3939
name: Check Rust formatting
4040
working_directory: libwasmvm
4141
command: cargo fmt -- --check
42-
- run:
43-
name: Run linter
44-
working_directory: libwasmvm
45-
command: cargo clippy --all-targets -- -D warnings
4642
- run:
4743
name: Run unit tests
4844
working_directory: libwasmvm
@@ -66,7 +62,40 @@ jobs:
6662
- libwasmvm/target/release/.fingerprint
6763
- libwasmvm/target/release/build
6864
- libwasmvm/target/release/deps
69-
key: cargocache-v3-libwasmvm_sanity-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
65+
key: cargocache-v3-libwasmvm_sanity-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
66+
67+
libwasmvm_clippy:
68+
parameters:
69+
rust-version:
70+
type: string
71+
docker:
72+
- image: rust:<< parameters.rust-version >>
73+
steps:
74+
- checkout
75+
- run:
76+
name: Version information
77+
command: rustc --version && cargo --version
78+
- restore_cache:
79+
keys:
80+
- v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-{{ checksum "libwasmvm/Cargo.lock" }}
81+
- v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-
82+
- run:
83+
name: Add clippy component
84+
command: rustup component add clippy
85+
- run:
86+
name: Run clippy
87+
working_directory: libwasmvm
88+
command: cargo clippy --all-targets -- -D warnings
89+
- save_cache:
90+
paths:
91+
- ~/.cargo/registry
92+
- libwasmvm/target/debug/.fingerprint
93+
- libwasmvm/target/debug/build
94+
- libwasmvm/target/debug/deps
95+
- libwasmvm/target/release/.fingerprint
96+
- libwasmvm/target/release/build
97+
- libwasmvm/target/release/deps
98+
key: v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-{{ checksum "libwasmvm/Cargo.lock" }}
7099

71100
# This performs all the Rust debug builds on Windows. Similar to libwasmvm_sanity
72101
# but avoids duplicating things that are not platform dependent.
@@ -84,15 +113,15 @@ jobs:
84113
command: |
85114
set -o errexit
86115
curl -sS --output rustup-init.exe https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
87-
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.60.0 -y
116+
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.74.0 -y
88117
echo 'export PATH="$PATH;$USERPROFILE/.cargo/bin"' >> "$BASH_ENV"
89118
- run:
90119
name: Show Rust version information
91120
command: rustc --version; cargo --version; rustup --version
92121
- restore_cache:
93122
keys:
94-
- cachev4-libwasmvm_sanity_windows-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
95-
- cachev4-libwasmvm_sanity_windows-rust:1.60.0-
123+
- cachev4-libwasmvm_sanity_windows-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
124+
- cachev4-libwasmvm_sanity_windows-rust:1.74.0-
96125
- run:
97126
name: Run unit tests
98127
working_directory: libwasmvm
@@ -104,13 +133,13 @@ jobs:
104133
- libwasmvm/target/debug/.fingerprint
105134
- libwasmvm/target/debug/build
106135
- libwasmvm/target/debug/deps
107-
key: cachev4-libwasmvm_sanity_windows-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
136+
key: cachev4-libwasmvm_sanity_windows-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
108137

109138
libwasmvm_audit:
110139
docker:
111140
# The audit tool might use a more modern Rust version than the build jobs. See
112141
# "Tooling Rust compiler" in docs/COMPILER_VERSIONS.md
113-
- image: cimg/rust:1.65.0
142+
- image: cimg/rust:1.81.0
114143
steps:
115144
- checkout
116145
- run:
@@ -123,23 +152,23 @@ jobs:
123152
command: rustc --version; cargo --version; rustup --version
124153
- restore_cache:
125154
keys:
126-
- cargocache-v3-libwasmvm_audit-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
127-
- cargocache-v3-libwasmvm_audit-rust:1.65.0-
155+
- v3-libwasmvm_audit-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
156+
- v3-libwasmvm_audit-rust:1.81.0-
128157
- run:
129158
name: Install cargo-audit
130-
command: cargo install --debug cargo-audit --version 0.17.4
159+
command: cargo install --debug cargo-audit --version 0.17.6
131160
- run:
132161
name: Run cargo-audit
133162
working_directory: libwasmvm
134163
command: cargo audit
135164
- save_cache:
136165
paths:
137166
- ~/.cargo/registry
138-
key: cargocache-v3-libwasmvm_audit-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
167+
key: v3-libwasmvm_audit-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
139168

140169
format-go:
141170
docker:
142-
- image: cimg/go:1.18.8
171+
- image: cimg/go:1.21.4
143172
steps:
144173
- run:
145174
name: Install gofumpt
@@ -157,7 +186,7 @@ jobs:
157186
# Build types and cosmwam package without cgo
158187
wasmvm_no_cgo:
159188
docker:
160-
- image: cimg/go:1.18.8
189+
- image: cimg/go:1.21.4
161190
steps:
162191
- checkout
163192
- run:
@@ -173,14 +202,33 @@ jobs:
173202
name: Test package "cosmwasm" without cgo
174203
command: CGO_ENABLED=0 go test .
175204

205+
# Build types and cosmwasm with libwasmvm linking disabled
206+
nolink_libwasmvm:
207+
docker:
208+
- image: cimg/go:1.21.4
209+
steps:
210+
- checkout
211+
- run:
212+
name: Build package "types" with libwasmvm linking disabled
213+
command: go build -tags "nolink_libwasmvm" ./types
214+
- run:
215+
name: Build package "cosmwasm" with libwasmvm linking disabled
216+
command: go build -tags "nolink_libwasmvm" .
217+
- run:
218+
name: Test package "types" with libwasmvm linking disabled
219+
command: go test -tags "nolink_libwasmvm" ./types
220+
- run:
221+
name: Test package "cosmwasm" with libwasmvm linking disabled
222+
command: go test -tags "nolink_libwasmvm" .
223+
176224
tidy-go:
177225
docker:
178-
- image: cimg/go:1.18.8
226+
- image: cimg/go:1.21.4
179227
steps:
180228
- checkout
181229
- run:
182230
name: Check go mod tidy
183-
# Use --check or --exit-code when available (Go 1.19?)
231+
# Use --check or --exit-code when available (Go 1.22?)
184232
# https://github.com/golang/go/issues/27005
185233
command: |
186234
go mod tidy
@@ -193,15 +241,15 @@ jobs:
193241
194242
format-scripts:
195243
docker:
196-
- image: cimg/go:1.18.8
244+
- image: cimg/go:1.21.4
197245
steps:
198246
- run:
199247
name: Install shfmt
200-
command: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@v3.4.0
248+
command: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@v3.7.0
201249
- checkout
202250
- run:
203251
name: Run shfmt
204-
command: shfmt -d .
252+
command: shfmt --diff .
205253

206254
lint-scripts:
207255
docker:
@@ -219,19 +267,19 @@ jobs:
219267

220268
build_shared_library:
221269
docker:
222-
- image: cimg/rust:1.60.0
270+
- image: cimg/rust:1.74.0
223271
steps:
224272
- checkout
225273
- run:
226274
name: Show version information
227275
command: rustc --version; cargo --version; rustup --version
228276
- restore_cache:
229277
keys:
230-
- cargocache-v3-build_shared_library-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
231-
- cargocache-v3-build_shared_library-rust:1.60.0-
278+
- cargocache-v3-build_shared_library-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
279+
- cargocache-v3-build_shared_library-rust:1.74.0-
232280
- run:
233281
name: Create release build of libwasmvm
234-
command: make build-rust
282+
command: make build-libwasmvm
235283
- persist_to_workspace:
236284
root: ./internal/api
237285
paths:
@@ -245,12 +293,12 @@ jobs:
245293
- libwasmvm/target/release/.fingerprint
246294
- libwasmvm/target/release/build
247295
- libwasmvm/target/release/deps
248-
key: cargocache-v3-build_shared_library-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
296+
key: cargocache-v3-build_shared_library-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
249297

250-
# Test the Go project
298+
# Test the Go project and run benchmarks
251299
wasmvm_test:
252300
docker:
253-
- image: cimg/go:1.18.8
301+
- image: cimg/go:1.21.4
254302
environment:
255303
GORACE: "halt_on_error=1"
256304
BUILD_VERSION: $(echo ${CIRCLE_SHA1} | cut -c 1-10)
@@ -261,13 +309,25 @@ jobs:
261309
- run:
262310
name: Copy .so build
263311
command: cp /tmp/builds/libwasmvm.x86_64.so ./internal/api
312+
# Debugging step to better understand what is linked here
313+
- run:
314+
name: Check .so files
315+
command: |
316+
ls -lA ./internal/api/libwasmvm.*.so
317+
sha256sum ./internal/api/libwasmvm.*.so
318+
ldd ./internal/api/libwasmvm.x86_64.so
319+
- run:
320+
name: Build Go project
321+
command: make build-go
264322
- run:
265323
name: Go integration tests
266324
command: make test
267325
- run:
268326
name: Go tests with cgo and race condition safety checks
269327
command: make test-safety
270-
- run: make build-go
328+
- run:
329+
name: Go benchmarks
330+
command: make bench
271331

272332
test_alpine_build:
273333
machine:
@@ -338,47 +398,68 @@ jobs:
338398
- run:
339399
name: Build static library for Alpine
340400
command: make release-build-alpine
401+
- run:
402+
name: Build static library for MacOS
403+
command: make release-build-macos-static
341404
- run:
342405
name: Debug build results
343406
command: ls -l ./internal/api
344-
- run:
345-
name: Collect artifacts
346-
command: |
347-
mkdir artifacts
348-
cp ./internal/api/libwasmvm_muslc.a artifacts/libwasmvm_muslc.x86_64.a
349-
cp ./internal/api/libwasmvm_muslc.aarch64.a artifacts/libwasmvm_muslc.aarch64.a
350-
- run:
351-
name: Create checksums
352-
working_directory: artifacts
353-
command: sha256sum * > checksums.txt && cat checksums.txt
354-
- store_artifacts:
355-
path: artifacts
356-
# Deploy to GitHub releases on tag builds
407+
# Deploy to GitHub releases on tag builds. At some point we might want to extract
408+
# those steps into a separate job for better maintainability.
357409
- when:
358410
condition: << pipeline.git.tag >>
359411
steps:
412+
- run:
413+
name: Collect artifacts
414+
command: |
415+
mkdir artifacts
416+
417+
# Static (from build)
418+
cp ./internal/api/libwasmvm_muslc.x86_64.a artifacts/
419+
cp ./internal/api/libwasmvm_muslc.aarch64.a artifacts/
420+
cp ./internal/api/libwasmvmstatic_darwin.a artifacts/
421+
422+
# Shared (from git)
423+
cp ./internal/api/libwasmvm.aarch64.so artifacts/
424+
cp ./internal/api/libwasmvm.x86_64.so artifacts/
425+
cp ./internal/api/libwasmvm.dylib artifacts/
426+
- run:
427+
name: Create checksums
428+
working_directory: artifacts
429+
command: sha256sum * > checksums.txt && cat checksums.txt
360430
- run:
361431
name: Publish artifacts on GitHub
362432
command: |
363433
TAG="$CIRCLE_TAG"
364434
TITLE="$TAG"
365435
BODY="Build artifacts generated at this tag."
436+
# Check if tag is a version without suffix (e.g. -rc or -beta) and
437+
# set prerelease flag accordingly
438+
[[ "$TAG" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]] || PRERELEASE=-prerelease
366439
ghr -t "$GITHUB_TOKEN" \
367440
-u "$CIRCLE_PROJECT_USERNAME" -r "$CIRCLE_PROJECT_REPONAME" \
368441
-c "$CIRCLE_SHA1" \
369442
-n "$TITLE" -b "$BODY" \
370443
-delete \
444+
$PRERELEASE \
371445
"$TAG" ./artifacts/
372446
373447
workflows:
374448
version: 2
375449
build_and_test:
376450
jobs:
377451
- libwasmvm_sanity
378-
- libwasmvm_sanity_windows
452+
# Temporarily disabled. This check is still running on main.
453+
# - libwasmvm_sanity_windows
454+
- libwasmvm_clippy:
455+
matrix:
456+
parameters:
457+
# Run with MSRV and some modern stable Rust
458+
rust-version: ["1.74.0", "1.80.0"]
379459
- libwasmvm_audit
380460
- format-go
381461
- wasmvm_no_cgo
462+
- nolink_libwasmvm
382463
- tidy-go
383464
- format-scripts
384465
- lint-scripts
@@ -412,7 +493,8 @@ workflows:
412493
only:
413494
# long living branches
414495
- main
415-
- 0.14-dev
496+
# Development
497+
- GoIter-creation
416498
# Run only on main, not on tags (auto-build on merge PR)
417499
- deploy_to_git:
418500
requires:
@@ -429,3 +511,4 @@ workflows:
429511
branches:
430512
only:
431513
- main
514+
- /^release\/.*/

0 commit comments

Comments
 (0)