Skip to content

fix(ci): run database and API integration tests with PostgreSQL #73

fix(ci): run database and API integration tests with PostgreSQL

fix(ci): run database and API integration tests with PostgreSQL #73

Workflow file for this run

name: CI

Check failure on line 1 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci.yml

Invalid workflow file

(Line: 24, Col: 21): Unrecognized named-value: 'job'. Located at position 1 within expression: job.services.postgres.ports[5432]
on:
pull_request:
push:
branches: [main]
jobs:
quality:
runs-on: [self-hosted, linux, x64, t31-project2-ci]
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: t31_ci
POSTGRES_PASSWORD: t31_ci
POSTGRES_DB: t31_ci
ports:
- 5432/tcp
options: >-
--health-cmd "pg_isready -U t31_ci -d t31_ci"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DATABASE_URL: postgresql://t31_ci:t31_ci@127.0.0.1:${{ job.services.postgres.ports[5432] }}/t31_ci
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version-file: .node-version, cache: npm }
- run: npm ci
- name: Verify generated GraphQL types
run: npm run types:check
- name: Verify database migrations
run: npm run db:check
- name: Lint, typecheck, test and build
run: npm run check
- name: Test database constraints and migrations
run: npm run test:db
- name: Test recipe API and image storage
run: npm run test:api
- run: npx playwright install chromium
- run: npm run test:e2e
- name: Save tested release
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3.2.1-node20
with:
name: project2-${{ github.sha }}-${{ github.run_attempt }}
path: |
apps/api/dist
apps/api/migrations
apps/api/package.json
apps/validation/dist
apps/validation/package.json
apps/web/dist
apps/web/package.json
package.json
package-lock.json
deploy:
needs: quality
if: github.ref == 'refs/heads/main'
runs-on: [self-hosted, linux, x64, t31-project2-deploy]
environment:
name: production
url: http://it2810-31.idi.ntnu.no/project2/
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3-node20
with:
name: project2-${{ github.sha }}-${{ github.run_attempt }}
path: release
- name: Install production dependencies
run: cd release && npm ci --omit=dev
- name: Apply database migrations
run: cd release && node --env-file=/etc/t31-project2.env apps/api/dist/db/migrate.js
- name: Publish and restart the API service
run: bash scripts/deploy.sh release "$GITHUB_SHA-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"