testing #41
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 Pipeline | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build_backend: | |
name: Build backend and connect to Postgres DB | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '20' | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml -DskipTests | |
working-directory: backend | |
build_frontend: | |
runs-on: ubuntu-latest | |
needs: [build_backend] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: frontend/package-lock.json | |
- name: Install dependencies | |
run: npm ci | |
working-directory: frontend | |
- name: Build frontend | |
run: npm run build --no-progress 2>&1 >/dev/null || true | |
working-directory: frontend | |
cypress: | |
runs-on: ubuntu-latest | |
needs: [build_backend, build_frontend] | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_DB: measdb | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '20' | |
cache: maven | |
- name: Start backend | |
run: java -jar /home/runner/work/ZimskaSola2024/ZimskaSola2024/backend/target/measurements-1.0.0.jar | |
working-directory: backend | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: frontend/package-lock.json | |
- name: Install dependencies | |
run: npm ci | |
working-directory: frontend | |
- name: Start frontend | |
run: npm run start | |
working-directory: frontend |