-
Notifications
You must be signed in to change notification settings - Fork 2
156 lines (140 loc) · 4.96 KB
/
Copy pathtest.yaml
File metadata and controls
156 lines (140 loc) · 4.96 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Test
on:
pull_request:
types: [opened, reopened, synchronize]
workflow_call:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
DJANGO_SECRET_KEY: n0t5os3cre7-${{ github.sha }}
EMAIL_HOST: localhost
EMAIL_PORT: 1025
EMAIL_HOST_USER:
EMAIL_HOST_PASSWORD:
EMAIL_USE_TLS: false
DEFAULT_FROM_EMAIL: h@ll.o
SITE_URL: http://localhost:8000
PYTHON_VERSION: 3.12.8
EUPHROSYNE_TOOLS_API_URL: http://localhost:8001
EROS_HTTP_TOKEN: token
RADIATION_PROTECTION_TALLY_SECRET_KEY: secret
RADIATION_PROTECTION_RISK_ADVISOR_EMAIL: test@test.com
RADIATION_PROTECTION_RISK_ADVISOR_FULLNAME: Risk Advisor
GOODFLAG_API_BASE: https://culture-test01.lex-persona.com/
GOODFLAG_API_TOKEN: token
GOODFLAG_USER_ID: user_id
GOODFLAG_SIGNATURE_CONSENT_PAGE_ID: page_id
GOODFLAG_SIGNATURE_PROFILE_ID: profile_id
GOODFLAG_TEMPLATE_ID: template_id
jobs:
python-checks:
runs-on: ubuntu-22.04
steps:
# -- block install --
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: |
requirements/dev.txt
requirements/base.txt
- name: Install dev requirements
run: pip install -r requirements/dev.txt
# -- endblock install --
- name: Install GNU gettext
run: sudo apt install gettext
- name: Pylint check
run: python -m pylint $(git ls-files '*.py' | grep -v '/migrations/')
- name: Black check
run: python -m black --check .
- name: Isort check
run: python -m isort --check .
- name: Flake8 check with mccabe complexity 10
run: python -m flake8 --max-complexity 10 $(git ls-files '*.py' | grep -v '/migrations/')
- name: Check no migration is missing
run: ./manage.py makemigrations --check --dry-run
- name: Check no makemessages translation is missing
run: |
./manage.py makemessages --all --verbosity 0 --no-location --no-obsolete
git diff -I'^"PO' --exit-code locale/*/LC_MESSAGES/django.po # Fail if any change apart from headers.
git checkout -- locale/*/LC_MESSAGES/django.po
./manage.py makemessages --all --verbosity 0 --no-obsolete --no-location -d djangojs --ignore 'node_modules/*' --ignore 'venv/*' --ignore 'euphrosyne/assets/dist/*' -e js,tsx,ts,jsx
git diff -I'^"PO' --exit-code locale/*/LC_MESSAGES/djangojs.po # Fail if any change apart from headers.
git checkout -- locale/*/LC_MESSAGES/djangojs.po
- name: Check no translation is empty
run: |
# Inspired from https://blog.erw.dk/2015/06/06/checks-for-your-django-project/
missing_translations=$(sed '$a\\' locale/*/LC_MESSAGES/django.po | tac | sed '/^$/N;/\nmsgstr ""$/,/^msgid/!d' | tac)
[ $(wc -l <(echo $missing_translations) | cut -d ' ' -f1) = '1' ]
- name: Run mypy on selected folders
run: |
python -m mypy $(git ls-files '*.py' | grep -v '/migrations/')
python-tests:
runs-on: ubuntu-22.04
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: euphrosyne
POSTGRES_USER: euphrosyne
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
# -- block install --
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: |
requirements/dev.txt
requirements/base.txt
- name: Install dev requirements
run: pip install -r requirements/dev.txt
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install modules
run: npm ci
- name: Build files with webpack
run: npm run build
# -- endblock install --
- name: Collect static files
run: rm -rf _static && python manage.py collectstatic --clear --noinput
- name: Pytest
run: python -m pytest .
env:
DB_HOST: localhost
DB_USER: euphrosyne
DB_PORT: 5432
DB_PASSWORD: password
DB_NAME: euphrosyne
frontend-tests:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install modules
run: npm ci
- name: Run eslint
run: npx eslint .
- name: Check Prettier
run: npx prettier -c $(git ls-files | grep -E '\.(js|json|yaml)$')
- name: Run tsc
run: npm run lint:tsc
- name: Run tests
run: npm run test