forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (90 loc) · 3.29 KB
/
pr_ci_frontend.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: pr_ci_frontend
on:
push:
pull_request:
branches:
- main
types: [opened, reopened, synchronize]
jobs:
frontend:
name: Run PR Frontend Check
runs-on: ubuntu-latest
environment: dev
services:
postgres: # Database service example
image: postgres:15
env:
POSTGRES_DB: ${{ secrets.DATABASE_NAME }}
POSTGRES_USER: ${{ secrets.DATABASE_USER }}
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
ports:
- 5432:5432 # Using the default PostgreSQL port
steps:
- 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 -d
- name: Setup Node environment
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install Prettier
working-directory: ./frontend
run: yarn add prettier
- name: Run Prettier - Formatting check
working-directory: ./frontend
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
- name: Install Playwright Browsers
working-directory: ./frontend
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
- 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