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

Add an E2E build & test, check linked dylibs of the executable #285

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- master
- staging
- trying
pull_request:
branches: [master]
schedule:
- cron: '0 2 * * *' # To test `wasmer-nightly` with `libwasmer_archive_name`.

Expand Down Expand Up @@ -74,6 +76,12 @@ jobs:
export CGO_LDFLAGS="-Wl,-rpath,$(pwd)/libwasmer/lib/ -L$(pwd)/libwasmer/lib/ -lwasmer"
just test -tags custom_wasmer_runtime

- name: Run e2e tests (default)
if: ${{ !matrix.target.libwasmer_archive_name }}
shell: bash
run: |
just e2e

- name: Run all the examples
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
app
3 changes: 3 additions & 0 deletions e2e/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module wasmer-go.org/app/v2

go 1.16
32 changes: 32 additions & 0 deletions e2e/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"
"io/ioutil"

wasmer "github.com/wasmerio/wasmer-go/wasmer"
)

func main() {
// fmt.Println(C.ffi_lz4_version_number())
wasmBytes, _ := ioutil.ReadFile("simple.wasm")

engine := wasmer.NewEngine()
store := wasmer.NewStore(engine)

// Compiles the module
module, _ := wasmer.NewModule(store, wasmBytes)

// Instantiates the module
importObject := wasmer.NewImportObject()
instance, _ := wasmer.NewInstance(module, importObject)

// Gets the `sum` exported function from the WebAssembly instance.
sum, _ := instance.Exports.GetFunction("sum")

// Calls that exported function with Go standard values. The WebAssembly
// types are inferred and values are casted automatically.
result, _ := sum(5, 37)

fmt.Println(result) // 42!
}
Binary file added e2e/simple.wasm
Binary file not shown.
8 changes: 8 additions & 0 deletions e2e/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
rm -r vendor || echo 'error ignored'
mkdir -p vendor/github.com/wasmerio/wasmer-go
cp -r ../wasmer vendor/github.com/wasmerio/wasmer-go
GODEBUG=cgocheck=2 go build -o app
ldd app || echo 'error ignored'
otool -L app || echo 'error ignored'
./app
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ examples:
# Run the examples.
GODEBUG=cgocheck=2 go test -v

e2e:
#!/usr/bin/env bash
cd e2e
./test.sh

# Preview the documentation (needs `godoc`, see `go get -v golang.org/x/tools/cmd/godoc`).
preview-doc ADDRESS="0.0.0.0" PORT="9090":
@echo "Starting godoc preview..."
Expand Down