]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
Merge pull request #3094 from lonvia/fix-failing-bdd-tests
[nominatim.git] / .github / workflows / ci-tests.yml
1 name: CI Tests
2
3 on: [ push, pull_request ]
4
5 jobs:
6     create-archive:
7         runs-on: ubuntu-latest
8
9         steps:
10             - uses: actions/checkout@v3
11               with:
12                 submodules: true
13
14             - uses: actions/cache@v3
15               with:
16                   path: |
17                      data/country_osm_grid.sql.gz
18                   key: nominatim-country-data-1
19
20             - name: Package tarball
21               run: |
22                   if [ ! -f data/country_osm_grid.sql.gz ]; then
23                       wget --no-verbose -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
24                   fi
25                   cd ..
26                   tar czf nominatim-src.tar.bz2 Nominatim
27                   mv nominatim-src.tar.bz2 Nominatim
28
29             - name: 'Upload Artifact'
30               uses: actions/upload-artifact@v3
31               with:
32                   name: full-source
33                   path: nominatim-src.tar.bz2
34                   retention-days: 1
35
36     tests:
37         needs: create-archive
38         strategy:
39             matrix:
40                 flavour: [oldstuff, "ubuntu-20", "ubuntu-22"]
41                 include:
42                     - flavour: oldstuff
43                       ubuntu: 20
44                       postgresql: '9.6'
45                       postgis: '2.5'
46                       php: '7.3'
47                       lua: '5.1'
48                     - flavour: ubuntu-20
49                       ubuntu: 20
50                       postgresql: 13
51                       postgis: 3
52                       php: '7.4'
53                       lua: '5.3'
54                     - flavour: ubuntu-22
55                       ubuntu: 22
56                       postgresql: 15
57                       postgis: 3
58                       php: '8.1'
59                       lua: '5.3'
60
61         runs-on: ubuntu-${{ matrix.ubuntu }}.04
62
63         steps:
64             - uses: actions/download-artifact@v3
65               with:
66                   name: full-source
67
68             - name: Unpack Nominatim
69               run: tar xf nominatim-src.tar.bz2
70
71             - name: Setup PHP
72               uses: shivammathur/setup-php@v2
73               with:
74                   php-version: ${{ matrix.php }}
75                   tools: phpunit:9, phpcs, composer
76                   ini-values: opcache.jit=disable
77               env:
78                   GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
80             - uses: actions/setup-python@v4
81               with:
82                 python-version: 3.7
83               if: matrix.flavour == 'oldstuff'
84
85             - uses: ./Nominatim/.github/actions/setup-postgresql
86               with:
87                   postgresql-version: ${{ matrix.postgresql }}
88                   postgis-version: ${{ matrix.postgis }}
89
90             - uses: ./Nominatim/.github/actions/build-nominatim
91               with:
92                   flavour: ${{ matrix.flavour }}
93                   lua: ${{ matrix.lua }}
94
95             - name: Install test prerequsites (behave from apt)
96               run: sudo apt-get install -y -qq python3-behave
97               if: matrix.flavour == 'ubuntu-20'
98
99             - name: Install test prerequsites (behave from pip)
100               run: pip3 install behave==1.2.6
101               if: (matrix.flavour == 'oldstuff') || (matrix.flavour == 'ubuntu-22')
102
103             - name: Install test prerequsites (from apt for Ununtu 2x)
104               run: sudo apt-get install -y -qq python3-pytest python3-pytest-asyncio uvicorn
105               if: matrix.flavour != 'oldstuff'
106
107             - name: Install newer pytest-asyncio
108               run: pip3 install -U pytest-asyncio
109               if: matrix.flavour == 'ubuntu-20'
110
111             - name: Install test prerequsites (from pip for Ubuntu 18)
112               run: pip3 install pytest pytest-asyncio uvicorn
113               if: matrix.flavour == 'oldstuff'
114
115             - name: Install Python webservers
116               run: pip3 install falcon starlette
117
118             - name: Install latest pylint
119               run: pip3 install -U pylint asgi_lifespan
120
121             - name: PHP linting
122               run: phpcs --report-width=120 .
123               working-directory: Nominatim
124
125             - name: Python linting
126               run: python3 -m pylint nominatim
127               working-directory: Nominatim
128
129             - name: PHP unit tests
130               run: phpunit ./
131               working-directory: Nominatim/test/php
132
133             - name: Python unit tests
134               run: python3 -m pytest test/python
135               working-directory: Nominatim
136
137             - name: BDD tests
138               run: |
139                   python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
140               working-directory: Nominatim/test/bdd
141
142             - name: Install mypy and typechecking info
143               run: pip3 install -U mypy osmium uvicorn types-PyYAML types-jinja2 types-psycopg2 types-psutil types-requests types-ujson types-Pygments typing-extensions
144               if: matrix.flavour != 'oldstuff'
145
146             - name: Python static typechecking
147               run: python3 -m mypy --strict nominatim
148               working-directory: Nominatim
149               if: matrix.flavour != 'oldstuff'
150
151     legacy-test:
152         needs: create-archive
153         runs-on: ubuntu-20.04
154
155         steps:
156             - uses: actions/download-artifact@v3
157               with:
158                   name: full-source
159
160             - name: Unpack Nominatim
161               run: tar xf nominatim-src.tar.bz2
162
163             - name: Setup PHP
164               uses: shivammathur/setup-php@v2
165               with:
166                   php-version: '7.4'
167
168             - uses: ./Nominatim/.github/actions/setup-postgresql
169               with:
170                   postgresql-version: 13
171                   postgis-version: 3
172
173             - name: Install Postgresql server dev
174               run: sudo apt-get install postgresql-server-dev-13
175
176             - uses: ./Nominatim/.github/actions/build-nominatim
177               with:
178                   cmake-args: -DBUILD_MODULE=on
179
180             - name: Install test prerequsites
181               run: sudo apt-get install -y -qq python3-behave
182
183             - name: BDD tests (legacy tokenizer)
184               run: |
185                   python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=legacy --format=progress3
186               working-directory: Nominatim/test/bdd
187
188
189     python-api-test:
190         needs: create-archive
191         runs-on: ubuntu-22.04
192
193         steps:
194             - uses: actions/download-artifact@v3
195               with:
196                   name: full-source
197
198             - name: Unpack Nominatim
199               run: tar xf nominatim-src.tar.bz2
200
201             - uses: ./Nominatim/.github/actions/setup-postgresql
202               with:
203                   postgresql-version: 15
204                   postgis-version: 3
205
206             - uses: ./Nominatim/.github/actions/build-nominatim
207               with:
208                   flavour: 'ubuntu-22'
209
210             - name: Install test prerequsites
211               run: sudo apt-get install -y -qq python3-behave
212
213             - name: Install Python webservers
214               run: pip3 install starlette asgi_lifespan httpx
215
216             - name: BDD tests (starlette)
217               run: |
218                   python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DAPI_ENGINE=starlette --format=progress3
219               working-directory: Nominatim/test/bdd
220
221
222     install:
223         runs-on: ubuntu-latest
224         needs: create-archive
225
226         strategy:
227             matrix:
228                 name: [Ubuntu-20, Ubuntu-22]
229                 include:
230                     - name: Ubuntu-20
231                       image: "ubuntu:20.04"
232                       ubuntu: 20
233                       install_mode: install-apache
234                     - name: Ubuntu-22
235                       image: "ubuntu:22.04"
236                       ubuntu: 22
237                       install_mode: install-apache
238
239         container:
240             image: ${{ matrix.image }}
241             env:
242                 LANG: en_US.UTF-8
243
244         defaults:
245             run:
246                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
247
248         steps:
249             - name: Prepare container (Ubuntu)
250               run: |
251                   export APT_LISTCHANGES_FRONTEND=none
252                   export DEBIAN_FRONTEND=noninteractive
253                   apt-get update -qq
254                   apt-get install -y git sudo wget
255                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
256               shell: bash
257
258             - name: Setup import user
259               run: |
260                   useradd -m nominatim
261                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
262                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
263               shell: bash
264               env:
265                 OS: ${{ matrix.name }}
266                 INSTALL_MODE: ${{ matrix.install_mode }}
267
268             - uses: actions/download-artifact@v3
269               with:
270                   name: full-source
271                   path: /home/nominatim
272
273             - name: Install Nominatim
274               run: |
275                 export USERNAME=nominatim
276                 export USERHOME=/home/nominatim
277                 export NOSYSTEMD=yes
278                 export HAVE_SELINUX=no
279                 tar xf nominatim-src.tar.bz2
280                 . vagrant.sh
281               working-directory: /home/nominatim
282
283             - name: Prepare import environment
284               run: |
285                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
286                   mv Nominatim/settings/flex-base.lua flex-base.lua
287                   mv Nominatim/settings/import-extratags.lua import-extratags.lua
288                   mv Nominatim/settings/taginfo.lua taginfo.lua
289                   rm -rf Nominatim
290                   mkdir data-env-reverse
291               working-directory: /home/nominatim
292
293             - name: Print version
294               run: nominatim --version
295               working-directory: /home/nominatim/nominatim-project
296
297             - name: Print taginfo
298               run: lua taginfo.lua
299               working-directory: /home/nominatim
300
301             - name: Collect host OS information
302               run: nominatim admin --collect-os-info
303               working-directory: /home/nominatim/nominatim-project
304
305             - name: Import
306               run: nominatim import --osm-file ../test.pbf
307               working-directory: /home/nominatim/nominatim-project
308
309             - name: Import special phrases
310               run: nominatim special-phrases --import-from-wiki
311               working-directory: /home/nominatim/nominatim-project
312
313             - name: Check full import
314               run: nominatim admin --check-database
315               working-directory: /home/nominatim/nominatim-project
316
317             - name: Warm up database
318               run: nominatim admin --warm
319               working-directory: /home/nominatim/nominatim-project
320
321             - name: Prepare update (Ubuntu)
322               run: apt-get install -y python3-pip
323               shell: bash
324
325             - name: Run update
326               run: |
327                   pip3 install --user osmium
328                   nominatim replication --init
329                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
330               working-directory: /home/nominatim/nominatim-project
331
332             - name: Clean up database
333               run: nominatim refresh --postcodes --word-tokens
334               working-directory: /home/nominatim/nominatim-project
335
336             - name: Run reverse-only import
337               run : |
338                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
339                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
340               working-directory: /home/nominatim/data-env-reverse
341
342             - name: Check reverse-only import
343               run: nominatim admin --check-database
344               working-directory: /home/nominatim/data-env-reverse
345
346             - name: Clean up database (reverse-only import)
347               run: nominatim refresh --postcodes --word-tokens
348               working-directory: /home/nominatim/nominatim-project