Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add release job #71

Merged
merged 10 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/builds_and_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ jobs:
name: libwasmvm
path: ./api/libwasmvm.x86_64.so

build_static_lib:
runs-on: ubuntu-latest
steps:
- name: set up
uses: actions/[email protected]
with:
go-version: 1.18
id: go
- name: Checkout
uses: actions/checkout@v2
- name: Build docker image
run: cd builders && make docker-image-alpine
- name: Build & Test static library
run: make release-build-alpine
tnasu marked this conversation as resolved.
Show resolved Hide resolved

test:
needs: build_shared_library
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,39 @@ jobs:
run: |
VERSION=$(cargo tree -i wasmvm | grep -oE "[0-9]+(\.[0-9]+){2}-[0-9]+(\.[0-9]+){2}")
echo ::set-output name=version::v$VERSION

build_static_lib:
name: Build static libraries
needs:
- get-version
if: ${{ needs.get-version.outputs.package-version != needs.get-version.outputs.latest-tag }}
runs-on: ubuntu-latest
steps:
- name: set up
uses: actions/setup-go@v2
shiki-tak marked this conversation as resolved.
Show resolved Hide resolved
with:
go-version: ^1.17.4
id: go
- name: Checkout
uses: actions/checkout@v2
- name: Build docker image
run: cd builders && make docker-image-alpine
- name: Build & Test static library
run: make release-build-alpine
- name: Collect artifacts
run: |
mkdir artifacts
cp ./api/libwasmvm_muslc.a artifacts/libwasmvm_muslc.x86_64.a
cp ./api/libwasmvm_muslc.aarch64.a artifacts/libwasmvm_muslc.aarch64.a
- name: Create checksums
working-directory: artifacts
run: sha256sum * > checksums.txt && cat checksums.txt
- name: Upload static library
uses: actions/upload-artifact@v2
with:
name: artifacts
path: ./artifacts

push-tag: # if the version does not exist as git tag, push it
name: Push Tag
needs:
Expand All @@ -46,3 +79,21 @@ jobs:
curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
-d "{\"ref\": \"refs/tags/${{ needs.get-version.outputs.package-version }}\", \"sha\": \"${GITHUB_SHA}\"}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs"

update-releases:
name: Update Latest release
needs:
- push-tag
tnasu marked this conversation as resolved.
Show resolved Hide resolved
- build_static_lib
if: ${{ needs.get-version.outputs.package-version != needs.get-version.outputs.latest-tag }}
runs-on: ubuntu-latest
steps:
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.get-version.outputs.package-version }}
body: ${{ github.event.pull_request.body }}
files: |
./artifacts/*
draft: false
prerelease: false
7 changes: 4 additions & 3 deletions api/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ type DBState struct {
}

// use this to create C.Db in two steps, so the pointer lives as long as the calling stack
// state := buildDBState(kv, callID)
// db := buildDB(&state, &gasMeter)
// // then pass db into some FFI function

// state := buildDBState(kv, callID)
// db := buildDB(&state, &gasMeter)
// // then pass db into some FFI function
func buildDBState(kv KVStore, callID uint64) DBState {
return DBState{
Store: kv,
Expand Down
1 change: 1 addition & 0 deletions api/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestCreateAndDestroyUnmanagedVector(t *testing.T) {

// Like the test above but without `newUnmanagedVector` calls.
// Since only Rust can actually create them, we only test edge cases here.

//go:nocheckptr
func TestCopyDestroyUnmanagedVector(t *testing.T) {
{
Expand Down
35 changes: 18 additions & 17 deletions builders/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Install C compiler for cross-compilation. This is required by
# Wasmer in https://github.com/wasmerio/wasmer/blob/2.2.1/lib/vm/build.rs.
# For newer versions this might not be needed anymore since build.rs is removed
# in https://github.com/wasmerio/wasmer/pull/2807.
#
# https://unix.stackexchange.com/questions/620205/aarch64-linux-musl-cross-has-a-broken-link-for-ld-musl-aarch64-so-1

# We need aarch64-linux-musl-cross to compile, wget to musl.cc is denied by github actions.
# We will use a copy from an image that already contains aarch64-linux-musl-cross.
FROM mondoolabs/golang:1.15.0-alpine AS builder
shiki-tak marked this conversation as resolved.
Show resolved Hide resolved

# 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
Expand All @@ -8,29 +19,15 @@ ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN apk add rustup

# this comes from standard alpine nightly file
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile
# with some changes to support our toolchain, etc
RUN set -eux \
&& apk add --no-cache ca-certificates build-base

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

# Install C compiler for cross-compilation. This is required by
# Wasmer in https://github.com/wasmerio/wasmer/blob/2.2.1/lib/vm/build.rs.
# For newer versions this might not be needed anymore since build.rs is removed
# in https://github.com/wasmerio/wasmer/pull/2807.
#
# https://unix.stackexchange.com/questions/620205/aarch64-linux-musl-cross-has-a-broken-link-for-ld-musl-aarch64-so-1
RUN wget https://musl.cc/aarch64-linux-musl-cross.tgz \
&& tar -xf aarch64-linux-musl-cross.tgz \
&& mv ./aarch64-linux-musl-cross /opt \
&& /opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc --version \
&& rm aarch64-linux-musl-cross.tgz
RUN rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.57.0

# prepare go cache dirs
RUN mkdir -p /.cache/go-build
Expand All @@ -42,6 +39,10 @@ RUN chmod -R 777 /usr/local/cargo
## COPY BUILD SCRIPTS
WORKDIR /code

COPY --from=builder \
/usr/local/bin/aarch64-linux-musl-cross \
/opt/aarch64-linux-musl-cross

# Add musl Rust targets
RUN rustup target add aarch64-unknown-linux-musl x86_64-unknown-linux-musl

Expand Down