Skip to content

pr_ci_frontend

pr_ci_frontend #36

Workflow file for this run

name: pr_ci_frontend
on:
pull_request:
branches:
- main
types: [opened, reopened, synchronize]
workflow_dispatch:
jobs:
frontend:
name: Run PR Frontend Check
runs-on: ubuntu-latest
environment: dev
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: ${{ secrets.DATABASE_NAME }}
POSTGRES_USER: ${{ secrets.DATABASE_USER }}
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
ports:
- 5432:5432
steps:
- name: cleanup old checkout
run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*;
- name: Checkout
uses: actions/checkout@v4
- name: Clean up any existing containers
run: |
docker stop $(docker ps -aq) || true
docker rm $(docker ps -aq) || true
- name: Check Port Availability
run: |
! nc -z localhost ${{ secrets.FRONTEND_PORT }} && \
! nc -z localhost ${{ secrets.BACKEND_PORT }} && \
! nc -z localhost 5432
- name: Set up Docker Compose
run: |
echo "FRONTEND_PORT=${{ secrets.FRONTEND_PORT }}" >> .env
echo "BACKEND_PORT=${{ secrets.BACKEND_PORT }}" >> .env
echo "DATABASE_PORT=${{ secrets.DATABASE_PORT }}" >> .env
echo "DATABASE_HOST=postgres" >> .env # Using the service name from the services section
echo "DATABASE_NAME=${{ secrets.DATABASE_NAME }}" >> .env
echo "DATABASE_USER=${{ secrets.DATABASE_USER }}" >> .env
echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> .env
echo "DJANGO_ALLOWED_HOSTS=${{ secrets.DJANGO_ALLOWED_HOSTS }}" >> .env
echo "DEBUG=${{ secrets.DEBUG }}" >> .env
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env
- name: Run Docker Compose
run: docker-compose -f docker-compose.yml up --build -d
- name: Setup Node environment
uses: actions/setup-node@v4
with:
node-version: 20
#- name: Install dependencies via Yarn
#uses: borales/actions-yarn@v5
#with:
#cmd: install --immutable --force --frozen-lockfile
#dir: "frontend"
- name: Install dependencies via Yarn
working-directory: ./frontend
run: |
sudo yarn install
- name: Install Prettier
run: sudo yarn add prettier
- name: Run Prettier - Formatting check
working-directory: ./frontend
run: |
sudo yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore
#- name: Run Type Check
#if: always()
#uses: borales/actions-yarn@v5
#with:
#cmd: nuxi typecheck
#dir: "frontend"
- name: Run Type Check
working-directory: ./frontend
if: always()
run: |
sudo yarn nuxi typecheck
#- name: Run eslint - Linting
#if: always()
#uses: borales/actions-yarn@v5
#with:
#cmd: eslint . --ext .js,.vue
#dir: "frontend"
- name: Run eslint - Linting
working-directory: ./frontend
if: always()
run: |
sudo yarn eslint . --ext .js,.vue
- name: Install Playwright Browsers
working-directory: ./frontend
run: |
sudo yarn playwright install --with-deps
- name: Wait for web server to be ready
working-directory: ./frontend
run: |
curl --retry 15 --retry-delay 5 --retry-all-errors http://localhost:${{ secrets.FRONTEND_PORT }}
- name: Run Playwright tests
working-directory: ./frontend
run: |
sudo yarn playwright test
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30
- name: Shutdown Docker Compose
if: always()
run: docker-compose down