DONE #56
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
name: CI/CD | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:14 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: harmonic_universe_test | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install Dependencies | |
run: | | |
npm ci | |
cd frontend && npm ci | |
cd ../backend && npm ci | |
- name: Run Frontend Tests | |
run: | | |
cd frontend | |
npm run test:ci | |
- name: Run Backend Tests | |
run: | | |
cd backend | |
npm run test:ci | |
env: | |
DB_HOST: localhost | |
DB_PORT: 5432 | |
DB_NAME: harmonic_universe_test | |
DB_USER: postgres | |
DB_PASSWORD: postgres | |
NODE_ENV: test | |
- name: Upload Coverage Reports | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./frontend/coverage/coverage-final.json,./backend/coverage/coverage-final.json | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install Dependencies | |
run: | | |
npm ci | |
cd frontend && npm ci | |
cd ../backend && npm ci | |
- name: Lint Frontend | |
run: | | |
cd frontend | |
npm run lint | |
- name: Lint Backend | |
run: | | |
cd backend | |
npm run lint | |
build: | |
needs: [test, lint] | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install Dependencies | |
run: | | |
npm ci | |
cd frontend && npm ci | |
cd ../backend && npm ci | |
- name: Build Frontend | |
run: | | |
cd frontend | |
npm run build | |
- name: Build Backend | |
run: | | |
cd backend | |
npm run build | |
- name: Upload Frontend Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: frontend-build | |
path: frontend/dist | |
- name: Upload Backend Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: backend-build | |
path: backend/dist |