-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (113 loc) · 3.98 KB
/
linting_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
122
123
124
125
126
127
128
129
name: Test & Lint tasks
on: [push]
jobs:
linting_check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11.9]
env:
DJANGO_SETTINGS_MODULE: config.settings.test
DJANGO_SECRET_KEY: ministryofsillywalks
PYTHONPATH: .
POSTGRESQL_ADDON_HOST: localhost
POSTGRESQL_ADDON_DB: postgres
POSTGRESQL_ADDON_USER: postgres
POSTGRESQL_ADDON_PASSWORD: postgres
CELLAR_ADDON_KEY_ID: TheMeaningOfLife
CELLAR_ADDON_KEY_SECRET: "42"
CELLAR_ADDON_HOST: example.com
services:
postgres:
# Docker Hub image
image: postgis/postgis:14-3.1
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.11.9
#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install Python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install System dependencies
run: |
sudo apt-get update
sudo apt-get -y install gdal-bin
#----------------------------------------------
# install your root project
#----------------------------------------------
- name: 📥 Install dependencies
run: poetry install --no-interaction
#----------------------------------------------
# migration checks
#----------------------------------------------
# - name: 💾 Create a database to check migrations
# run: |
# psql <<SQL
# CREATE DATABASE marche;
# SQL
- name: 🚧 Check pending migrations
run: |
source .venv/bin/activate
python manage.py makemigrations --check --dry-run --noinput
#----------------------------------------------
# run lint suite
# Why not install default flake8 or pylint ?
# Because we use pyproject.toml config file, and
# prefer locally reproducible tests.
#----------------------------------------------
- name: ✨ Run Linters
run: |
source .venv/bin/activate
echo "flake8"
pflake8 "./lemarche"
echo "black"
black . --check
echo "isort"
isort ./lemarche/*.py --check-only
#----------------------------------------------
# run tests
# collectstatic needed for selenium tests
#----------------------------------------------
- name: 🤹 Run Tests
run: |
source .venv/bin/activate
python manage.py collectstatic
coverage run --source='./lemarche' ./manage.py test --parallel auto lemarche
coverage report