Skip to content

Commit

Permalink
env: add wasip1/wasm wazero builder
Browse files Browse the repository at this point in the history
This builder installs wazero, a pure Go Wasm runtime with
WASI support.

Fixes golang/go#59150

Change-Id: Id27f7eff79848d0aec1434dad1bf5b57cbfff874
Reviewed-on: https://go-review.googlesource.com/c/build/+/479118
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
  • Loading branch information
johanbrandhorst authored and gopherbot committed Mar 29, 2023
1 parent 3e1213a commit 2805ef1
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
38 changes: 38 additions & 0 deletions dashboard/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var slowBotAliases = map[string]string{
"illumos": "illumos-amd64",
"ios": "ios-arm64-corellium",
"js": "js-wasm-node18",
"wasip1": "wasip1-wasm-wazero",
"linux": "linux-amd64",
"linux-arm": "linux-arm-aws",
"linux-loong64": "linux-loong64-3a5000",
Expand Down Expand Up @@ -97,6 +98,7 @@ var slowBotAliases = map[string]string{
"solaris": "solaris-amd64-oraclerel",
"solaris-amd64": "solaris-amd64-oraclerel",
"wasm": "js-wasm-node18",
"wazero": "wasip1-wasm-wazero",
"windows": "windows-amd64-2016",
"windows-386": "windows-386-2016",
"windows-amd64": "windows-amd64-2016",
Expand Down Expand Up @@ -322,6 +324,11 @@ var Hosts = map[string]*HostConfig{
ContainerImage: "linux-x86-stretch:latest",
SSHUsername: "root",
},
"host-linux-amd64-wasip1-wasm-wazero": {
Notes: "Container with Wazero for testing wasip1/wasm.",
ContainerImage: "wasip1-wasm-wazero:latest",
SSHUsername: "root",
},
"host-linux-amd64-wsl": {
Notes: "Windows 10 WSL2 Ubuntu",
Owners: []*gophers.Person{gh("mengzhuo")},
Expand Down Expand Up @@ -3089,6 +3096,37 @@ func init() {
RunBench: true,
SkipSnapshot: true,
})
addBuilder(BuildConfig{
Name: "wasip1-wasm-wazero",
HostType: "host-linux-amd64-wasip1-wasm-wazero",
KnownIssues: []int{58141},
buildsRepo: func(repo, branch, goBranch string) bool {
b := buildRepoByDefault(repo) && atLeastGo1(goBranch, 21)
switch repo {
case "benchmarks", "debug", "perf", "talks", "tools", "tour", "website":
// Don't test these golang.org/x repos.
b = false
}
if repo != "go" && !(branch == "master" && goBranch == "master") {
// For golang.org/x repos, don't test non-latest versions.
b = false
}
return b
},
distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
if isNormalTry && (strings.Contains(distTest, "/internal/") || distTest == "reboot") {
// Skip some tests in an attempt to speed up normal trybots, inherited from CL 121938.
run = false
}
return run
},
numTryTestHelpers: 3,
env: []string{
"GOOS=wasip1", "GOARCH=wasm", "GOHOSTOS=linux", "GOHOSTARCH=amd64",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workdir/go/misc/wasm",
"GO_DISABLE_OUTBOUND_NETWORK=1",
},
})
}

// addBuilder adds c to the Builders map after doing some checks.
Expand Down
19 changes: 19 additions & 0 deletions dashboard/builders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,23 @@ func TestBuilderConfig(t *testing.T) {
{b("js-wasm-node18", "tour"), none},
{b("js-wasm-node18", "website"), none},

{b("wasip1-wasm-wazero", "go"), onlyPost},
{b("wasip1-wasm-wazero@go1.21", "go"), onlyPost},
{b("wasip1-wasm-wazero@go1.20", "go"), none},
// Test wasip1/wasm on a subset of golang.org/x repos:
{b("wasip1-wasm-wazero", "arch"), onlyPost},
{b("wasip1-wasm-wazero", "crypto"), onlyPost},
{b("wasip1-wasm-wazero", "sys"), onlyPost},
{b("wasip1-wasm-wazero", "net"), onlyPost},
{b("wasip1-wasm-wazero", "benchmarks"), none},
{b("wasip1-wasm-wazero", "debug"), none},
{b("wasip1-wasm-wazero", "mobile"), none},
{b("wasip1-wasm-wazero", "perf"), none},
{b("wasip1-wasm-wazero", "talks"), none},
{b("wasip1-wasm-wazero", "tools"), none},
{b("wasip1-wasm-wazero", "tour"), none},
{b("wasip1-wasm-wazero", "website"), none},

// Race builders. Linux for all, GCE builders for
// post-submit, and only post-submit for "go" for
// Darwin (limited resources).
Expand Down Expand Up @@ -665,6 +682,7 @@ func TestBuilderConfig(t *testing.T) {
{b("freebsd-386-12_3", "exp"), none},
{b("freebsd-amd64-12_3", "exp"), none},
{b("js-wasm", "exp"), none},
{b("wasip1-wasm-wazero", "exp"), none},

// exp is experimental; it doesn't test against release branches.
{b("linux-amd64@go1.99", "exp"), none},
Expand All @@ -691,6 +709,7 @@ func TestBuilderConfig(t *testing.T) {
{b("linux-amd64@go1.20", "pkgsite-metrics"), both},

{b("js-wasm", "build"), none},
{b("wasip1-wasm-wazero", "build"), none},
{b("android-386-emu", "build"), none},
{b("android-amd64-emu", "build"), none},

Expand Down
16 changes: 16 additions & 0 deletions env/wasip1-wasm-wazero/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

ARG REPO

FROM golang:latest as builder
LABEL maintainer="golang-dev@googlegroups.com"

RUN go install github.com/tetratelabs/wazero/cmd/wazero@v1.0.1

FROM ${REPO}/linux-x86-sid:20221109

COPY --from=builder /go/bin/wazero /usr/local/bin/wazero

CMD ["/usr/local/bin/stage0"]
22 changes: 22 additions & 0 deletions env/wasip1-wasm-wazero/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

IMAGE_NAME=$(shell basename $(CURDIR))
PROD_REPO=gcr.io/symbolic-datum-552

usage:
echo "Use prod or dev targets. For dev, specify your Docker repository with the REPO=foo argument." ; exit 1

prod: Dockerfile
docker build -t $(PROD_REPO)/$(IMAGE_NAME):latest --build-arg REPO=$(PROD_REPO) -f Dockerfile .

pushprod: prod
docker push $(PROD_REPO)/$(IMAGE_NAME):latest

# You must provide a REPO=your-repo-name arg when you make
# this target. REPO is the name of the Docker repository
# that will be prefixed to the name of the image being built.
dev: Dockerfile
docker build -t $(REPO)/$(IMAGE_NAME):latest --build-arg REPO=$(REPO) -f Dockerfile .
docker push $(REPO)/$(IMAGE_NAME):latest

0 comments on commit 2805ef1

Please sign in to comment.