-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (55 loc) · 1.95 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Run Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.18.0'
# Set up environment variables for Prisma and Supabase
- name: Set up environment variables
run: |
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> $GITHUB_ENV
echo "SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" >> $GITHUB_ENV
echo "SUPABASE_SERVICE_ROLE_KEY=${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}" >> $GITHUB_ENV
echo "JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }}" >> $GITHUB_ENV
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> $GITHUB_ENV
# Install dependencies
- name: Install dependencies
run: |
npm install
npx prisma generate # Generate Prisma client
# Reset the database before running tests
- name: Reset database before tests
run: npx prisma migrate reset --force
# Clear users before running tests
- name: Clear Supabase Auth Users before tests
run: npx ts-node src/auth/clear-users.ts
# Apply Prisma migrations (this will set up the database schema)
- name: Apply Prisma migrations
run: |
npx prisma migrate deploy # Apply migrations to the database
# Run unit tests
- name: Run unit tests
run: npm run test
# Run e2e tests
- name: Run e2e tests
run: npm run test:e2e
# Clear users after running tests
- name: Clear Supabase Auth Users after tests
run: npx ts-node src/auth/clear-users.ts
# Reset the database after running tests
- name: Reset database after tests
run: npx prisma migrate reset --force