Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into golang-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Dec 20, 2024
2 parents fe74a1c + 6480176 commit 3662cd2
Show file tree
Hide file tree
Showing 110 changed files with 7,682 additions and 3,951 deletions.
179 changes: 131 additions & 48 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ jobs:
# All checks on the codebase that can run in parallel to build_shared_library
libwasmvm_sanity:
docker:
- image: cimg/rust:1.60.0
- image: cimg/rust:1.74.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 clippy rustfmt
command: rustup component add rustfmt
- restore_cache:
keys:
- cargocache-v3-libwasmvm_sanity-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.60.0-
- cargocache-v3-libwasmvm_sanity-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.74.0-
- run:
name: Ensure libwasmvm/bindings.h is up-to-date
working_directory: libwasmvm
Expand All @@ -39,10 +39,6 @@ jobs:
name: Check Rust formatting
working_directory: libwasmvm
command: cargo fmt -- --check
- run:
name: Run linter
working_directory: libwasmvm
command: cargo clippy --all-targets -- -D warnings
- run:
name: Run unit tests
working_directory: libwasmvm
Expand All @@ -66,7 +62,40 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-libwasmvm_sanity-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_sanity-rust:1.74.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.
Expand All @@ -84,15 +113,15 @@ jobs:
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.60.0 -y
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.74.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.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.60.0-
- cachev4-libwasmvm_sanity_windows-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.74.0-
- run:
name: Run unit tests
working_directory: libwasmvm
Expand All @@ -104,13 +133,13 @@ jobs:
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
key: cachev4-libwasmvm_sanity_windows-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cachev4-libwasmvm_sanity_windows-rust:1.74.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.65.0
- image: cimg/rust:1.81.0
steps:
- checkout
- run:
Expand All @@ -123,23 +152,23 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-v3-libwasmvm_audit-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_audit-rust:1.65.0-
- v3-libwasmvm_audit-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
- v3-libwasmvm_audit-rust:1.81.0-
- run:
name: Install cargo-audit
command: cargo install --debug cargo-audit --version 0.17.4
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: cargocache-v3-libwasmvm_audit-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: v3-libwasmvm_audit-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}

format-go:
docker:
- image: cimg/go:1.18.8
- image: cimg/go:1.21.4
steps:
- run:
name: Install gofumpt
Expand All @@ -157,7 +186,7 @@ jobs:
# Build types and cosmwam package without cgo
wasmvm_no_cgo:
docker:
- image: cimg/go:1.18.8
- image: cimg/go:1.21.4
steps:
- checkout
- run:
Expand All @@ -173,14 +202,33 @@ jobs:
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.18.8
- image: cimg/go:1.21.4
steps:
- checkout
- run:
name: Check go mod tidy
# Use --check or --exit-code when available (Go 1.19?)
# Use --check or --exit-code when available (Go 1.22?)
# https://github.com/golang/go/issues/27005
command: |
go mod tidy
Expand All @@ -193,15 +241,15 @@ jobs:
format-scripts:
docker:
- image: cimg/go:1.18.8
- image: cimg/go:1.21.4
steps:
- run:
name: Install shfmt
command: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@v3.4.0
command: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@v3.7.0
- checkout
- run:
name: Run shfmt
command: shfmt -d .
command: shfmt --diff .

lint-scripts:
docker:
Expand All @@ -219,19 +267,19 @@ jobs:

build_shared_library:
docker:
- image: cimg/rust:1.60.0
- image: cimg/rust:1.74.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.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.60.0-
- cargocache-v3-build_shared_library-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.74.0-
- run:
name: Create release build of libwasmvm
command: make build-rust
command: make build-libwasmvm
- persist_to_workspace:
root: ./internal/api
paths:
Expand All @@ -245,12 +293,12 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-build_shared_library-rust:1.60.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-build_shared_library-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}

# Test the Go project
# Test the Go project and run benchmarks
wasmvm_test:
docker:
- image: cimg/go:1.18.8
- image: cimg/go:1.21.4
environment:
GORACE: "halt_on_error=1"
BUILD_VERSION: $(echo ${CIRCLE_SHA1} | cut -c 1-10)
Expand All @@ -261,13 +309,25 @@ jobs:
- run:
name: Copy .so build
command: cp /tmp/builds/libwasmvm.x86_64.so ./internal/api
# Debugging step to better understand what is linked here
- run:
name: Check .so files
command: |
ls -lA ./internal/api/libwasmvm.*.so
sha256sum ./internal/api/libwasmvm.*.so
ldd ./internal/api/libwasmvm.x86_64.so
- 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: make build-go
- run:
name: Go benchmarks
command: make bench

test_alpine_build:
machine:
Expand Down Expand Up @@ -338,47 +398,68 @@ jobs:
- 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
- run:
name: Collect artifacts
command: |
mkdir artifacts
cp ./internal/api/libwasmvm_muslc.a artifacts/libwasmvm_muslc.x86_64.a
cp ./internal/api/libwasmvm_muslc.aarch64.a artifacts/libwasmvm_muslc.aarch64.a
- run:
name: Create checksums
working_directory: artifacts
command: sha256sum * > checksums.txt && cat checksums.txt
- store_artifacts:
path: artifacts
# Deploy to GitHub releases on tag builds
# 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
- libwasmvm_sanity_windows
# 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.74.0", "1.80.0"]
- libwasmvm_audit
- format-go
- wasmvm_no_cgo
- nolink_libwasmvm
- tidy-go
- format-scripts
- lint-scripts
Expand Down Expand Up @@ -412,7 +493,8 @@ workflows:
only:
# long living branches
- main
- 0.14-dev
# Development
- GoIter-creation
# Run only on main, not on tags (auto-build on merge PR)
- deploy_to_git:
requires:
Expand All @@ -429,3 +511,4 @@ workflows:
branches:
only:
- main
- /^release\/.*/
Loading

0 comments on commit 3662cd2

Please sign in to comment.