Skip to content

Commit

Permalink
restored original 'pr_ci_frontend.yaml' from upstream/main and made a…
Browse files Browse the repository at this point in the history
… separate 'pr_ci_playwright_e2e.yaml' WIP workflow for Playwright E2E tests only
  • Loading branch information
aasimsyed committed May 2, 2024
1 parent 049a98e commit 1425d22
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 101 deletions.
115 changes: 14 additions & 101 deletions .github/workflows/pr_ci_frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,129 +4,42 @@ on:
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 Yarn
uses: borales/actions-yarn@v5
with:
cmd: install
dir: "frontend"

- name: Install Prettier
run: sudo yarn add prettier
run: yarn add prettier

- name: Run Prettier - Formatting check
working-directory: ./frontend
run: |
sudo yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore
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
uses: borales/actions-yarn@v4
with:
cmd: nuxi typecheck
dir: "frontend"

#- 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 --reporter=html
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
uses: borales/actions-yarn@v4
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30

- name: Shutdown Docker Compose
if: always()
run: docker-compose down
cmd: eslint . --ext .js,.vue
dir: "frontend"
128 changes: 128 additions & 0 deletions .github/workflows/pr_ci_playwright_e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: pr_ci_playwright_e2e
on:
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 --reporter=html
- 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

0 comments on commit 1425d22

Please sign in to comment.