Skip to content

Add SUPABASE_SERVICE_ROLE_KEY to environment variables in GitHub Acti… #10

Add SUPABASE_SERVICE_ROLE_KEY to environment variables in GitHub Acti…

Add SUPABASE_SERVICE_ROLE_KEY to environment variables in GitHub Acti… #10

Workflow file for this run

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