-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (119 loc) · 3.6 KB
/
testing.yml
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
name: Testing Django
# Activates the workflow when there is a push or pull request in the repo
on:
push:
branches:
- main
- develop
pull_request:
jobs:
test_project:
runs-on: ubuntu-latest # operating system your code will run on
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: sadilar
POSTGRES_PASSWORD: sadilar
POSTGRES_DB: test_db_1
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
sudo apt-get install -y gettext
- name: Run linting tools
run: |
cd app/
ruff format .
- name: Create logging folder
run: |
sudo mkdir -p /logging
sudo chown runner:runner /logging
- name: Compile Translation Messages
run: |
cp .env.testing app/.env
cd app/
python manage.py makemessages --all
python manage.py compilemessages
- name: Run validate_templates
run: |
export DJANGO_TEST_PROCESSES=1
cp .env.testing app/.env
cd app/
mkdir -p static_files
python manage.py validate_templates --ignore-app django_filters
- name: Run Tests
run: |
cp .env.testing app/.env
cd app/
mkdir -p static_files
python manage.py test
env:
DJANGO_SETTINGS_MODULE: app.settings
DATABASE_URL: postgres://sadilar:sadilar@localhost:5432/test_db
- name: Manager Check
run: |
cd app/
python manage.py check
lighthouse:
runs-on: ubuntu-latest # operating system your code will run on
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: sadilar
POSTGRES_PASSWORD: sadilar
POSTGRES_DB: term_db
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
sudo apt-get install -y gettext
npm install -g @lhci/[email protected]
- name: Create folders
run: |
cp .env.lhci app/.env
cp entrypoint.sh app/
sudo chmod +x app/entrypoint.sh
- name: Run Lighthouse
run: cd app && lhci autorun
env:
DJANGO_SETTINGS_MODULE: app.settings
DATABASE_URL: postgres://sadilar:sadilar@localhost:5432/term_db
- name: TEST
if: always()
run: |
ls -al
ls -al app/
- name: Archive Lighthouse results
if: always() # Ensure results are uploaded on failure too
uses: actions/upload-artifact@v4
with:
name: lighthouse-report
path: app/.lighthouseci/
include-hidden-files: true
- name: Archive Django logs
if: always() # Ensure logs are uploaded on failure too
uses: actions/upload-artifact@v4
with:
name: django-logs
path: app/debug.log