diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-01-02 15:16:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-02 15:16:48 +0200 |
| commit | 39358b1517a06b90b9886a648ce1c595d1556c8e (patch) | |
| tree | 60103dae88acaf549fb684b7cfc65f8c133a5bc4 | |
| parent | 3bcb1e10d3e97309ff8ede707dc5c3c057ba27ca (diff) | |
| download | karakeep-39358b1517a06b90b9886a648ce1c595d1556c8e.tar.zst | |
ci: Run tests on push (#807)
* ci: Run tests on push
* disable drizzle logging in tests
* run db migrations in trpc tests
| -rw-r--r-- | .github/workflows/ci.yml | 10 | ||||
| -rw-r--r-- | apps/web/package.json | 1 | ||||
| -rw-r--r-- | package.json | 3 | ||||
| -rw-r--r-- | packages/db/drizzle.ts | 2 | ||||
| -rw-r--r-- | packages/shared/package.json | 3 | ||||
| -rw-r--r-- | packages/trpc/package.json | 3 | ||||
| -rw-r--r-- | packages/trpc/testUtils.ts | 2 | ||||
| -rw-r--r-- | turbo.json | 1 |
8 files changed, 20 insertions, 5 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8216c7cf..127c7990 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,16 @@ jobs: - name: Typecheck run: pnpm typecheck + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup + uses: ./tooling/github/setup + + - name: Tests + run: pnpm test open-api-spec: runs-on: ubuntu-latest steps: diff --git a/apps/web/package.json b/apps/web/package.json index ec0a3bd2..d78b1d4d 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -10,7 +10,6 @@ "build": "next build", "start": "next start", "lint": "next lint", - "test": "vitest", "typecheck": "tsc --noEmit", "format": "prettier --check . --ignore-path ../../.gitignore", "format:fix": "prettier --write . --ignore-path ../../.gitignore", diff --git a/package.json b/package.json index 66bfbaee..c9ad5633 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "lint:fix": "turbo --no-daemon lint --continue -- --fix --cache-location node_modules/.cache/.eslintcache", "lint:ws": "pnpm dlx sherif@latest", "postinstall": "pnpm lint:ws", - "typecheck": "turbo --no-daemon typecheck" + "typecheck": "turbo --no-daemon typecheck", + "test": "turbo --no-daemon test --continue" }, "devDependencies": { "@hoarder/prettier-config": "workspace:^0.1.0", diff --git a/packages/db/drizzle.ts b/packages/db/drizzle.ts index 4763d9d7..037f7c35 100644 --- a/packages/db/drizzle.ts +++ b/packages/db/drizzle.ts @@ -12,7 +12,7 @@ export const db = drizzle(sqlite, { schema }); export function getInMemoryDB(runMigrations: boolean) { const mem = new Database(":memory:"); - const db = drizzle(mem, { schema, logger: true }); + const db = drizzle(mem, { schema, logger: false }); if (runMigrations) { migrate(db, { migrationsFolder: path.resolve(__dirname, "./drizzle") }); } diff --git a/packages/shared/package.json b/packages/shared/package.json index 93d5495a..b5a001b9 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -26,7 +26,8 @@ "format:fix": "prettier . --write --ignore-path ../../.prettierignore", "lint": "eslint .", "lint:fix": "eslint . --fix", - "test": "vitest" + "test": "vitest run", + "test:watch": "vitest" }, "main": "index.ts", "eslintConfig": { diff --git a/packages/trpc/package.json b/packages/trpc/package.json index 0e1721f1..00652b8d 100644 --- a/packages/trpc/package.json +++ b/packages/trpc/package.json @@ -10,7 +10,8 @@ "format:fix": "prettier . --write --ignore-path ../../.prettierignore", "lint": "eslint .", "lint:fix": "eslint . --fix", - "test": "vitest" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@hoarder/db": "workspace:*", diff --git a/packages/trpc/testUtils.ts b/packages/trpc/testUtils.ts index 23dcdb33..6d7e6dee 100644 --- a/packages/trpc/testUtils.ts +++ b/packages/trpc/testUtils.ts @@ -1,5 +1,6 @@ import { getInMemoryDB } from "@hoarder/db/drizzle"; import { users } from "@hoarder/db/schema"; +import { runQueueDBMigrations } from "@hoarder/shared/queues"; import { createCallerFactory } from "./index"; import { appRouter } from "./routers/_app"; @@ -54,6 +55,7 @@ export interface CustomTestContext { export async function buildTestContext( seedDB: boolean, ): Promise<CustomTestContext> { + runQueueDBMigrations(); const db = getTestDB(); let users: Awaited<ReturnType<typeof seedUsers>> = []; if (seedDB) { @@ -48,6 +48,7 @@ "node_modules/.cache/tsbuildinfo.json" ] }, + "test": {}, "clean": { "cache": false }, |
