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

Add wasmtime to CI. #212

Merged
merged 3 commits into from
Jan 7, 2025
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
25 changes: 0 additions & 25 deletions .github/workflows/cross.sh

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/cross.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/repro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ embed/build.sh
embed/bcw2/build.sh

# Download and build sqlite-createtable-parser
util/sql3util/parse/download.sh
util/sql3util/parse/build.sh
util/sql3util/wasm/download.sh
util/sql3util/wasm/build.sh

# Check diffs
git diff --exit-code
2 changes: 1 addition & 1 deletion .github/workflows/repro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
subject-path: |
embed/sqlite3.wasm
embed/bcw2/bcw2.wasm
util/sql3util/parse/sql3parse_table.wasm
util/sql3util/wasm/sql3parse_table.wasm
29 changes: 24 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ name: Test

on:
push:
branches: [ "main" ]
branches: [ 'main' ]
paths:
- '**.go'
- '**.mod'
- '**.wasm'
- '**.wasm.bz2'
pull_request:
branches: [ "main" ]
branches: [ 'main' ]
paths:
- '**.go'
- '**.mod'
- '**.wasm'
- '**.wasm.bz2'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -161,6 +159,27 @@ jobs:
copyback: false
run: . ./test.sh

test-wasip1:
runs-on: ubuntu-latest
needs: test

steps:
- uses: bytecodealliance/actions/wasmtime/setup@v1
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version: stable }

- name: Set path
run: echo "$(go env GOROOT)/misc/wasm" >> "$GITHUB_PATH"

- name: Test wasmtime
env:
GOOS: wasip1
GOARCH: wasm
GOWASIRUNTIME: wasmtime
GOWASIRUNTIMEARGS: '--env CI=true'
run: go test -v -short -tags sqlite3_dotlk -skip Example ./...

test-qemu:
runs-on: ubuntu-latest
needs: test
Expand Down Expand Up @@ -196,4 +215,4 @@ jobs:
with: { go-version: stable }

- name: Test
run: go test -v ./...
run: go test -v ./...
10 changes: 8 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math"
"math/rand"
"net/url"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -375,8 +376,13 @@ func (c *Conn) checkInterrupt(handle uint32) {
}

func progressCallback(ctx context.Context, mod api.Module, _ uint32) (interrupt uint32) {
if c, ok := ctx.Value(connKey{}).(*Conn); ok && c.interrupt.Err() != nil {
interrupt = 1
if c, ok := ctx.Value(connKey{}).(*Conn); ok {
if c.interrupt.Done() != nil {
runtime.Gosched()
}
if c.interrupt.Err() != nil {
interrupt = 1
}
}
return interrupt
}
Expand Down
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
3 changes: 0 additions & 3 deletions tests/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ func TestConn_SetInterrupt(t *testing.T) {
t.Fatal(err)
}

db.SetInterrupt(context.Background())

stmt, _, err := db.Prepare(`
WITH RECURSIVE
fibonacci (curr, next)
Expand All @@ -148,7 +146,6 @@ func TestConn_SetInterrupt(t *testing.T) {
}
defer stmt.Close()

db.SetInterrupt(ctx)
go func() {
time.Sleep(time.Millisecond)
cancel()
Expand Down
2 changes: 1 addition & 1 deletion util/sql3util/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
)

var (
//go:embed parse/sql3parse_table.wasm
//go:embed wasm/sql3parse_table.wasm
binary []byte
once sync.Once
runtime wazero.Runtime
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions vfs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"syscall"

"github.com/ncruces/go-sqlite3/util/osutil"
Expand Down Expand Up @@ -41,7 +40,7 @@ func (vfsOS) Delete(path string, syncDir bool) error {
if err != nil {
return err
}
if runtime.GOOS != "windows" && syncDir {
if canSyncDirs && syncDir {
f, err := os.Open(filepath.Dir(path))
if err != nil {
return _OK
Expand Down Expand Up @@ -120,9 +119,9 @@ func (vfsOS) OpenFilename(name *Filename, flags OpenFlag) (File, OpenFlag, error
File: f,
psow: true,
readOnly: flags&OPEN_READONLY != 0,
syncDir: runtime.GOOS != "windows" &&
flags&(OPEN_CREATE) != 0 &&
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0,
syncDir: canSyncDirs &&
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0 &&
flags&(OPEN_CREATE) != 0,
shm: NewSharedMemory(name.String()+"-shm", flags),
}
return &file, flags, nil
Expand Down Expand Up @@ -163,7 +162,7 @@ func (f *vfsFile) Sync(flags SyncFlag) error {
if err != nil {
return err
}
if runtime.GOOS != "windows" && f.syncDir {
if canSyncDirs && f.syncDir {
f.syncDir = false
d, err := os.Open(filepath.Dir(f.File.Name()))
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion vfs/os_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"os"
)

const _O_NOFOLLOW = 0
const (
_O_NOFOLLOW = 0
canSyncDirs = false
)

func osAccess(path string, flags AccessFlag) error {
fi, err := os.Stat(path)
Expand Down
5 changes: 4 additions & 1 deletion vfs/os_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
"golang.org/x/sys/unix"
)

const _O_NOFOLLOW = unix.O_NOFOLLOW
const (
_O_NOFOLLOW = unix.O_NOFOLLOW
canSyncDirs = true
)

func osAccess(path string, flags AccessFlag) error {
var access uint32 // unix.F_OK
Expand Down
5 changes: 5 additions & 0 deletions vfs/vfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ func Test_vfsAccess(t *testing.T) {
t.Error("can't access file")
}

if fi, err := os.Stat(file); err != nil {
t.Fatal(err)
} else if fi.Mode().Perm()&0700 != syscall.S_IRUSR {
t.Skip("skipping due to permissions")
}
if usr, err := user.Current(); err == nil && usr.Uid == "0" {
t.Skip("skipping as root")
}
Expand Down
Loading