Skip to content

Commit

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

For golang/go#59150

Change-Id: I7d1db6c9f5ec2b4257e3961b552f3de0bb7ed049
Reviewed-on: https://go-review.googlesource.com/c/build/+/479121
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
  • Loading branch information
johanbrandhorst authored and heschi committed Mar 30, 2023
1 parent 2805ef1 commit 579d681
Show file tree
Hide file tree
Showing 5 changed files with 647 additions and 0 deletions.
37 changes: 37 additions & 0 deletions dashboard/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ var slowBotAliases = map[string]string{
"solaris": "solaris-amd64-oraclerel",
"solaris-amd64": "solaris-amd64-oraclerel",
"wasm": "js-wasm-node18",
"wasmtime": "wasip1-wasm-wasmtime",
"wazero": "wasip1-wasm-wazero",
"windows": "windows-amd64-2016",
"windows-386": "windows-386-2016",
Expand Down Expand Up @@ -324,6 +325,11 @@ var Hosts = map[string]*HostConfig{
ContainerImage: "linux-x86-stretch:latest",
SSHUsername: "root",
},
"host-linux-amd64-wasip1-wasm-wasmtime": {
Notes: "Container with wasmtime for testing wasip1/wasm.",
ContainerImage: "wasip1-wasm-wasmtime:latest",
SSHUsername: "root",
},
"host-linux-amd64-wasip1-wasm-wazero": {
Notes: "Container with Wazero for testing wasip1/wasm.",
ContainerImage: "wasip1-wasm-wazero:latest",
Expand Down Expand Up @@ -3127,6 +3133,37 @@ func init() {
"GO_DISABLE_OUTBOUND_NETWORK=1",
},
})
addBuilder(BuildConfig{
Name: "wasip1-wasm-wasmtime",
HostType: "host-linux-amd64-wasip1-wasm-wasmtime",
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
17 changes: 17 additions & 0 deletions dashboard/builders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ func TestBuilderConfig(t *testing.T) {
{b("wasip1-wasm-wazero", "go"), onlyPost},
{b("wasip1-wasm-wazero@go1.21", "go"), onlyPost},
{b("wasip1-wasm-wazero@go1.20", "go"), none},
{b("wasip1-wasm-wasmtime", "go"), onlyPost},
{b("wasip1-wasm-wasmtime@go1.21", "go"), onlyPost},
{b("wasip1-wasm-wasmtime@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},
Expand All @@ -642,6 +645,18 @@ func TestBuilderConfig(t *testing.T) {
{b("wasip1-wasm-wazero", "tools"), none},
{b("wasip1-wasm-wazero", "tour"), none},
{b("wasip1-wasm-wazero", "website"), none},
{b("wasip1-wasm-wasmtime", "arch"), onlyPost},
{b("wasip1-wasm-wasmtime", "crypto"), onlyPost},
{b("wasip1-wasm-wasmtime", "sys"), onlyPost},
{b("wasip1-wasm-wasmtime", "net"), onlyPost},
{b("wasip1-wasm-wasmtime", "benchmarks"), none},
{b("wasip1-wasm-wasmtime", "debug"), none},
{b("wasip1-wasm-wasmtime", "mobile"), none},
{b("wasip1-wasm-wasmtime", "perf"), none},
{b("wasip1-wasm-wasmtime", "talks"), none},
{b("wasip1-wasm-wasmtime", "tools"), none},
{b("wasip1-wasm-wasmtime", "tour"), none},
{b("wasip1-wasm-wasmtime", "website"), none},

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

// exp is experimental; it doesn't test against release branches.
{b("linux-amd64@go1.99", "exp"), none},
Expand Down Expand Up @@ -710,6 +726,7 @@ func TestBuilderConfig(t *testing.T) {

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

Expand Down
21 changes: 21 additions & 0 deletions env/wasip1-wasm-wasmtime/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022 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 debian:latest as builder
LABEL maintainer="golang-dev@googlegroups.com"

RUN apt-get update && apt-get -y install curl xz-utils

# A copy of https://wasmtime.dev/install.sh.
COPY install.sh install.sh

RUN bash install.sh --version v7.0.0

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

COPY --from=builder /root/.wasmtime/bin/wasmtime /usr/local/bin/wasmtime

CMD ["/usr/local/bin/stage0"]
22 changes: 22 additions & 0 deletions env/wasip1-wasm-wasmtime/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
Loading

0 comments on commit 579d681

Please sign in to comment.