-
-
Save Akumzy/9372c944c99c0df586e8be8a1264913d 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 db push --preview-feature | |
- run: npm run test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment