Skip to content

Commit b6c2f18

Browse files
committed
fix ci
1 parent fb0ad1a commit b6c2f18

File tree

4 files changed

+10
-25
lines changed

4 files changed

+10
-25
lines changed

.env.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DATABASE_PATH="./tests/prisma/base.db"
2+
DATABASE_URL=file:../tests/prisma/base.db

.github/workflows/deploy.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
- name: 📥 Download deps
3131
uses: bahmutov/npm-install@v1
3232

33-
- name: 🏄 Copy test env vars
34-
run: cp .env.example .env
35-
3633
- name: 🛠 Setup Database
3734
run: npx prisma migrate deploy && npx prisma generate --sql
3835

@@ -57,9 +54,6 @@ jobs:
5754
- name: 🏗 Build
5855
run: npm run build
5956

60-
- name: 🏄 Copy test env vars
61-
run: cp .env.example .env
62-
6357
- name: 🛠 Setup Database
6458
run: npx prisma migrate deploy && npx prisma generate --sql
6559

@@ -81,9 +75,6 @@ jobs:
8175
- name: 📥 Download deps
8276
uses: bahmutov/npm-install@v1
8377

84-
- name: 🏄 Copy test env vars
85-
run: cp .env.example .env
86-
8778
- name: 🛠 Setup Database
8879
run: npx prisma migrate deploy && npx prisma generate --sql
8980

@@ -98,9 +89,6 @@ jobs:
9889
- name: ⬇️ Checkout repo
9990
uses: actions/checkout@v4
10091

101-
- name: 🏄 Copy test env vars
102-
run: cp .env.example .env
103-
10492
- name: ⎔ Setup node
10593
uses: actions/setup-node@v4
10694
with:

tests/setup/db-setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import path from 'node:path'
22
import fsExtra from 'fs-extra'
3+
import { ENV } from 'varlock/env'
34
import { afterAll, beforeEach } from 'vitest'
4-
import { BASE_DATABASE_PATH } from './global-setup.ts'
55

66
const databaseFile = `./tests/prisma/data.${process.env.VITEST_POOL_ID || 0}.db`
77
const databasePath = path.join(process.cwd(), databaseFile)
88
process.env.DATABASE_URL = `file:${databasePath}`
99

1010
beforeEach(async () => {
11-
await fsExtra.copyFile(BASE_DATABASE_PATH, databasePath)
11+
await fsExtra.copyFile(ENV.DATABASE_PATH, databasePath)
1212
})
1313

1414
afterAll(async () => {

tests/setup/global-setup.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import 'varlock/auto-load'
2-
import path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
33
import { execaCommand } from 'execa'
44
import fsExtra from 'fs-extra'
5+
import { ENV } from 'varlock/env'
56
import '#app/utils/cache.server.ts'
67

7-
export const BASE_DATABASE_PATH = path.join(
8-
process.cwd(),
9-
`./tests/prisma/base.db`,
10-
)
8+
119

1210
export async function setup() {
13-
const databaseExists = await fsExtra.pathExists(BASE_DATABASE_PATH)
11+
const dbPath = fileURLToPath(ENV.DATABASE_URL);
12+
const databaseExists = await fsExtra.pathExists(dbPath)
1413

1514
if (databaseExists) {
16-
const databaseLastModifiedAt = (await fsExtra.stat(BASE_DATABASE_PATH))
15+
const databaseLastModifiedAt = (await fsExtra.stat(dbPath))
1716
.mtime
1817
const prismaSchemaLastModifiedAt = (
1918
await fsExtra.stat('./prisma/schema.prisma')
@@ -28,10 +27,6 @@ export async function setup() {
2827
'npx prisma migrate reset --force --skip-seed --skip-generate',
2928
{
3029
stdio: 'inherit',
31-
env: {
32-
...process.env,
33-
DATABASE_URL: `file:${BASE_DATABASE_PATH}`,
34-
},
3530
},
3631
)
3732
}

0 commit comments

Comments
 (0)