Skip to content

Commit

Permalink
ci: Run tests on push (#807)
Browse files Browse the repository at this point in the history
* ci: Run tests on push

* disable drizzle logging in tests

* run db migrations in trpc tests
  • Loading branch information
MohamedBassem authored Jan 2, 2025
1 parent 3bcb1e1 commit 39358b1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") });
}
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion packages/trpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
2 changes: 2 additions & 0 deletions packages/trpc/testUtils.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"node_modules/.cache/tsbuildinfo.json"
]
},
"test": {},
"clean": {
"cache": false
},
Expand Down

0 comments on commit 39358b1

Please sign in to comment.