Last active
April 10, 2024 18:57
-
-
Save 2color/537f8ef13ecec80059abb007839a6878 to your computer and use it in GitHub Desktop.
How to run integration tests with PostgreSQL and Prisma on GitHub Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/test.yaml | |
name: test | |
on: push | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
# Service containers to run with `container-job` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub PostgreSQL image | |
image: postgres | |
# Provide the password for postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
env: | |
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/fastify-graphql | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: '14.x' | |
- run: npm ci | |
- run: npm run build | |
# Create the database | |
- run: npx prisma migrate deploy | |
- run: npm run test |
Prisma Migrate will create it but it can be anything
This works great, thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why is the name of the database
fastify-graphql
?