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

Go 1.21 #92

Merged
merged 2 commits into from
Aug 10, 2023
Merged
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
30 changes: 24 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,53 @@ on:
pull_request:

jobs:
Go:
go-test:
name: Go Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version-file: go.mod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh cool trick! Wondering if we can do the same with goreleaser instead of having the .go-version file.

check-latest: true

# We run the tests 20 times because sometimes it helps highlight flaky
# behaviors that do not trigger on a single pass.
- name: Go Tests
run: make test count=20

WASI:
golangci-lint:
name: Go Lint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- run: go mod download
- uses: golangci/golangci-lint-action@v3
with:
version: v1.54.0
args: --timeout 5m --issues-exit-code 0 # warn only

wasi-test:
name: WASI Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version-file: go.mod
check-latest: true

- name: WASI Tests
Expand Down
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.PHONY: all clean test testdata wasi-libc wasi-testsuite
.PHONY: all clean fmt lint test testdata wasi-libc wasi-testsuite

GO ?= go

count ?= 1

Expand Down Expand Up @@ -33,7 +35,13 @@ clean:
rm -f $(testdata.files)

test: testdata
go test -count=$(count) ./...
$(GO) test -count=$(count) ./...

fmt:
$(GO) fmt ./...

lint:
which golangci-lint >/dev/null && golangci-lint run

testdata: $(testdata.files)

Expand Down Expand Up @@ -61,13 +69,13 @@ testdata/c/http/http.wasm: testdata/c/http/http.c
clang $< -o $@ -Wall -Os -target wasm32-unknown-wasi testdata/c/http/proxy.c testdata/c/http/proxy_component_type.o

testdata/go/%.wasm: testdata/go/%.go
GOARCH=wasm GOOS=wasip1 gotip build -o $@ $<
GOARCH=wasm GOOS=wasip1 $(GO) build -o $@ $<

testdata/tinygo/%.wasm: testdata/tinygo/%.go
tinygo build -target=wasi -o $@ $<

wasirun: go.mod $(wasirun.src)
go build -o wasirun ./cmd/wasirun
$(GO) build -o wasirun ./cmd/wasirun

wasi-libc: testdata/.sysroot/lib/wasm32-wasi/libc.a

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ As the providers of a Go implementation of WASI, we're naturally interested in
Go's support for WebAssembly and WASI, and are championing the efforts to make
Go a first class citizen in the ecosystem (along with Rust and Zig).

Go v1.21, scheduled for release in August 2023, has native support for
WebAssembly and WASI. To test these features before release, use [`gotip`][gotip]
in place of `go`:
[Go v1.21][go-121] has native support for WebAssembly and WASI:


```go
package main
Expand All @@ -124,7 +123,9 @@ func main() {
```

```console
$ GOOS=wasip1 GOARCH=wasm gotip build -o hello.wasm hello.go
# go version
go version go1.21.0 darwin/arm64
$ GOOS=wasip1 GOARCH=wasm go build -o hello.wasm hello.go
$ wasirun hello.wasm
Hello, World!
```
Expand All @@ -150,7 +151,7 @@ Remember to be respectful and open minded!
[wasitest]: https://github.com/stealthrocket/wasi-go/tree/main/wasitest
[tracer]: https://github.com/stealthrocket/wasi-go/blob/main/tracer.go
[sockets-extension]: https://github.com/stealthrocket/wasi-go/blob/main/sockets_extension.go
[gotip]: https://pkg.go.dev/golang.org/dl/gotip
[go-121]: https://go.dev/blog/go1.21
[go-script]: https://github.com/stealthrocket/wasi-go/blob/main/share/go_wasip1_wasm_exec
[wasmer]: https://github.com/wasmerio/wasmer
[wasmedge]: https://github.com/WasmEdge/WasmEdge
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/stealthrocket/wasi-go

go 1.20
go 1.21

require (
github.com/stealthrocket/wazergo v0.19.1
Expand Down
2 changes: 1 addition & 1 deletion wasitest/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package wasitest

import (
"context"
"slices"
"testing"

"github.com/stealthrocket/wasi-go"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

// TestSystem is a test suite which validates the behavior of wasi.System
Expand Down
Loading