forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (112 loc) · 3.94 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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