mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Add wasmtime to CI. (#212)
This commit is contained in:
25
.github/workflows/cross.sh
vendored
25
.github/workflows/cross.sh
vendored
@@ -1,25 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
echo android ; GOOS=android GOARCH=amd64 go build .
|
|
||||||
echo darwin ; GOOS=darwin GOARCH=amd64 go build .
|
|
||||||
echo dragonfly ; GOOS=dragonfly GOARCH=amd64 go build .
|
|
||||||
echo freebsd ; GOOS=freebsd GOARCH=amd64 go build .
|
|
||||||
echo illumos ; GOOS=illumos GOARCH=amd64 go build .
|
|
||||||
echo ios ; GOOS=ios GOARCH=amd64 go build .
|
|
||||||
echo linux ; GOOS=linux GOARCH=amd64 go build .
|
|
||||||
echo netbsd ; GOOS=netbsd GOARCH=amd64 go build .
|
|
||||||
echo openbsd ; GOOS=openbsd GOARCH=amd64 go build .
|
|
||||||
echo plan9 ; GOOS=plan9 GOARCH=amd64 go build .
|
|
||||||
echo solaris ; GOOS=solaris GOARCH=amd64 go build .
|
|
||||||
echo windows ; GOOS=windows GOARCH=amd64 go build .
|
|
||||||
echo aix ; GOOS=aix GOARCH=ppc64 go build .
|
|
||||||
echo js ; GOOS=js GOARCH=wasm go build .
|
|
||||||
echo wasip1 ; GOOS=wasip1 GOARCH=wasm go build .
|
|
||||||
echo linux-flock ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_flock .
|
|
||||||
echo linux-dotlk ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_dotlk .
|
|
||||||
echo darwin-flock ; GOOS=darwin GOARCH=amd64 go build -tags sqlite3_flock .
|
|
||||||
echo darwin-dotlk ; GOOS=darwin GOARCH=amd64 go build -tags sqlite3_dotlk .
|
|
||||||
echo windows-dotlk ; GOOS=windows GOARCH=amd64 go build -tags sqlite3_dotlk .
|
|
||||||
echo freebsd-dotlk ; GOOS=freebsd GOARCH=amd64 go build -tags sqlite3_dotlk .
|
|
||||||
echo solaris-dotlk ; GOOS=solaris GOARCH=amd64 go build -tags sqlite3_dotlk .
|
|
||||||
16
.github/workflows/cross.yml
vendored
16
.github/workflows/cross.yml
vendored
@@ -1,16 +0,0 @@
|
|||||||
name: Cross compile
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with: { go-version: stable }
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: .github/workflows/cross.sh
|
|
||||||
4
.github/workflows/repro.sh
vendored
4
.github/workflows/repro.sh
vendored
@@ -27,8 +27,8 @@ embed/build.sh
|
|||||||
embed/bcw2/build.sh
|
embed/bcw2/build.sh
|
||||||
|
|
||||||
# Download and build sqlite-createtable-parser
|
# Download and build sqlite-createtable-parser
|
||||||
util/sql3util/parse/download.sh
|
util/sql3util/wasm/download.sh
|
||||||
util/sql3util/parse/build.sh
|
util/sql3util/wasm/build.sh
|
||||||
|
|
||||||
# Check diffs
|
# Check diffs
|
||||||
git diff --exit-code
|
git diff --exit-code
|
||||||
2
.github/workflows/repro.yml
vendored
2
.github/workflows/repro.yml
vendored
@@ -29,4 +29,4 @@ jobs:
|
|||||||
subject-path: |
|
subject-path: |
|
||||||
embed/sqlite3.wasm
|
embed/sqlite3.wasm
|
||||||
embed/bcw2/bcw2.wasm
|
embed/bcw2/bcw2.wasm
|
||||||
util/sql3util/parse/sql3parse_table.wasm
|
util/sql3util/wasm/sql3parse_table.wasm
|
||||||
29
.github/workflows/test.yml
vendored
29
.github/workflows/test.yml
vendored
@@ -2,19 +2,17 @@ name: Test
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [ 'main' ]
|
||||||
paths:
|
paths:
|
||||||
- '**.go'
|
- '**.go'
|
||||||
- '**.mod'
|
- '**.mod'
|
||||||
- '**.wasm'
|
- '**.wasm'
|
||||||
- '**.wasm.bz2'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ 'main' ]
|
||||||
paths:
|
paths:
|
||||||
- '**.go'
|
- '**.go'
|
||||||
- '**.mod'
|
- '**.mod'
|
||||||
- '**.wasm'
|
- '**.wasm'
|
||||||
- '**.wasm.bz2'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -161,6 +159,27 @@ jobs:
|
|||||||
copyback: false
|
copyback: false
|
||||||
run: . ./test.sh
|
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:
|
test-qemu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: test
|
needs: test
|
||||||
@@ -196,4 +215,4 @@ jobs:
|
|||||||
with: { go-version: stable }
|
with: { go-version: stable }
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test -v ./...
|
run: go test -v ./...
|
||||||
10
conn.go
10
conn.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -375,8 +376,13 @@ func (c *Conn) checkInterrupt(handle uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func progressCallback(ctx context.Context, mod api.Module, _ uint32) (interrupt uint32) {
|
func progressCallback(ctx context.Context, mod api.Module, _ uint32) (interrupt uint32) {
|
||||||
if c, ok := ctx.Value(connKey{}).(*Conn); ok && c.interrupt.Err() != nil {
|
if c, ok := ctx.Value(connKey{}).(*Conn); ok {
|
||||||
interrupt = 1
|
if c.interrupt.Done() != nil {
|
||||||
|
runtime.Gosched()
|
||||||
|
}
|
||||||
|
if c.interrupt.Err() != nil {
|
||||||
|
interrupt = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return interrupt
|
return interrupt
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
||||||
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
|
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.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.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
|
|||||||
@@ -130,8 +130,6 @@ func TestConn_SetInterrupt(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
db.SetInterrupt(context.Background())
|
|
||||||
|
|
||||||
stmt, _, err := db.Prepare(`
|
stmt, _, err := db.Prepare(`
|
||||||
WITH RECURSIVE
|
WITH RECURSIVE
|
||||||
fibonacci (curr, next)
|
fibonacci (curr, next)
|
||||||
@@ -148,7 +146,6 @@ func TestConn_SetInterrupt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
db.SetInterrupt(ctx)
|
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond)
|
||||||
cancel()
|
cancel()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//go:embed parse/sql3parse_table.wasm
|
//go:embed wasm/sql3parse_table.wasm
|
||||||
binary []byte
|
binary []byte
|
||||||
once sync.Once
|
once sync.Once
|
||||||
runtime wazero.Runtime
|
runtime wazero.Runtime
|
||||||
|
|||||||
11
vfs/file.go
11
vfs/file.go
@@ -6,7 +6,6 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/ncruces/go-sqlite3/util/osutil"
|
"github.com/ncruces/go-sqlite3/util/osutil"
|
||||||
@@ -41,7 +40,7 @@ func (vfsOS) Delete(path string, syncDir bool) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" && syncDir {
|
if canSyncDirs && syncDir {
|
||||||
f, err := os.Open(filepath.Dir(path))
|
f, err := os.Open(filepath.Dir(path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return _OK
|
return _OK
|
||||||
@@ -120,9 +119,9 @@ func (vfsOS) OpenFilename(name *Filename, flags OpenFlag) (File, OpenFlag, error
|
|||||||
File: f,
|
File: f,
|
||||||
psow: true,
|
psow: true,
|
||||||
readOnly: flags&OPEN_READONLY != 0,
|
readOnly: flags&OPEN_READONLY != 0,
|
||||||
syncDir: runtime.GOOS != "windows" &&
|
syncDir: canSyncDirs &&
|
||||||
flags&(OPEN_CREATE) != 0 &&
|
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0 &&
|
||||||
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0,
|
flags&(OPEN_CREATE) != 0,
|
||||||
shm: NewSharedMemory(name.String()+"-shm", flags),
|
shm: NewSharedMemory(name.String()+"-shm", flags),
|
||||||
}
|
}
|
||||||
return &file, flags, nil
|
return &file, flags, nil
|
||||||
@@ -163,7 +162,7 @@ func (f *vfsFile) Sync(flags SyncFlag) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" && f.syncDir {
|
if canSyncDirs && f.syncDir {
|
||||||
f.syncDir = false
|
f.syncDir = false
|
||||||
d, err := os.Open(filepath.Dir(f.File.Name()))
|
d, err := os.Open(filepath.Dir(f.File.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const _O_NOFOLLOW = 0
|
const (
|
||||||
|
_O_NOFOLLOW = 0
|
||||||
|
canSyncDirs = false
|
||||||
|
)
|
||||||
|
|
||||||
func osAccess(path string, flags AccessFlag) error {
|
func osAccess(path string, flags AccessFlag) error {
|
||||||
fi, err := os.Stat(path)
|
fi, err := os.Stat(path)
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"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 {
|
func osAccess(path string, flags AccessFlag) error {
|
||||||
var access uint32 // unix.F_OK
|
var access uint32 // unix.F_OK
|
||||||
|
|||||||
@@ -194,6 +194,11 @@ func Test_vfsAccess(t *testing.T) {
|
|||||||
t.Error("can't access file")
|
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" {
|
if usr, err := user.Current(); err == nil && usr.Uid == "0" {
|
||||||
t.Skip("skipping as root")
|
t.Skip("skipping as root")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user