-
Notifications
You must be signed in to change notification settings - Fork 102
159 lines (152 loc) · 4.94 KB
/
gn-module-pytest.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
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
name: Run pytest against GeoNature module
on:
workflow_call:
inputs:
geonature_ref:
description: "La branche, tag ou SHA de GeoNature à utiliser"
default: "master"
required: false
type: string
upload_coverage:
description: "Téléverser la couverture de code sur Codecov"
default: false
required: false
type: boolean
secrets:
codecov_token:
description: "Token pour téléverser sur codecov"
required: false
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
debian-version: ['11', '12']
include:
- debian-version: '11'
python-version: '3.9'
postgres-version: '13'
postgis-version: '3.2'
- debian-version: '12'
python-version: '3.11'
postgres-version: '15'
postgis-version: '3.3'
name: Debian ${{ matrix.debian-version }}
services:
postgres:
image: postgis/postgis:${{ matrix.postgres-version }}-${{ matrix.postgis-version }}
env:
POSTGRES_DB: geonature2db
POSTGRES_PASSWORD: geonatpasswd
POSTGRES_USER: geonatadmin
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MODULE_DIR: ${{ github.workspace }}/extra/${{ github.event.repository.name }}
steps:
- name: Clone GeoNature
uses: actions/checkout@v4
with:
repository: pnx-si/geonature
ref: ${{ inputs.geonature_ref }}
submodules: true
- name: Clone ${{ github.event.repository.name }} module
uses: actions/checkout@v4
with:
path: ${{ env.MODULE_DIR }}
- name: Add database extensions
run: |
psql -h localhost -U geonatadmin -d geonature2db -f install/assets/db/add_pg_extensions.sql
env:
PGPASSWORD: geonatpasswd
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install GDAL
run: |
sudo apt update
sudo apt install -y libgdal-dev
- name: Install dependencies
if: github.action_ref == 'master'
run: |
echo 'Installation des requirements de prod'
python -m pip install --upgrade pip
python -m pip install \
-e ..[tests] \
-r requirements.txt
working-directory: ./backend
- name: Install dependencies
if: github.action_ref != 'master'
run: |
echo 'Installation des requirements de dev'
python -m pip install --upgrade pip
python -m pip install \
-e ..[tests] \
-r requirements-dev.txt
working-directory: ./backend
- name: Show database branches and dependencies
run: |
geonature db status --dependencies
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Install database
run: |
install/03b_populate_db.sh
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
srid_local: 2154
install_bdc_statuts: true
taxref_region: fr
add_sample_data: true
install_sig_layers: true
install_grid_layer_5: true
install_grid_layer_10: true
install_ref_sensitivity: true
- name: Show database status
run: |
geonature db status
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Install core modules backend
run: |
pip install -e contrib/occtax
pip install -e contrib/gn_module_occhab
pip install -e contrib/gn_module_validation
- name: Install ${{ github.event.repository.name }} module backend
run: |
pip install -e .
working-directory: ${{ env.MODULE_DIR }}
- name: Install modules database
run: |
geonature upgrade-modules-db
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Show database status
run: |
geonature db status --dependencies
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Test with pytest
run: |
pytest -v --cov --cov-report xml
working-directory: ${{ env.MODULE_DIR }}
env:
GEONATURE_CONFIG_FILE: ${{ github.workspace }}/config/test_config.toml
- name: Show coverage
run: |
coverage report
working-directory: ${{ env.MODULE_DIR }}
- name: Upload coverage to Codecov
if: ${{ inputs.upload_coverage && matrix.debian-version == '12' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.codecov_token }}
flags: pytest