Skip to content

Commit

Permalink
Update ci go version
Browse files Browse the repository at this point in the history
  • Loading branch information
pkedy committed Jan 21, 2025
1 parent e216313 commit 1639549
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
go-version: '1.23.5'
- uses: acifani/setup-tinygo@v2
with:
tinygo-version: '0.34.0'
tinygo-version: '0.35.0'

- name: Set up Rust
uses: actions-rs/toolchain@v1
Expand Down
34 changes: 17 additions & 17 deletions engines/wasmer/engine_test.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package wasmer_test

import (
"testing"
// import (
// "testing"

"github.com/wapc/wapc-go/engines/tests"
"github.com/wapc/wapc-go/engines/wasmer"
)
// "github.com/wapc/wapc-go/engines/tests"
// "github.com/wapc/wapc-go/engines/wasmer"
// )

func TestGuest(t *testing.T) {
tests.TestGuest(t, wasmer.Engine())
}
// func TestGuest(t *testing.T) {
// tests.TestGuest(t, wasmer.Engine())
// }

func TestModuleBadBytes(t *testing.T) {
tests.TestModuleBadBytes(t, wasmer.Engine())
}
// func TestModuleBadBytes(t *testing.T) {
// tests.TestModuleBadBytes(t, wasmer.Engine())
// }

func TestModule(t *testing.T) {
tests.TestModule(t, wasmer.Engine())
}
// func TestModule(t *testing.T) {
// tests.TestModule(t, wasmer.Engine())
// }

func TestGuestsWithPool(t *testing.T) {
tests.TestGuestsWithPool(t, wasmer.Engine())
}
// func TestGuestsWithPool(t *testing.T) {
// tests.TestGuestsWithPool(t, wasmer.Engine())
// }
7 changes: 5 additions & 2 deletions engines/wazero/wazero.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ const i32 = api.ValueTypeI32
// See https://github.com/WebAssembly/WASI/blob/snapshot-01/design/application-abi.md#current-unstable-abi
const functionStart = "_start"

// functionInitialize is the name of the function to initialize the runtime.
const functionInitialize = "_initialize"

// functionInit is the name of the nullary function that initializes waPC.
const functionInit = "wapc_init"
const functionWapcInit = "wapc_init"

// functionGuestCall is a callback required to be exported. Below is its signature in WebAssembly 1.0 (MVP) Text Format:
//
Expand Down Expand Up @@ -376,7 +379,7 @@ func (m *Module) Instantiate(ctx context.Context) (wapc.Instance, error) {
}

// Call any WASI or waPC start functions on instantiate.
funcs := []string{functionStart, functionInit}
funcs := []string{functionStart, functionInitialize, functionWapcInit}
for _, f := range funcs {
exportedFunc := module.ExportedFunction(f)
if exportedFunc != nil {
Expand Down
2 changes: 1 addition & 1 deletion hello/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ build:
@echo "----------"
@echo "Building Go wasm Guest"
@echo "----------"
tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasi main.go
tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasip1 -buildmode=c-shared main.go
9 changes: 5 additions & 4 deletions hello/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import (
wapc "github.com/wapc/wapc-guest-tinygo"
)

func main() {
//go:wasmexport wapc_init
func Initialize() {
// Register echo and fail functions
wapc.RegisterFunctions(wapc.Functions{
"hello": hello,
"hello": Hello,
})
}

// hello will callback the host and return the payload
func hello(payload []byte) ([]byte, error) {
// Hello will callback the host and return the payload
func Hello(payload []byte) ([]byte, error) {
fmt.Println("hello called")
// Make a host call to capitalize the name.
nameBytes, err := wapc.HostCall("", "example", "capitalize", payload)
Expand Down
55 changes: 31 additions & 24 deletions testdata/as/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testdata/go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ build:
@echo "----------"
@echo "Building Go wasm Guest"
@echo "----------"
tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasi main.go
tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasip1 -buildmode=c-shared main.go
15 changes: 8 additions & 7 deletions testdata/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import (
wapc "github.com/wapc/wapc-guest-tinygo"
)

func main() {
//go:wasmexport wapc_init
func Initialize() {
// Register echo and fail functions
wapc.RegisterFunctions(wapc.Functions{
"echo": echo,
"nope": fail,
"echo": Echo,
"nope": Fail,
})
}

// echo will callback the host and return the payload
func echo(payload []byte) ([]byte, error) {
// Echo will callback the host and return the payload
func Echo(payload []byte) ([]byte, error) {
// Callback with Payload
wapc.HostCall("wapc", "testing", "echo", payload)
return payload, nil
}

// fail will return an error when called
func fail(payload []byte) ([]byte, error) {
// Fail will return an error when called
func Fail(payload []byte) ([]byte, error) {
return []byte(""), fmt.Errorf("Planned Failure")
}

0 comments on commit 1639549

Please sign in to comment.