ci: update Go floor to 1.22 and run CI with 1.22/1.24 (#2379)

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
This commit is contained in:
Anuraag (Rag) Agrawal
2025-02-19 00:24:27 +09:00
committed by GitHub
parent 70a9688a9f
commit 96f2052f6d
23 changed files with 180 additions and 162 deletions
+5 -5
View File
@@ -14,7 +14,7 @@ on:
- 'netlify.toml'
env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.23"
GO_VERSION: "1.24"
defaults:
run: # use bash for all operating systems unless overridden
@@ -71,8 +71,8 @@ jobs:
- os: macos-14
arch: arm64
go-version:
- "1.23" # Current Go version
- "1.21" # Floor Go version of wazero (current - 2)
- "1.24" # Current Go version
- "1.22" # Floor Go version of wazero (current - 2)
steps:
@@ -112,8 +112,8 @@ jobs:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
go-version:
- "1.23" # Current Go version
- "1.21" # Floor Go version of wazero (current - 2)
- "1.24" # Current Go version
- "1.22" # Floor Go version of wazero (current - 2)
platform:
- os: ubuntu-22.04
arch: amd64
+3 -3
View File
@@ -18,7 +18,7 @@ on:
env:
EMSDK_VERSION: "3.1.40"
TINYGO_VERSION: "0.35.0"
ZIG_VERSION: "0.11.0"
ZIG_VERSION: "0.13.0"
concurrency:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run
@@ -34,8 +34,8 @@ jobs:
strategy:
matrix:
go-version:
- "1.23"
- "1.21"
- "1.23" # Max version supported by TinyGo 0.35.0
- "1.22"
steps:
- name: Checkout
+8 -8
View File
@@ -18,7 +18,7 @@ defaults:
shell: bash
env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.23"
GO_VERSION: "1.24"
TINYGO_VERSION: "0.35.0"
ZIG_VERSION: "0.11.0"
BINARYEN_VERSION: "116"
@@ -47,7 +47,7 @@ jobs:
with:
# Use share the cache containing archives across OSes.
enableCrossOsArchive: true
key: zig-stdlib-test-binary-${{ env.ZIG_VERSION }}
key: zig-stdlib-test-binary-${{ env.ZIG_VERSION }}-${{ hashFiles(format('{0}/Makefile', env.STDLIB_TESTS)) }}
path:
${{ env.STDLIB_TESTS }}/testdata/zig
@@ -132,7 +132,7 @@ jobs:
with:
# Use share the cache containing archives across OSes.
enableCrossOsArchive: true
key: tinygo-test-binaries-${{ env.TINYGO_VERSION }}
key: tinygo-test-binaries-${{ env.TINYGO_VERSION }}-${{ hashFiles(format('{0}/Makefile', env.STDLIB_TESTS)) }}
path:
${{ env.STDLIB_TESTS }}/testdata/tinygo
@@ -147,7 +147,7 @@ jobs:
- uses: actions/setup-go@v5
if: steps.binary-cache.outputs.cache-hit != 'true'
with:
go-version: ${{ env.GO_VERSION }}
go-version: 1.23 # Latest supported by TinyGo 0.35
- name: Build Test Binaries
if: steps.binary-cache.outputs.cache-hit != 'true'
@@ -192,7 +192,7 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version: 1.23 # Latest supported by TinyGo 0.35
- name: Run test binaries
run: |
@@ -276,8 +276,8 @@ jobs:
name: Windows
arch: amd64
go-version:
- "1.23"
- "1.21"
- "1.24"
- "1.22"
steps:
- id: setup-go
@@ -295,7 +295,7 @@ jobs:
path:
${{ env.STDLIB_TESTS }}/testdata/go
# Use precise Go version from setup-go as patch version differences can effect tests.
key: go-wasip1-binaries-${{ matrix.os.version }}-${{ steps.setup-go.outputs.go-version }}-${{ matrix.os.arch }}
key: go-wasip1-binaries-${{ matrix.os.version }}-${{ steps.setup-go.outputs.go-version }}-${{ matrix.os.arch }}-${{ hashFiles(format('{0}/Makefile', env.STDLIB_TESTS)) }}
- if: ${{ steps.cache-go-test-binaries.outputs.cache-hit != 'true' }}
name: Build Test Binaries
+1 -1
View File
@@ -11,7 +11,7 @@ on:
tags: 'v[0-9]+.[0-9]+.[0-9]+**' # Ex. v0.2.0 v0.2.1-rc2
env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.23"
GO_VERSION: "1.24"
defaults:
run: # use bash for all operating systems unless overridden
+1
View File
@@ -36,6 +36,7 @@ package-lock.json
.vagrant
zig-cache/
.zig-cache/
zig-out/
.DS_Store
+1 -1
View File
@@ -1,7 +1,7 @@
gofumpt := mvdan.cc/gofumpt@v0.6.0
gosimports := github.com/rinchsan/gosimports/cmd/gosimports@v0.3.8
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.0
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
asmfmt := github.com/klauspost/asmfmt/cmd/asmfmt@v1.3.2
# sync this with netlify.toml!
hugo := github.com/gohugoio/hugo@v0.115.2
+9 -8
View File
@@ -1,16 +1,17 @@
const std = @import("std");
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *std.build.Builder) void {
const target = .{.cpu_arch = .wasm32, .os_tag = .freestanding};
const optimize = b.standardOptimizeOption(.{});
const lib = b.addSharedLibrary(.{
pub fn build(b: *std.Build) void {
const lib = b.addExecutable(.{
.name = "greet",
.root_source_file = .{ .path = "greet.zig" },
.target = target,
.optimize = optimize,
.root_source_file = b.path("greet.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
.optimize = b.standardOptimizeOption(.{}),
});
lib.entry = .disabled;
lib.rdynamic = true;
b.installArtifact(lib);
}
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
module github.com/tetratelabs/wazero
// Floor Go version of wazero (current - 2)
go 1.21
go 1.22.0
// All the beta tags are retracted and replaced with "pre" to prevent users
// from accidentally upgrading into the broken beta 1.
@@ -1,16 +1,15 @@
const std = @import("std");
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *std.build.Builder) void {
const target = .{.cpu_arch = .wasm32, .os_tag = .wasi};
const optimize = b.standardOptimizeOption(.{});
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "cat",
.root_source_file = .{ .path = "cat.zig" },
.target = target,
.optimize = optimize,
.root_source_file = b.path("cat.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .wasi,
}),
.optimize = b.standardOptimizeOption(.{}),
});
exe.install();
b.installArtifact(exe);
}
Binary file not shown.
+8 -9
View File
@@ -1,16 +1,15 @@
const std = @import("std");
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *std.build.Builder) void {
const target = .{.cpu_arch = .wasm32, .os_tag = .wasi};
const optimize = b.standardOptimizeOption(.{});
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "wasi",
.root_source_file = .{ .path = "wasi.zig" },
.target = target,
.optimize = optimize,
.root_source_file = b.path("wasi.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .wasi,
}),
.optimize = b.standardOptimizeOption(.{}),
});
std.Build.installArtifact(b, exe);
b.installArtifact(exe);
}
Binary file not shown.
+8 -7
View File
@@ -1,6 +1,7 @@
const std = @import("std");
const os = std.os;
const fs = std.fs;
const posix = std.posix;
const allocator = std.heap.page_allocator;
const preopensAlloc = std.fs.wasi.preopensAlloc;
const stdout = std.io.getStdOut().writer();
@@ -12,7 +13,7 @@ pub fn main() !void {
if (std.mem.eql(u8, args[1], "ls")) {
// TODO: This only looks at fd 3. See #14678
var dir = std.fs.cwd().openIterableDir(args[2], .{}) catch |err| switch (err) {
const dir = std.fs.cwd().openDir(args[2], .{}) catch |err| switch (err) {
error.NotDir => {
try stdout.print("ENOTDIR\n", .{});
return;
@@ -28,12 +29,12 @@ pub fn main() !void {
try ls(dir);
}
} else if (std.mem.eql(u8, args[1], "stat")) {
try stdout.print("stdin isatty: {}\n", .{os.isatty(0)});
try stdout.print("stdout isatty: {}\n", .{os.isatty(1)});
try stdout.print("stderr isatty: {}\n", .{os.isatty(2)});
try stdout.print("/ isatty: {}\n", .{os.isatty(3)});
try stdout.print("stdin isatty: {}\n", .{posix.isatty(0)});
try stdout.print("stdout isatty: {}\n", .{posix.isatty(1)});
try stdout.print("stderr isatty: {}\n", .{posix.isatty(2)});
try stdout.print("/ isatty: {}\n", .{posix.isatty(3)});
} else if (std.mem.eql(u8, args[1], "preopen")) {
var wasi_preopens = try preopensAlloc(allocator);
const wasi_preopens = try preopensAlloc(allocator);
// fs.wasi.Preopens does not have a free function
for (wasi_preopens.names, 0..) |preopen, i| {
@@ -42,7 +43,7 @@ pub fn main() !void {
}
}
fn ls(dir: std.fs.IterableDir) !void {
fn ls(dir: std.fs.Dir) !void {
var iter = dir.iterate();
while (try iter.next()) |entry| {
try stdout.print("./{s}\n", .{entry.name});
@@ -60,17 +60,17 @@ wasm stack trace:
}
func testZigDWARF(t *testing.T, r wazero.Runtime) {
runDWARFTest(t, r, dwarftestdata.ZigWasm, `module[] function[_start] failed: wasm error: unreachable
runDWARFTest(t, r, dwarftestdata.ZigWasm, `module[main.wasm] function[_start] failed: wasm error: unreachable
wasm stack trace:
.builtin.default_panic(i32,i32,i32,i32)
0x63: /builtin.zig:889:17
.main.main() i32
main.wasm.builtin.default_panic(i32,i32,i32,i32)
0x63: /builtin.zig:792:17
main.wasm.main.main(i32) i32
0x25: /main.zig:10:5 (inlined)
/main.zig:6:5 (inlined)
/main.zig:2:5
._start()
0x6a: /start.zig:609:37 (inlined)
/start.zig:224:5`)
main.wasm._start()
0xd1: /start.zig:524:37 (inlined)
/start.zig:199:5`)
}
func testCCDWARF(t *testing.T, r wazero.Runtime) {
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/tetratelabs/wazero/internal/integration_test/fuzz
go 1.21
go 1.22.0
require github.com/tetratelabs/wazero v0.0.0
+66 -64
View File
@@ -1,7 +1,7 @@
# Note: Some tests might fail if Go has been installed with homebrew because
# the file system layout is different than what the tests expect.
# Easiest fix is to install without using brew.
goroot?=$(shell go env GOROOT)
goroot?=$(shell go env GOROOT)/src
# Note: The standard binary zig distribution does not ship some testdata.
# You should override with the zig source code path, otherwise some tests will fail.
zigroot?=$(shell dirname $(shell which zig))
@@ -50,69 +50,69 @@ tinygo_tests=container/heap \
unicode/utf16 \
unicode/utf8
gowasip1_tests=src/archive/tar \
src/bufio \
src/bytes \
src/context \
src/encoding/ascii85 \
src/encoding/asn1 \
src/encoding/base32 \
src/encoding/base64 \
src/encoding/binary \
src/encoding/csv \
src/encoding/gob \
src/encoding/hex \
src/encoding/json \
src/encoding/pem \
src/encoding/xml \
src/errors \
src/expvar \
src/flag \
src/fmt \
src/hash \
src/hash/adler32 \
src/hash/crc32 \
src/hash/crc64 \
src/hash/fnv \
src/hash/maphash \
src/io \
src/io/fs \
src/io/ioutil \
src/log \
src/log/syslog \
src/maps \
src/math \
src/math/big \
src/math/bits \
src/math/cmplx \
src/math/rand \
src/mime \
src/mime/multipart \
src/mime/quotedprintable \
src/os \
src/os/exec \
src/os/signal \
src/os/user \
src/path \
src/reflect \
src/regexp \
src/regexp/syntax \
src/runtime \
src/runtime/internal/atomic \
src/runtime/internal/math \
src/runtime/internal/sys \
src/slices \
src/sort \
src/strconv \
src/strings \
src/sync \
src/sync/atomic \
src/syscall \
src/testing \
src/testing/fstest \
src/testing/iotest \
src/testing/quick \
src/time
gowasip1_tests=archive/tar \
bufio \
bytes \
context \
encoding/ascii85 \
encoding/asn1 \
encoding/base32 \
encoding/base64 \
encoding/binary \
encoding/csv \
encoding/gob \
encoding/hex \
encoding/json \
encoding/pem \
encoding/xml \
errors \
expvar \
flag \
fmt \
hash \
hash/adler32 \
hash/crc32 \
hash/crc64 \
hash/fnv \
hash/maphash \
io \
io/fs \
io/ioutil \
log \
log/syslog \
maps \
math \
math/big \
math/bits \
math/cmplx \
math/rand \
mime \
mime/multipart \
mime/quotedprintable \
os \
os/exec \
os/signal \
os/user \
path \
reflect \
regexp \
regexp/syntax \
runtime \
runtime/internal/atomic \
runtime/internal/math \
runtime/internal/sys \
slices \
sort \
strconv \
strings \
sync \
sync/atomic \
syscall \
testing \
testing/fstest \
testing/iotest \
testing/quick \
time
all: build.zig build.tinygo build.gowasip1
@@ -141,5 +141,7 @@ build.gowasip1:
@mkdir -p $(gowasip1_bin)
@cd '$(goroot)'; \
for value in $(gowasip1_tests); do\
if [ -d ./$${value} ]; then\
GOOS=wasip1 GOARCH=wasm go test -v -c -o $(gowasip1_bin)/$$(echo $$value | sed -e 's/\//_/g').test ./$${value}; \
fi;\
done
@@ -81,7 +81,7 @@ var (
}
fsuffixstripped := strings.ReplaceAll(fname, ".test", "")
inferredpath := strings.ReplaceAll(fsuffixstripped, "_", "/")
testdir := filepath.Join(runtime.GOROOT(), inferredpath)
testdir := filepath.Join(runtime.GOROOT(), "src", inferredpath)
err = os.Chdir(testdir)
sysroot := filepath.VolumeName(testdir) + string(os.PathSeparator)
@@ -91,20 +91,29 @@ var (
c = c.WithFSConfig(
wazero.NewFSConfig().
WithDirMount(sysroot, "/")).
WithEnv("PWD", normalizedTestdir)
WithEnv("PWD", normalizedTestdir).
WithEnv("GOWASIRUNTIME", "wazero")
args := []string{fname, "-test.short", "-test.v"}
// Some distributions of Go such as used by homebrew or GitHub actions do not
// contain the LICENSE file in the correct location for these.
skip := []string{
"TestFileReaddir/sysdir",
"TestFileReadDir/sysdir",
"TestFileReaddirnames/sysdir",
}
// Skip tests that are fragile on Windows.
if runtime.GOOS == "windows" {
c = c.
WithEnv("GOROOT", normalizeOsPath(runtime.GOROOT()))
args = append(args,
"-test.skip=TestRenameCaseDifference/dir|"+
"TestDirFSPathsValid|TestDirFS|TestDevNullFile|"+
"TestOpenError|TestSymlinkWithTrailingSlash|TestCopyFS")
skip = append(skip, "TestRenameCaseDifference/dir", "TestDirFSPathsValid", "TestDirFS",
"TestDevNullFile", "TestOpenError", "TestSymlinkWithTrailingSlash", "TestCopyFS",
"TestRoot", "TestOpenInRoot", "ExampleAfterFunc_connection")
}
args = append(args, "-test.skip="+strings.Join(skip, "|"))
c = c.WithArgs(args...)
return bin, c, stdout, stderr, err
@@ -193,11 +202,15 @@ func requireZeroExitCode(b *testing.B, err error, stdout, stderr *os.File) {
b.Helper()
if se, ok := err.(*sys.ExitError); ok {
if se.ExitCode() != 0 { // Don't err on success.
stdout.Seek(0, io.SeekStart)
stderr.Seek(0, io.SeekStart)
stdoutBytes, _ := io.ReadAll(stdout)
stderrBytes, _ := io.ReadAll(stderr)
require.NoError(b, err, "stdout: %s\nstderr: %s", string(stdoutBytes), string(stderrBytes))
}
} else if err != nil {
stdout.Seek(0, io.SeekStart)
stderr.Seek(0, io.SeekStart)
stdoutBytes, _ := io.ReadAll(stdout)
stderrBytes, _ := io.ReadAll(stderr)
require.NoError(b, err, "stdout: %s\nstderr: %s", string(stdoutBytes), string(stderrBytes))
+3
View File
@@ -275,6 +275,9 @@ func (f *osFile) Pwrite(buf []byte, off int64) (n int, errno experimentalsys.Err
// Truncate implements the same method as documented on sys.File
func (f *osFile) Truncate(size int64) (errno experimentalsys.Errno) {
if size < 0 {
return experimentalsys.EINVAL
}
if errno = experimentalsys.UnwrapOSError(f.file.Truncate(size)); errno != 0 {
// Defer validation overhead until we've already had an error.
errno = fileError(f, f.closed, errno)
+9 -10
View File
@@ -1,19 +1,18 @@
const std = @import("std");
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *std.build.Builder) void {
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "main",
.root_source_file = b.path("main.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
// Don't use wasi because this calls os_exit on panic. An ExitError isn't
// wrapped due to logic in FromRecovered.
// TODO: Find another way to avoid re-wrapping!
const target = .{.cpu_arch = .wasm32, .os_tag = .freestanding};
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "main",
.root_source_file = .{ .path = "main.zig" },
.target = target,
.optimize = optimize,
.os_tag = .freestanding,
}),
.optimize = b.standardOptimizeOption(.{}),
});
b.installArtifact(exe);
}
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/tetratelabs/wazero/internal/version/testdata
go 1.21
go 1.22.0
require github.com/tetratelabs/wazero v0.0.0-20220818123113-1948909ec0b1 // indirect
+16 -16
View File
@@ -20,7 +20,7 @@ func TestDWARFLines_Line_Zig(t *testing.T) {
// codeSecStart is the beginning of the code section in the Wasm binary.
// If dwarftestdata.ZigWasm has been changed, we need to inspect by `wasm-tools objdump`.
const codeSecStart = 0x46
const codeSecStart = 0x48
// These cases are crafted by matching the stack trace result from wasmtime. To verify, run:
//
@@ -31,31 +31,31 @@ func TestDWARFLines_Line_Zig(t *testing.T) {
// Caused by:
// 0: failed to invoke command default
// 1: error while executing at wasm backtrace:
// 0: 0xa9 - builtin.default_panic
// at /Users/adrian/Downloads/zig-macos-aarch64-0.11.0-dev.3334+cd1417dbd/lib/std/builtin.zig:889:17
// 1: 0x6b - main.inlined_b
// at /Users/adrian/oss/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:10:5 - main.inlined_a
// at /Users/adrian/oss/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:6:5 - main.main
// at /Users/adrian/oss/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:2:5
// 2: 0xb0 - start.callMain
// at /Users/adrian/Downloads/zig-macos-aarch64-0.11.0-dev.3334+cd1417dbd/lib/std/start.zig:609:37 - _start
// at /Users/adrian/Downloads/zig-macos-aarch64-0.11.0-dev.3334+cd1417dbd/lib/std/start.zig:224:5
// 0: 0xab - builtin.default_panic
// at /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/builtin.zig:792:17
// 1: 0x6d - main.inlined_b
// at /Users/anuraag/git/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:10:5 - main.inlined_a
// at /Users/anuraag/git/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:6:5 - main.main
// at /Users/anuraag/git/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:2:5
// 2: 0x119 - start.callMain
// at /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/start.zig:524:37 - start.wasm_freestanding_start
// at /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/start.zig:199:5
// 2: wasm trap: wasm `unreachable` instruction executed
for _, tc := range []struct {
offset uint64
exp []string
}{
{offset: 0xa9 - codeSecStart, exp: []string{
"lib/std/builtin.zig:889:17",
{offset: 0xab - codeSecStart, exp: []string{
"lib/zig/std/builtin.zig:792:17",
}},
{offset: 0x6b - codeSecStart, exp: []string{
{offset: 0x6d - codeSecStart, exp: []string{
"zig/main.zig:10:5 (inlined)",
"zig/main.zig:6:5 (inlined)",
"zig/main.zig:2:5",
}},
{offset: 0xb0 - codeSecStart, exp: []string{
"lib/std/start.zig:609:37 (inlined)",
"lib/std/start.zig:224:5",
{offset: 0x119 - codeSecStart, exp: []string{
"lib/zig/std/start.zig:524:37 (inlined)",
"lib/zig/std/start.zig:199:5",
}},
} {
tc := tc