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