Skip to content

Commit

Permalink
Try #200:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Feb 25, 2021
2 parents 011e500 + e6df4af commit 154af4d
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 56 deletions.
79 changes: 41 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ jobs:
matrix:
go: [1.14, 1.15]
target:
- id: 'linux-amd64'
os: 'ubuntu-18.04'
#- id: 'linux-amd64'
# os: 'ubuntu-18.04'

- id: 'linux-aarch64'
os: ['self-hosted', 'linux', 'ARM64']
#- id: 'linux-aarch64'
# os: ['self-hosted', 'linux', 'ARM64']

- id: 'darwin-amd64'
os: 'macos-latest'
#- id: 'darwin-amd64'
# os: 'macos-latest'

- id: 'linux-amd64'
os: 'ubuntu-18.04'
libwasmer_archive_name: 'wasmer-linux-amd64.tar.gz'
- id: 'windows-amd64'
os: 'windows-latest'

#- id: 'linux-amd64'
# os: 'ubuntu-18.04'
# libwasmer_archive_name: 'wasmer-linux-amd64.tar.gz'
fail-fast: true

runs-on: ${{ matrix.target.os }}
Expand All @@ -35,46 +38,46 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
default: false
#- name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# override: true
# default: false

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Set up just
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
cargo install just
#- name: Set up just
# run: |
# export PATH="$HOME/.cargo/bin:$PATH"
# cargo install just

- name: Run all the tests (default)
if: ${{ !matrix.target.libwasmer_archive_name }}
shell: bash
run: |
just test
cd wasmer
go test -v
#just test
#- name: Run all the tests (with custom Wasmer runtime)
# if: matrix.target.libwasmer_archive_name
# shell: bash
# run: |
# libwasmer_url=$(curl -s https://api.github.com/repos/wasmerio/wasmer-nightly/releases/latest | jq --raw-output '.assets[] | select(.name == "${{ matrix.target.libwasmer_archive_name }}") | .browser_download_url')
# mkdir -p libwasmer
# curl -L $libwasmer_url > release.tar.gz
# tar xzvf release.tar.gz -C libwasmer
# export CGO_CFLAGS="-I$(pwd)/libwasmer/include/"
# export CGO_LDFLAGS="-Wl,-rpath,$(pwd)/libwasmer/lib/ -L$(pwd)/libwasmer/lib/ -lwasmer"
# just test -tags custom_wasmer_runtime

#- name: Run all the examples
# run: |
# just examples

- name: Run all the tests (with custom Wasmer runtime)
if: matrix.target.libwasmer_archive_name
shell: bash
run: |
libwasmer_url=$(curl -s https://api.github.com/repos/wasmerio/wasmer-nightly/releases/latest | jq --raw-output '.assets[] | select(.name == "${{ matrix.target.libwasmer_archive_name }}") | .browser_download_url')
mkdir -p libwasmer
curl -L $libwasmer_url > release.tar.gz
tar xzvf release.tar.gz -C libwasmer
export CGO_CFLAGS="-I$(pwd)/libwasmer/include/"
export CGO_LDFLAGS="-Wl,-rpath,$(pwd)/libwasmer/lib/ -L$(pwd)/libwasmer/lib/ -lwasmer"
just test -tags custom_wasmer_runtime
- name: Run all the examples
shell: bash
run: |
just examples
# Skipped for now because of Github banning the API request from actions.
# You can find more info in this PR: https://github.com/wasmerio/wasmer-go/pull/118#issuecomment-588487544
# - name: Test bazel build
Expand Down
10 changes: 6 additions & 4 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
status = [
"Build and Test (1.14, linux-amd64, ubuntu-%)",
"Build and Test (1.14, linux-aarch64, self-hosted, linux, ARM64)",
"Build and Test (1.14, darwin-amd64, macos-%)",
"Build and Test (1.14, linux-aarch64, self-hosted, linux, ARM64)",
"Build and Test (1.14, linux-amd64, ubuntu-%)",
"Build and Test (1.14, linux-amd64, ubuntu-%, wasmer-%.tar.gz)",
"Build and Test (1.15, linux-amd64, ubuntu-%)",
"Build and Test (1.15, linux-aarch64, self-hosted, linux, ARM64)",
"Build and Test (1.14, windows-amd64, windows-%)",
"Build and Test (1.15, darwin-amd64, macos-%)",
"Build and Test (1.15, linux-aarch64, self-hosted, linux, ARM64)",
"Build and Test (1.15, linux-amd64, ubuntu-%)",
"Build and Test (1.15, linux-amd64, ubuntu-%, wasmer-%.tar.gz)",
"Build and Test (1.15, windows-amd64, windows-%)"
]
required_approvals = 1
timeout_sec = 7200
Expand Down
7 changes: 5 additions & 2 deletions wasmer/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
package wasmer

// #cgo CFLAGS: -I${SRCDIR}/packaged/include
// #cgo LDFLAGS: -lwasmer
//
// #cgo !windows LDFLAGS: -lwasmer
// #cgo windows LDFLAGS: -lwasmer -luserenv -lws2_32 -ladvapi32 -lbcrypt -lkernel32
//
// #cgo darwin,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/darwin-amd64 -L${SRCDIR}/packaged/lib/darwin-amd64
// #cgo linux,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/linux-amd64 -L${SRCDIR}/packaged/lib/linux-amd64
// #cgo linux,arm64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/linux-aarch64 -L${SRCDIR}/packaged/lib/linux-aarch64
// #cgo darwin,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/darwin-amd64 -L${SRCDIR}/packaged/lib/darwin-amd64
// #cgo windows,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/windows-amd64 -L${SRCDIR}/packaged/lib/windows-amd64
//
// #include <wasmer_wasm.h>
import "C"
Expand Down
1 change: 1 addition & 0 deletions wasmer/packaged/lib/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import (
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/darwin-amd64"
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/linux-aarch64"
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/linux-amd64"
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/windows-amd64"
)
2 changes: 2 additions & 0 deletions wasmer/packaged/lib/windows-amd64/dummy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See https://github.com/golang/go/issues/26366.
package windows_amd64
Binary file added wasmer/packaged/lib/windows-amd64/wasmer.lib
Binary file not shown.
17 changes: 6 additions & 11 deletions wasmer/wasi.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package wasmer

// #include <stdlib.h>
// #include <stdio.h>
// #include <string.h>
// #include <wasmer_wasm.h>
//
// // Buffer size for `wasi_env_read_inner`.
Expand All @@ -17,28 +17,23 @@ package wasmer
//
// // Common function to read a WASI environment captured stream.
// size_t to_wasi_env_read_inner(wasi_env_t *wasi_env, char** buffer, wasi_env_reader reader) {
// FILE *memory_stream;
// char* buffer_ptr = (char*) malloc(1);
// size_t buffer_size = 0;
//
// memory_stream = open_memstream(buffer, &buffer_size);
//
// if (NULL == memory_stream) {
// return 0;
// }
//
// char temp_buffer[WASI_ENV_READER_BUFFER_SIZE] = { 0 };
// size_t data_read_size = WASI_ENV_READER_BUFFER_SIZE;
// size_t data_read_size = 0;
//
// do {
// data_read_size = reader(wasi_env, temp_buffer, WASI_ENV_READER_BUFFER_SIZE);
//
// if (data_read_size > 0) {
// buffer_ptr = realloc(buffer_ptr, buffer_size + data_read_size);
// memcpy(buffer_ptr + buffer_size, temp_buffer, data_read_size);
// buffer_size += data_read_size;
// fwrite(temp_buffer, sizeof(char), data_read_size, memory_stream);
// }
// } while (WASI_ENV_READER_BUFFER_SIZE == data_read_size);
//
// fclose(memory_stream);
// *buffer = buffer_ptr;
//
// return buffer_size;
// }
Expand Down
2 changes: 1 addition & 1 deletion wasmer/wasi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func TestWasiWithCapturedStdout(t *testing.T) {

assert.Equal(
t,
stdout,
"Found program name: `test-program`\n"+
"Found 1 arguments: --foo\n"+
"Found 2 environment variables: ABC=DEF, X=ZY\n"+
"Found 1 preopened directories: DirEntry(\"/the_host_current_directory\")\n",
stdout,
)
}

0 comments on commit 154af4d

Please sign in to comment.