Skip to content

Hasan/feat/recipe frontend integration #74

Hasan/feat/recipe frontend integration

Hasan/feat/recipe frontend integration #74

Workflow file for this run

name: CI
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
steps:
- uses: actions/checkout@v4
- name: Configure test database connection
env:
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
run: echo "DATABASE_URL=postgresql://t31_ci:t31_ci@127.0.0.1:${POSTGRES_PORT}/t31_ci" >> "$GITHUB_ENV"
- 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"