Skip to content
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
33 changes: 32 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# Node 18 and 20 bundle node-gyp versions that do not yet recognize
# the Visual Studio 2026 installation on windows-latest. Keep the
# compatibility matrix on VS 2022; release-windows below exercises
# the current publishing image with the current node-gyp.
os: [ubuntu-latest, macos-latest, windows-2022]
node: ["18", "20", "22"]

steps:
Expand All @@ -31,3 +35,30 @@ jobs:

- name: Run tests
run: bun test test/

release-windows:
name: Windows release toolchain
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies without building
run: npm install --ignore-scripts

- name: Download amalgamation
run: node scripts/download.js

- name: Build with the publishing toolchain
run: npx node-gyp rebuild

- name: Run tests
run: bun test test/
3 changes: 2 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"libraries": ["-lpthread"]
}],
["OS=='win'", {
"defines": ["strncasecmp=_strnicmp"]
"defines": ["strncasecmp=_strnicmp"],
"libraries": ["Ws2_32.lib"]
}]
]
}
Expand Down
18 changes: 11 additions & 7 deletions scripts/build-amalgamation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ if (!fs.existsSync(inH)) {
console.log("Preparing released doltlite amalgamation...")
fs.mkdirSync(outDir, { recursive: true })
let amalgamation = fs.readFileSync(inC, "utf8")
amalgamation += `

#if defined(DOLTLITE_PROLLY) && defined(SQLITE_USE_SEH) && !defined(SQLITE_OMIT_WAL)
SQLITE_PRIVATE int sqlite3PagerWalSystemErrno(Pager *pPager){
(void)pPager;
return 0;
}
// DoltLite releases before v0.11.37 emitted the Winsock 2 headers after
// SQLite's Windows VFS had already included windows.h. Keep those releases
// buildable while newer release amalgamations carry the ordering fix directly.
if (!amalgamation.includes("DOLTLITE_AMALGAMATION_WINSOCK2_EARLY")) {
amalgamation = `/* DOLTLITE_NODE_WINSOCK2_EARLY_FALLBACK */
#ifdef _WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
#endif
`

${amalgamation}`
}
fs.writeFileSync(outC, amalgamation)
fs.copyFileSync(inH, outH)
fs.writeFileSync(versionMarker, `${pkg.version}\n`)
Expand Down
40 changes: 40 additions & 0 deletions test/amalgamation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { describe, expect, test } from "bun:test"
import { existsSync, readFileSync } from "fs"
import { join } from "path"

const sourcePath = join(import.meta.dir, "..", "amalgamation", ".source", "sqlite3.c")
const outputPath = join(import.meta.dir, "..", "amalgamation", "doltlite.c")

describe("released amalgamation preparation", () => {
test("preserves the core SEH pager shim without appending a duplicate", () => {
expect(existsSync(sourcePath)).toBe(true)
expect(existsSync(outputPath)).toBe(true)

const source = readFileSync(sourcePath, "utf8")
const output = readFileSync(outputPath, "utf8")
const definition = /^(?:SQLITE_PRIVATE )?int sqlite3PagerWalSystemErrno\(Pager \*pPager\)\{/gm

expect(output.match(definition)?.length ?? 0).toBe(source.match(definition)?.length ?? 0)
})

test("selects Winsock 2 before the first windows.h include", () => {
const output = readFileSync(outputPath, "utf8")
const winsock = output.search(/^# *include <winsock2\.h>/m)
const windows = output.search(/^# *include [<"]windows\.h[>"]/m)

expect(winsock).toBeGreaterThanOrEqual(0)
expect(windows).toBeGreaterThanOrEqual(0)
expect(winsock).toBeLessThan(windows)
})

test("uses an unmodified fixed release amalgamation", () => {
const source = readFileSync(sourcePath, "utf8")
const output = readFileSync(outputPath, "utf8")

if (source.includes("DOLTLITE_AMALGAMATION_WINSOCK2_EARLY")) {
expect(output).toBe(source)
} else {
expect(output).toContain("DOLTLITE_NODE_WINSOCK2_EARLY_FALLBACK")
}
})
})
Loading