]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
lift restrictions on search with frequent terms slightly
[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@v4
11               with:
12                 submodules: true
13
14             - uses: actions/cache@v4
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@v4
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                       lua: '5.1'
47                     - flavour: ubuntu-20
48                       ubuntu: 20
49                       postgresql: 13
50                       postgis: 3
51                       lua: '5.3'
52                     - flavour: ubuntu-22
53                       ubuntu: 22
54                       postgresql: 15
55                       postgis: 3
56                       lua: '5.3'
57
58         runs-on: ubuntu-${{ matrix.ubuntu }}.04
59
60         steps:
61             - uses: actions/download-artifact@v4
62               with:
63                   name: full-source
64
65             - name: Unpack Nominatim
66               run: tar xf nominatim-src.tar.bz2
67
68             - uses: actions/setup-python@v5
69               with:
70                 python-version: 3.7
71               if: matrix.flavour == 'oldstuff'
72
73             - uses: ./Nominatim/.github/actions/setup-postgresql
74               with:
75                   postgresql-version: ${{ matrix.postgresql }}
76                   postgis-version: ${{ matrix.postgis }}
77
78             - uses: ./Nominatim/.github/actions/build-nominatim
79               with:
80                   flavour: ${{ matrix.flavour }}
81                   lua: ${{ matrix.lua }}
82
83             - name: Install test prerequisites (behave from apt)
84               run: sudo apt-get install -y -qq python3-behave
85               if: matrix.flavour == 'ubuntu-20'
86
87             - name: Install test prerequisites (behave from pip)
88               run: pip3 install behave==1.2.6
89               if: (matrix.flavour == 'oldstuff') || (matrix.flavour == 'ubuntu-22')
90
91             - name: Install test prerequisites (from apt for Ununtu 2x)
92               run: sudo apt-get install -y -qq python3-pytest python3-pytest-asyncio uvicorn
93               if: matrix.flavour != 'oldstuff'
94
95             - name: Install newer pytest-asyncio
96               run: pip3 install -U pytest-asyncio
97               if: matrix.flavour == 'ubuntu-20'
98
99             - name: Install test prerequisites (from pip for Ubuntu 18)
100               run: pip3 install pytest pytest-asyncio uvicorn
101               if: matrix.flavour == 'oldstuff'
102
103             - name: Install Python webservers
104               run: pip3 install falcon starlette asgi_lifespan
105
106             - name: Install latest pylint
107               run: pip3 install -U pylint
108               if: matrix.flavour == 'ubuntu-22'
109
110             - name: Python linting
111               run: python3 -m pylint src
112               working-directory: Nominatim
113               if: matrix.flavour == 'ubuntu-22'
114
115             - name: Python unit tests
116               run: python3 -m pytest test/python
117               working-directory: Nominatim
118
119             - name: BDD tests
120               run: |
121                   export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
122                   python3 -m behave -DREMOVE_TEMPLATE=1 --format=progress3
123               working-directory: Nominatim/test/bdd
124
125             - name: Install mypy and typechecking info
126               run: pip3 install -U mypy osmium uvicorn types-PyYAML types-jinja2 types-psycopg2 types-psutil types-requests types-ujson types-Pygments typing-extensions
127               if: matrix.flavour != 'oldstuff'
128
129             - name: Python static typechecking
130               run: python3 -m mypy --strict src
131               working-directory: Nominatim
132               if: matrix.flavour != 'oldstuff'
133
134     legacy-test:
135         needs: create-archive
136         runs-on: ubuntu-20.04
137
138         strategy:
139             matrix:
140                 postgresql: ["13", "16"]
141
142         steps:
143             - uses: actions/download-artifact@v4
144               with:
145                   name: full-source
146
147             - name: Unpack Nominatim
148               run: tar xf nominatim-src.tar.bz2
149
150             - name: Setup PHP
151               uses: shivammathur/setup-php@v2
152               with:
153                   php-version: '7.4'
154
155             - uses: ./Nominatim/.github/actions/setup-postgresql
156               with:
157                   postgresql-version: ${{ matrix.postgresql }}
158                   postgis-version: 3
159
160             - name: Install Postgresql server dev
161               run: sudo apt-get install postgresql-server-dev-$PGVER
162               env:
163                 PGVER: ${{ matrix.postgresql }}
164
165             - uses: ./Nominatim/.github/actions/build-nominatim
166               with:
167                   cmake-args: -DBUILD_MODULE=on
168
169             - name: Install test prerequisites
170               run: sudo apt-get install -y -qq python3-behave
171
172             - name: BDD tests (legacy tokenizer)
173               run: |
174                   export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
175                   python3 -m behave -DREMOVE_TEMPLATE=1 -DSERVER_MODULE_PATH=$GITHUB_WORKSPACE/build/module -DAPI_ENGINE=php -DTOKENIZER=legacy --format=progress3
176               working-directory: Nominatim/test/bdd
177
178
179     php-test:
180         needs: create-archive
181         runs-on: ubuntu-22.04
182
183         steps:
184             - uses: actions/download-artifact@v4
185               with:
186                   name: full-source
187
188             - name: Unpack Nominatim
189               run: tar xf nominatim-src.tar.bz2
190
191             - uses: ./Nominatim/.github/actions/setup-postgresql
192               with:
193                   postgresql-version: 15
194                   postgis-version: 3
195
196             - name: Setup PHP
197               uses: shivammathur/setup-php@v2
198               with:
199                   php-version: 8.1
200                   tools: phpunit:9, phpcs, composer
201                   ini-values: opcache.jit=disable
202               env:
203                   GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
204
205             - name: PHP linting
206               run: phpcs --report-width=120 .
207               working-directory: Nominatim
208
209             - name: PHP unit tests
210               run: phpunit ./
211               working-directory: Nominatim/test/php
212
213             - uses: ./Nominatim/.github/actions/build-nominatim
214               with:
215                   flavour: 'ubuntu-22'
216
217             - name: Install test prerequisites
218               run: sudo apt-get install -y -qq python3-behave
219
220             - name: BDD tests (php)
221               run: |
222                   export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
223                   python3 -m behave -DREMOVE_TEMPLATE=1 -DAPI_ENGINE=php --format=progress3
224               working-directory: Nominatim/test/bdd
225
226
227     install:
228         runs-on: ubuntu-latest
229         needs: create-archive
230
231         strategy:
232             matrix:
233                 name: [Ubuntu-22, Ubuntu-24]
234                 include:
235                     - name: Ubuntu-22
236                       image: "ubuntu:22.04"
237                       ubuntu: 22
238                       install_mode: install-apache
239                     - name: Ubuntu-24
240                       image: "ubuntu:24.04"
241                       ubuntu: 24
242                       install_mode: install-apache
243
244         container:
245             image: ${{ matrix.image }}
246             env:
247                 LANG: en_US.UTF-8
248
249         defaults:
250             run:
251                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
252
253         steps:
254             - name: Prepare container (Ubuntu)
255               run: |
256                   export APT_LISTCHANGES_FRONTEND=none
257                   export DEBIAN_FRONTEND=noninteractive
258                   apt-get update -qq
259                   apt-get install -y git sudo wget
260                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
261               shell: bash
262
263             - name: Setup import user
264               run: |
265                   useradd -m nominatim
266                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
267                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
268               shell: bash
269               env:
270                 OS: ${{ matrix.name }}
271                 INSTALL_MODE: ${{ matrix.install_mode }}
272
273             - uses: actions/download-artifact@v4
274               with:
275                   name: full-source
276                   path: /home/nominatim
277
278             - name: Install Nominatim
279               run: |
280                 export USERNAME=nominatim
281                 export USERHOME=/home/nominatim
282                 export NOSYSTEMD=yes
283                 export HAVE_SELINUX=no
284                 tar xf nominatim-src.tar.bz2
285                 . vagrant.sh
286               working-directory: /home/nominatim
287
288             - name: Prepare import environment
289               run: |
290                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
291                   mv Nominatim/settings/flex-base.lua flex-base.lua
292                   mv Nominatim/settings/import-extratags.lua import-extratags.lua
293                   mv Nominatim/settings/taginfo.lua taginfo.lua
294                   rm -rf Nominatim
295                   mkdir data-env-reverse
296               working-directory: /home/nominatim
297
298             - name: Add nominatim to path
299               run: |
300                 sudo ln -s /home/nominatim/nominatim-venv/bin/nominatim /usr/local/bin/nominatim
301               if: matrix.ubuntu == 24
302
303             - name: Need lua binary
304               run: |
305                 sudo apt-get install -y lua5.4 lua-dkjson
306               if: matrix.ubuntu == 24
307
308             - name: Print version
309               run: nominatim --version
310               working-directory: /home/nominatim/nominatim-project
311
312             - name: Print taginfo
313               run: lua taginfo.lua
314               working-directory: /home/nominatim
315
316             - name: Collect host OS information
317               run: nominatim admin --collect-os-info
318               working-directory: /home/nominatim/nominatim-project
319
320             - name: Import
321               run: nominatim import --osm-file ../test.pbf
322               working-directory: /home/nominatim/nominatim-project
323
324             - name: Import special phrases
325               run: nominatim special-phrases --import-from-wiki
326               working-directory: /home/nominatim/nominatim-project
327
328             - name: Check full import
329               run: nominatim admin --check-database
330               working-directory: /home/nominatim/nominatim-project
331
332             - name: Warm up database
333               run: nominatim admin --warm
334               working-directory: /home/nominatim/nominatim-project
335
336             - name: Prepare update (Ubuntu)
337               run: apt-get install -y python3-pip
338               shell: bash
339
340             - name: Install osmium (Ubuntu 22)
341               run: |
342                   pip3 install --user osmium
343               if: matrix.ubuntu == 22
344
345             - name: Install osmium (Ubuntu 24)
346               run: |
347                   /home/nominatim/nominatim-venv/bin/pip install osmium
348               if: matrix.ubuntu == 24
349
350             - name: Run update
351               run: |
352                   nominatim replication --init
353                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
354               working-directory: /home/nominatim/nominatim-project
355
356             - name: Clean up database
357               run: nominatim refresh --postcodes --word-tokens
358               working-directory: /home/nominatim/nominatim-project
359
360             - name: Run reverse-only import
361               run : |
362                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
363                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
364               working-directory: /home/nominatim/data-env-reverse
365
366             - name: Check reverse-only import
367               run: nominatim admin --check-database
368               working-directory: /home/nominatim/data-env-reverse
369
370             - name: Clean up database (reverse-only import)
371               run: nominatim refresh --postcodes --word-tokens
372               working-directory: /home/nominatim/nominatim-project
373
374     install-no-superuser:
375       runs-on: ubuntu-latest
376       needs: create-archive
377
378       steps:
379           - uses: actions/download-artifact@v4
380             with:
381                 name: full-source
382
383           - name: Unpack Nominatim
384             run: tar xf nominatim-src.tar.bz2
385
386           - uses: ./Nominatim/.github/actions/setup-postgresql
387             with:
388                 postgresql-version: 16
389                 postgis-version: 3
390
391           - uses: ./Nominatim/.github/actions/build-nominatim
392             with:
393                 flavour: ubuntu-22
394                 lua: 5.3
395
396           - name: Prepare import environment
397             run: |
398                 mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
399                 rm -rf Nominatim
400
401           - name: Prepare Database
402             run: |
403                 nominatim import --prepare-database
404
405           - name: Create import user
406             run: |
407                 sudo -u postgres createuser osm-import
408                 psql -d nominatim -c "ALTER USER \"osm-import\" WITH PASSWORD 'osm-import'"
409                 psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "osm-import"'
410
411           - name: Run import
412             run: |
413                 NOMINATIM_DATABASE_DSN="pgsql:host=127.0.0.1;dbname=nominatim;user=osm-import;password=osm-import" nominatim import --continue import-from-file --osm-file test.pbf
414
415           - name: Check full import
416             run: nominatim admin --check-database
417
418     codespell:
419       runs-on: ubuntu-latest
420       steps:
421           - uses: codespell-project/actions-codespell@v2
422             with:
423                 only_warn: 1