Skip to content

Commit

Permalink
Merge pull request #278 from CosmWasm/upgrade-builders
Browse files Browse the repository at this point in the history
Upgrade builders and build setup
  • Loading branch information
webmaster128 authored Dec 15, 2021
2 parents 2d42dbd + 38517f5 commit 1277a79
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 24 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
# All checks on the codebase that can run in parallel to build_shared_library
libwasmvm_sanity:
docker:
- image: cimg/rust:1.53.0
- image: cimg/rust:1.55.0
steps:
- checkout
- run:
Expand All @@ -15,7 +15,7 @@ jobs:
command: rustup component add clippy rustfmt
- restore_cache:
keys:
- cargocache-v3-libwasmvm_sanity-rust:1.53.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.55.0-{{ checksum "libwasmvm/Cargo.lock" }}
- run:
name: Check Rust formatting
working_directory: libwasmvm
Expand Down Expand Up @@ -47,11 +47,11 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-libwasmvm_sanity-rust:1.53.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_sanity-rust:1.55.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_audit:
docker:
- image: cimg/rust:1.53.0
- image: cimg/rust:1.55.0
steps:
- checkout
- run:
Expand All @@ -64,7 +64,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-v3-libwasmvm_audit-rust:1.53.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_audit-rust:1.55.0-{{ checksum "libwasmvm/Cargo.lock" }}
- run:
name: Install cargo-audit
command: cargo install --debug cargo-audit --version 0.14.1
Expand All @@ -75,7 +75,7 @@ jobs:
- save_cache:
paths:
- ~/.cargo/registry
key: cargocache-v3-libwasmvm_audit-rust:1.53.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_audit-rust:1.55.0-{{ checksum "libwasmvm/Cargo.lock" }}

format-go:
docker:
Expand Down Expand Up @@ -133,15 +133,15 @@ jobs:

build_shared_library:
docker:
- image: cimg/rust:1.53.0
- image: cimg/rust:1.55.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.53.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.55.0-{{ checksum "libwasmvm/Cargo.lock" }}
- run:
name: Create release build of libwasmvm
command: make build-rust
Expand All @@ -158,7 +158,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-build_shared_library-rust:1.53.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-build_shared_library-rust:1.55.0-{{ checksum "libwasmvm/Cargo.lock" }}

test:
working_directory: /go/src/github.com/CosmWasm/wasmvm
Expand Down
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.PHONY: all build build-rust build-go test

BUILDERS_PREFIX := cosmwasm/go-ext-builder:0007
# Builds the Rust library libwasmvm
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0008
# Contains a full Go dev environment in order to run Go tests on the built library
ALPINE_TESTER := cosmwasm/go-ext-builder:0008-alpine

USER_ID := $(shell id -u)
USER_GROUP = $(shell id -g)

Expand Down Expand Up @@ -57,8 +61,8 @@ release-build-alpine:
cp libwasmvm/target/release/examples/libmuslc.a api/libwasmvm_muslc.a
make update-bindings
# try running go tests using this lib with muslc
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/testing -w /testing $(BUILDERS_PREFIX)-alpine go build -tags muslc .
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/testing -w /testing $(BUILDERS_PREFIX)-alpine go test -tags muslc ./api ./types
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(ALPINE_TESTER) go build -tags muslc .
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(ALPINE_TESTER) go test -tags muslc ./api ./types

# Creates a release build in a containerized build environment of the shared library for glibc Linux (.so)
release-build-linux:
Expand Down Expand Up @@ -88,11 +92,12 @@ release-build:

test-alpine: release-build-alpine
# build a go binary
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/testing -w /testing $(BUILDERS_PREFIX)-alpine go build -tags muslc -o demo ./cmd
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(BUILDERS_PREFIX)-alpine go build -tags muslc -o demo ./cmd
# run static binary in an alpine machines (not dlls)
docker run --rm --read-only -v $(shell pwd):/testing -w /testing alpine:3.14 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/testing -w /testing alpine:3.13 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/testing -w /testing alpine:3.12 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/testing -w /testing alpine:3.11 ./demo ./api/testdata/hackatom.wasm
# See https://de.wikipedia.org/wiki/Alpine_Linux#Versionen for supported versions
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.15 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.14 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.13 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.12 ./demo ./api/testdata/hackatom.wasm
# run static binary locally if you are on Linux
# ./muslc.exe ./api/testdata/hackatom.wasm
11 changes: 7 additions & 4 deletions builders/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# we build with go and rust
FROM golang:1.15-alpine3.12
# This image is used for two things (which is not ideal, but yeah):
# 1. Build the static Rust library
# 2. Execute Go tests that use and test this library
# For 2. we define the Go image here. For 1. we install Rust below.
FROM golang:1.17.5-alpine

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
Expand All @@ -15,12 +18,12 @@ RUN set -eux; \

RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init"
RUN chmod +x rustup-init
RUN ./rustup-init -y --no-modify-path --default-toolchain 1.53.0; rm rustup-init
RUN ./rustup-init -y --no-modify-path --default-toolchain 1.55.0; rm rustup-init
RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME

# needed for
# /usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
ENV LIBRARY_PATH=/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib:$LIBRARY_PATH
ENV LIBRARY_PATH=/usr/local/rustup/toolchains/1.55.0-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib:$LIBRARY_PATH

# prepare go cache dirs
RUN mkdir -p /.cache/go-build
Expand Down
2 changes: 1 addition & 1 deletion builders/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENV RUSTUP_HOME=/usr/local/rustup \
RUN url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \
wget "$url"; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --default-toolchain 1.53.0; \
./rustup-init -y --no-modify-path --default-toolchain 1.55.0; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
Expand Down
2 changes: 1 addition & 1 deletion builders/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.53.0-buster
FROM rust:1.55.0-buster

# Install build dependencies
RUN apt-get update
Expand Down
2 changes: 1 addition & 1 deletion builders/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Versioned by a simple counter that is not bound to a specific CosmWasm version
# See builders/README.md
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0007
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0008

.PHONY: docker-image-centos7
docker-image-centos7:
Expand Down
4 changes: 4 additions & 0 deletions builders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ can do the cross-compilation.

## Changelog

**Version 0008:**

- Update Rust to 1.55.0 and Go (for testing only) to 1.17.5.

**Version 0007:**

- Do not copy output from the target folder to final destination. The caller should do that.
Expand Down

0 comments on commit 1277a79

Please sign in to comment.