Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
ci: fail loudly when DB-backed tests cannot run
Alcahest91f94262f6a7
diff --git a/.github/workflows/build-and-notarize.yml b/.github/workflows/build-and-notarize.ymlindex df4e1c386..9d759755b 100644--- a/.github/workflows/build-and-notarize.yml+++ b/.github/workflows/build-and-notarize.yml@@ -34,6 +34,8 @@ jobs:env:# keeps require("electron") from throwing when postinstall was skippedELECTRON_OVERRIDE_DIST_PATH: /tmp+ # a skipped DB test here means the rebuild step above is gone: fail instead+ REQUIRE_DB_TESTS: "1"build-linux:needs: testsdiff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 3c5e9d7f5..26befd5ef 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -24,3 +24,5 @@ jobs:env:# keeps require("electron") from throwing when postinstall was skippedELECTRON_OVERRIDE_DIST_PATH: /tmp+ # a skipped DB test here means the rebuild step above is gone: fail instead+ REQUIRE_DB_TESTS: "1"diff --git a/test/helpers/harness/db.js b/test/helpers/harness/db.jsnew file mode 100644index 000000000..25a5e33ed--- /dev/null+++ b/test/helpers/harness/db.js@@ -0,0 +1,31 @@+const REQUIRED_DB_FAILURE =+ "DB-backed tests were required (REQUIRE_DB_TESTS is set) but the better-sqlite3 native " ++ "binding could not be loaded, so this test would have been skipped instead of run. In CI " ++ "this almost always means the step that rebuilds better-sqlite3 for the runner's Node " ++ '("npm rebuild better-sqlite3", right after "npm ci --ignore-scripts") is missing or ' ++ "failed. Restore that step instead of deleting this check: without it every DB test " ++ "skips and the suite stays green with no database coverage. Underlying error: ";++function isNativeBindingUnavailable(error) {+ const message = String(error?.message || error);+ return (+ message.includes("NODE_MODULE_VERSION") ||+ message.includes("Could not locate the bindings file") ||+ message.includes("ERR_DLOPEN_FAILED") ||+ error?.code === "ERR_DLOPEN_FAILED"+ );+}++// Locally the binding is built for Electron's ABI, so a plain `node` run must skip. In CI the+// rebuild step makes it loadable, so a skip there means that step vanished and must fail.+function skipOrFail(t, error) {+ if (!isNativeBindingUnavailable(error)) {+ throw error;+ }+ if (process.env.REQUIRE_DB_TESTS) {+ throw new Error(REQUIRED_DB_FAILURE + String(error?.message || error), { cause: error });+ }+ t.skip("better-sqlite3 native binding is not available for this Node runtime");+}++module.exports = { isNativeBindingUnavailable, skipOrFail };diff --git a/test/helpers/noteCloudUpsertGuard.test.js b/test/helpers/noteCloudUpsertGuard.test.jsindex 7c5dd4a9c..4018780b7 100644--- a/test/helpers/noteCloudUpsertGuard.test.js+++ b/test/helpers/noteCloudUpsertGuard.test.js@@ -25,14 +25,7 @@ process.env.NODE_ENV = "test";const DatabaseManager = require("../../src/helpers/database.js");const loadGuards = () => import("../../src/helpers/cloudSyncGuards.js");--function isNativeBindingUnavailable(error) {- const message = String(error?.message || error);- return (- message.includes("NODE_MODULE_VERSION") ||- message.includes("Could not locate the bindings file")- );-}+const { skipOrFail } = require("./harness/db.js");function createDb(t) {userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), "openwhispr-note-sync-db-"));@@ -42,21 +35,15 @@ function createDb(t) {probe.close();fs.rmSync(path.join(userDataDir, "probe.db"), { force: true });} catch (error) {- if (isNativeBindingUnavailable(error)) {- t.skip("better-sqlite3 native binding is not available for this Node runtime");- return null;- }- throw error;+ skipOrFail(t, error);+ return null;}try {return new DatabaseManager();} catch (error) {- if (isNativeBindingUnavailable(error)) {- t.skip("better-sqlite3 native binding is not available for this Node runtime");- return null;- }- throw error;+ skipOrFail(t, error);+ return null;}}diff --git a/test/helpers/snippetsDatabase.test.js b/test/helpers/snippetsDatabase.test.jsindex 248c33d44..a59cecf4a 100644--- a/test/helpers/snippetsDatabase.test.js+++ b/test/helpers/snippetsDatabase.test.js@@ -24,13 +24,7 @@ Module._load = function patchedLoad(request, parent, isMain) {process.env.NODE_ENV = "test";const DatabaseManager = require("../../src/helpers/database.js");--function isNativeBindingUnavailable(error) {- const message = String(error?.message || error);- return (- message.includes("NODE_MODULE_VERSION") || message.includes("Could not locate the bindings file")- );-}+const { skipOrFail } = require("./harness/db.js");function createDb(t) {userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), "openwhispr-snippets-db-"));@@ -40,21 +34,15 @@ function createDb(t) {probe.close();fs.rmSync(path.join(userDataDir, "probe.db"), { force: true });} catch (error) {- if (isNativeBindingUnavailable(error)) {- t.skip("better-sqlite3 native binding is not available for this Node runtime");- return null;- }- throw error;+ skipOrFail(t, error);+ return null;}try {return new DatabaseManager();} catch (error) {- if (isNativeBindingUnavailable(error)) {- t.skip("better-sqlite3 native binding is not available for this Node runtime");- return null;- }- throw error;+ skipOrFail(t, error);+ return null;}}diff --git a/test/helpers/translationHistory.test.js b/test/helpers/translationHistory.test.jsindex 646ee84cc..2bdf4491f 100644--- a/test/helpers/translationHistory.test.js+++ b/test/helpers/translationHistory.test.js@@ -24,18 +24,7 @@ Module._load = function patchedLoad(request, parent, isMain) {process.env.NODE_ENV = "test";const DatabaseManager = require("../../src/helpers/database.js");--// The repo's better-sqlite3 binding is built for Electron's ABI, so a plain `node`-// runtime cannot dlopen it. Skip cleanly instead of failing in that case.-function isNativeBindingUnavailable(error) {- const message = String(error?.message || error);- return (- message.includes("NODE_MODULE_VERSION") ||- message.includes("Could not locate the bindings file") ||- message.includes("ERR_DLOPEN_FAILED") ||- error?.code === "ERR_DLOPEN_FAILED"- );-}+const { skipOrFail } = require("./harness/db.js");function createDb(t) {userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), "openwhispr-translation-db-"));@@ -45,21 +34,15 @@ function createDb(t) {probe.close();fs.rmSync(path.join(userDataDir, "probe.db"), { force: true });} catch (error) {- if (isNativeBindingUnavailable(error)) {- t.skip("better-sqlite3 native binding is not available for this Node runtime");- return null;- }- throw error;+ skipOrFail(t, error);+ return null;}try {return new DatabaseManager();} catch (error) {- if (isNativeBindingUnavailable(error)) {- t.skip("better-sqlite3 native binding is not available for this Node runtime");- return null;- }- throw error;+ skipOrFail(t, error);+ return null;}}