Merge pull request #1 from dangvinh/codecov-baseline #10
This file contains hidden or 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
name: Test & Coverage | |
on: | |
push: | |
branches: [development] | |
pull_request: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: clean_arch_db | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd="pg_isready" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=5 | |
redis: | |
image: redis:7 | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd="redis-cli ping" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Set env vars | |
run: | | |
echo "DATABASE_URL=postgresql://postgres:postgres@localhost:5432/clean_arch_db" >> $GITHUB_ENV | |
echo "REDIS_URL=redis://localhost:6379" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: npm ci | |
- name: Wait for PostgreSQL to be ready | |
run: | | |
for i in {1..30}; do | |
nc -z localhost 5432 && echo "Postgres is up!" && exit 0 | |
echo "Waiting for postgres..." | |
sleep 2 | |
done | |
echo "Postgres never became available" && exit 1 | |
- name: Run Prisma migrations | |
run: npx prisma migrate deploy | |
- name: Run tests with coverage | |
run: npm run test:coverage | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |