forked from ifgi/optimetaPortal
-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (190 loc) · 6.44 KB
/
Copy pathci.yml
File metadata and controls
219 lines (190 loc) · 6.44 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Django CI Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
pull-requests: write # allow posting comments on PRs by actions
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install ruff
run: pip install ruff
- name: Check formatting
run: ruff format --check .
- name: Check lint
run: ruff check .
licenses:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install GDAL from UbuntuGIS
run: |
sudo apt-get update
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get install -y -qq gdal-bin libgdal-dev
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install gdal=="$(gdal-config --version).*"
python -m pip install -r requirements.txt
python -m pip install pip-licenses
- name: Check dependency licenses
run: |
pip-licenses --order=license --format=plain-vertical
pip-licenses --order=license --format=json --output-file=licenses.json
IGNORE=$(python -c "
import tomllib
cfg = tomllib.load(open('pyproject.toml', 'rb'))
pkgs = cfg.get('tool', {}).get('license-check', {}).get('ignore-packages', [])
print(' '.join(pkgs))
")
pip-licenses --fail-on="Unknown" --ignore-packages $IGNORE
- name: Upload license report
if: always()
uses: actions/upload-artifact@v4
with:
name: license-report
path: licenses.json
unittests:
runs-on: ubuntu-24.04
strategy:
max-parallel: 4
matrix:
python-version: [
3.11,
#3.13
]
services:
db:
image: postgis/postgis:17-3.5
env:
POSTGRES_USER: optimap
POSTGRES_PASSWORD: optimap
POSTGRES_DB: optimap
ports:
- 5432:5432
options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install GDAL from UbuntuGIS
run: |
sudo apt-get update
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get install -y -qq gdal-bin libgdal-dev
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install gdal=="$(gdal-config --version).*"
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
- name: Run Django migrations
env:
DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap
run: |
python manage.py migrate
- name: Load all testdata to see if it is up to date with the Django migrations
env:
DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap
run: |
python manage.py loaddata fixtures/test_data_optimap.json
python manage.py loaddata fixtures/test_data_partners.json
- name: Run deploy checks
env:
DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap
run: |
python -Wa manage.py check --deploy
- name: Run Tests
env:
DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap
run: |
coverage run --source='works' --omit='*/migrations/**' manage.py test tests
- name: Check coverage and save it to files
run: |
coverage html
coverage xml
coverage report --show-missing --fail-under=50
#- name: Post code coverage
# uses: orgoro/coverage@v3.2
# with:
# coverageFile: coverage.xml
# token: ${{ secrets.GITHUB_TOKEN }}
uitests:
# disable until UI tests are fixed, see https://github.com/GeoinformationSystems/optimap/issues/142
if: false
runs-on: ubuntu-24.04
strategy:
max-parallel: 4
matrix:
python-version: [
3.11,
#3.13
]
services:
db:
image: postgis/postgis:17-3.5
env:
POSTGRES_USER: optimap
POSTGRES_PASSWORD: optimap
POSTGRES_DB: optimap
ports:
- 5432:5432
options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
# Based on https://github.com/MarketingPipeline/Python-Selenium-Action/blob/main/.github/workflows/Selenium-Action_Template.yaml and put python packages in requirements-dev.txt
- name: Removing previous chrome instances on runner
run: sudo apt purge google-chrome-stable
- name: Install xvfb
run: |
sudo apt install -y xvfb firefox
# See https://github.com/SeleniumHQ/selenium/issues/15327
- name: Install deps for chrome
run: |
sudo apt install libgtk-3-dev libnotify-dev libnss3 libxss1 libasound2t64
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install GDAL from UbuntuGIS
run: |
sudo apt-get update
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get install -y -qq gdal-bin libgdal-dev
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install gdal=="$(gdal-config --version).*"
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
- name: Run Django migrations
run: |
python manage.py migrate
- name: Run UI Tests
run: |
python -Wa manage.py runserver > server.log 2>&1 & python -Wa manage.py test tests-ui
- name: Print Server Logs
run: |
cat server.log
- name: Upload screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots for Python ${{ matrix.python-version }}
path: |
${{ github.workspace }}/tests-ui/screenshots/