Skip to content

Commit 0c09dd8

Browse files
authored
Add wasmtime to CI. (#212)
1 parent 31c5000 commit 0c09dd8

18 files changed

+55
-63
lines changed

.github/workflows/cross.sh

-25
This file was deleted.

.github/workflows/cross.yml

-16
This file was deleted.

.github/workflows/repro.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ embed/build.sh
2727
embed/bcw2/build.sh
2828

2929
# Download and build sqlite-createtable-parser
30-
util/sql3util/parse/download.sh
31-
util/sql3util/parse/build.sh
30+
util/sql3util/wasm/download.sh
31+
util/sql3util/wasm/build.sh
3232

3333
# Check diffs
3434
git diff --exit-code

.github/workflows/repro.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
subject-path: |
3030
embed/sqlite3.wasm
3131
embed/bcw2/bcw2.wasm
32-
util/sql3util/parse/sql3parse_table.wasm
32+
util/sql3util/wasm/sql3parse_table.wasm

.github/workflows/test.yml

+24-5
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ name: Test
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ 'main' ]
66
paths:
77
- '**.go'
88
- '**.mod'
99
- '**.wasm'
10-
- '**.wasm.bz2'
1110
pull_request:
12-
branches: [ "main" ]
11+
branches: [ 'main' ]
1312
paths:
1413
- '**.go'
1514
- '**.mod'
1615
- '**.wasm'
17-
- '**.wasm.bz2'
1816
workflow_dispatch:
1917

2018
jobs:
@@ -161,6 +159,27 @@ jobs:
161159
copyback: false
162160
run: . ./test.sh
163161

162+
test-wasip1:
163+
runs-on: ubuntu-latest
164+
needs: test
165+
166+
steps:
167+
- uses: bytecodealliance/actions/wasmtime/setup@v1
168+
- uses: actions/checkout@v4
169+
- uses: actions/setup-go@v5
170+
with: { go-version: stable }
171+
172+
- name: Set path
173+
run: echo "$(go env GOROOT)/misc/wasm" >> "$GITHUB_PATH"
174+
175+
- name: Test wasmtime
176+
env:
177+
GOOS: wasip1
178+
GOARCH: wasm
179+
GOWASIRUNTIME: wasmtime
180+
GOWASIRUNTIMEARGS: '--env CI=true'
181+
run: go test -v -short -tags sqlite3_dotlk -skip Example ./...
182+
164183
test-qemu:
165184
runs-on: ubuntu-latest
166185
needs: test
@@ -196,4 +215,4 @@ jobs:
196215
with: { go-version: stable }
197216

198217
- name: Test
199-
run: go test -v ./...
218+
run: go test -v ./...

conn.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"math"
77
"math/rand"
88
"net/url"
9+
"runtime"
910
"strings"
1011
"time"
1112

@@ -375,8 +376,13 @@ func (c *Conn) checkInterrupt(handle uint32) {
375376
}
376377

377378
func progressCallback(ctx context.Context, mod api.Module, _ uint32) (interrupt uint32) {
378-
if c, ok := ctx.Value(connKey{}).(*Conn); ok && c.interrupt.Err() != nil {
379-
interrupt = 1
379+
if c, ok := ctx.Value(connKey{}).(*Conn); ok {
380+
if c.interrupt.Done() != nil {
381+
runtime.Gosched()
382+
}
383+
if c.interrupt.Err() != nil {
384+
interrupt = 1
385+
}
380386
}
381387
return interrupt
382388
}

go.work.sum

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
1212
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
1313
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
1414
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
15+
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
1516
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
1617
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=

tests/conn_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ func TestConn_SetInterrupt(t *testing.T) {
130130
t.Fatal(err)
131131
}
132132

133-
db.SetInterrupt(context.Background())
134-
135133
stmt, _, err := db.Prepare(`
136134
WITH RECURSIVE
137135
fibonacci (curr, next)
@@ -148,7 +146,6 @@ func TestConn_SetInterrupt(t *testing.T) {
148146
}
149147
defer stmt.Close()
150148

151-
db.SetInterrupt(ctx)
152149
go func() {
153150
time.Sleep(time.Millisecond)
154151
cancel()

util/sql3util/parse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
)
1818

1919
var (
20-
//go:embed parse/sql3parse_table.wasm
20+
//go:embed wasm/sql3parse_table.wasm
2121
binary []byte
2222
once sync.Once
2323
runtime wazero.Runtime
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

vfs/file.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io/fs"
77
"os"
88
"path/filepath"
9-
"runtime"
109
"syscall"
1110

1211
"github.com/ncruces/go-sqlite3/util/osutil"
@@ -41,7 +40,7 @@ func (vfsOS) Delete(path string, syncDir bool) error {
4140
if err != nil {
4241
return err
4342
}
44-
if runtime.GOOS != "windows" && syncDir {
43+
if canSyncDirs && syncDir {
4544
f, err := os.Open(filepath.Dir(path))
4645
if err != nil {
4746
return _OK
@@ -120,9 +119,9 @@ func (vfsOS) OpenFilename(name *Filename, flags OpenFlag) (File, OpenFlag, error
120119
File: f,
121120
psow: true,
122121
readOnly: flags&OPEN_READONLY != 0,
123-
syncDir: runtime.GOOS != "windows" &&
124-
flags&(OPEN_CREATE) != 0 &&
125-
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0,
122+
syncDir: canSyncDirs &&
123+
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0 &&
124+
flags&(OPEN_CREATE) != 0,
126125
shm: NewSharedMemory(name.String()+"-shm", flags),
127126
}
128127
return &file, flags, nil
@@ -163,7 +162,7 @@ func (f *vfsFile) Sync(flags SyncFlag) error {
163162
if err != nil {
164163
return err
165164
}
166-
if runtime.GOOS != "windows" && f.syncDir {
165+
if canSyncDirs && f.syncDir {
167166
f.syncDir = false
168167
d, err := os.Open(filepath.Dir(f.File.Name()))
169168
if err != nil {

vfs/os_std.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import (
77
"os"
88
)
99

10-
const _O_NOFOLLOW = 0
10+
const (
11+
_O_NOFOLLOW = 0
12+
canSyncDirs = false
13+
)
1114

1215
func osAccess(path string, flags AccessFlag) error {
1316
fi, err := os.Stat(path)

vfs/os_unix.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import (
99
"golang.org/x/sys/unix"
1010
)
1111

12-
const _O_NOFOLLOW = unix.O_NOFOLLOW
12+
const (
13+
_O_NOFOLLOW = unix.O_NOFOLLOW
14+
canSyncDirs = true
15+
)
1316

1417
func osAccess(path string, flags AccessFlag) error {
1518
var access uint32 // unix.F_OK

vfs/vfs_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ func Test_vfsAccess(t *testing.T) {
194194
t.Error("can't access file")
195195
}
196196

197+
if fi, err := os.Stat(file); err != nil {
198+
t.Fatal(err)
199+
} else if fi.Mode().Perm()&0700 != syscall.S_IRUSR {
200+
t.Skip("skipping due to permissions")
201+
}
197202
if usr, err := user.Current(); err == nil && usr.Uid == "0" {
198203
t.Skip("skipping as root")
199204
}

0 commit comments

Comments
 (0)