-
Notifications
You must be signed in to change notification settings - Fork 15
80 lines (77 loc) · 2.14 KB
/
python.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
name: Python
on:
push:
branches:
- "main"
pull_request:
branches:
- "**"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
lint_and_tests:
name: Lint and tests
env:
DJANGO_SETTINGS_MODULE: backend.settings.test
SRC_DIRS: backend metrics-exporter fixtures
BACKEND_DB_NAME: backend_default
BACKEND_DB_USER: backend
BACKEND_DB_PWD: backend
BACKEND_DB_HOST: localhost
BACKEND_DB_PORT: 5432
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_DB: backend_default
POSTGRES_USER: backend
POSTGRES_PASSWORD: backend
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: 3.11
- uses: actions/cache@v4.0.2
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install --upgrade --upgrade-strategy eager -r backend/dev-requirements.txt
- name: Check formatting - Black
run: |
black --check --diff $SRC_DIRS
- name: Check formatting - isort
run: |
isort --check $SRC_DIRS
- name: Lint
run: |
flake8 $SRC_DIRS
- name: Check security - Bandit
run: bandit --ini=.bandit
- name: Mypy
run: mypy backend/substrapp/tasks/
- name: Check for missing Django migrations
run: |
# If this fails, please run `make migrations` and commit the results
make check-migrations
- name: Check documentation
run: python tools/build_settings_doc.py --check
- name: Test
run: |
cd backend/
pytest