Skip to content

Commit

Permalink
trying another approach for docker compose service
Browse files Browse the repository at this point in the history
  • Loading branch information
aasimsyed committed Apr 23, 2024
1 parent f60a5d0 commit 2aa0b1b
Showing 1 changed file with 48 additions and 24 deletions.
72 changes: 48 additions & 24 deletions .github/workflows/pr_ci_frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,85 @@ on:
- main
types: [opened, reopened, synchronize]

env:
NODE_VERSION: '14'

jobs:
frontend:
name: Run PR Frontend Check
runs-on: ubuntu-latest
environment: dev

services:
app: # This is the service for the web server needed for Playwright tests
image: docker-compose.yml
postgres: # Database service example
image: postgres:15
env:
FRONTEND_PORT: ${{ secrets.FRONTEND_PORT }}
BACKEND_PORT: ${{ secrets.BACKEND_PORT }}
DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DJANGO_ALLOWED_HOSTS: ${{ secrets.DJANGO_ALLOWED_HOSTS }}
DEBUG: ${{ secrets.DEBUG }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
POSTGRES_DB: ${{ secrets.DATABASE_NAME }}
POSTGRES_USER: ${{ secrets.DATABASE_USER }}
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
ports:
- 5432:5432
options: --env-file .env.dev up --build
- 5432:5432 # Using the default PostgreSQL port

steps:
- name: Checkout
uses: actions/checkout@v4

- 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 -d

- name: Setup Node environment
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
node-version: '16'

- name: Install Yarn
uses: borales/actions-yarn@v5
with:
cmd: install
dir: "frontend"

- name: Install Yarn and dependencies
- name: Install Prettier
working-directory: ./frontend
run: yarn install
run: yarn add prettier

- name: Run Prettier - Formatting check
working-directory: ./frontend
run: yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore
run: |
yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore
- name: Run Type Check
working-directory: ./frontend
run: yarn nuxi typecheck

- name: Run eslint - Linting
working-directory: ./frontend
run: yarn eslint . --ext .js,.vue
run: |
yarn eslint . --ext .js,.vue
- name: Install Playwright Browsers
working-directory: ./frontend
run: yarn playwright install --with-deps
run: |
yarn playwright install --with-deps
- name: Wait for web server to be ready
working-directory: ./frontend
run: |
curl --retry 5 --retry-delay 5 --retry-all-errors http://localhost:${{ secrets.FRONTEND_PORT }}
- name: Run Playwright tests
working-directory: ./frontend
run: yarn playwright test
run: |
yarn playwright test
- name: Upload Playwright report
if: always()
Expand All @@ -73,3 +93,7 @@ jobs:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30

- name: Shutdown Docker Compose
if: always()
run: docker-compose down

0 comments on commit 2aa0b1b

Please sign in to comment.