]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
Merge remote-tracking branch 'upstream/master'
[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 prerequsites (behave from apt)
84               run: sudo apt-get install -y -qq python3-behave
85               if: matrix.flavour == 'ubuntu-20'
86
87             - name: Install test prerequsites (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 prerequsites (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 prerequsites (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 != 'oldstuff'
109
110             - name: Python linting
111               run: python3 -m pylint nominatim
112               working-directory: Nominatim
113               if: matrix.flavour != 'oldstuff'
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 nominatim
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 prerequsites
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 prerequsites
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-20, Ubuntu-22]
231                 include:
232                     - name: Ubuntu-20
233                       image: "ubuntu:20.04"
234                       ubuntu: 20
235                       install_mode: install-apache
236                     - name: Ubuntu-22
237                       image: "ubuntu:22.04"
238                       ubuntu: 22
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: Print version
296               run: nominatim --version
297               working-directory: /home/nominatim/nominatim-project
298
299             - name: Print taginfo
300               run: lua taginfo.lua
301               working-directory: /home/nominatim
302
303             - name: Collect host OS information
304               run: nominatim admin --collect-os-info
305               working-directory: /home/nominatim/nominatim-project
306
307             - name: Import
308               run: nominatim import --osm-file ../test.pbf
309               working-directory: /home/nominatim/nominatim-project
310
311             - name: Import special phrases
312               run: nominatim special-phrases --import-from-wiki
313               working-directory: /home/nominatim/nominatim-project
314
315             - name: Check full import
316               run: nominatim admin --check-database
317               working-directory: /home/nominatim/nominatim-project
318
319             - name: Warm up database
320               run: nominatim admin --warm
321               working-directory: /home/nominatim/nominatim-project
322
323             - name: Prepare update (Ubuntu)
324               run: apt-get install -y python3-pip
325               shell: bash
326
327             - name: Run update
328               run: |
329                   pip3 install --user osmium
330                   nominatim replication --init
331                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
332               working-directory: /home/nominatim/nominatim-project
333
334             - name: Clean up database
335               run: nominatim refresh --postcodes --word-tokens
336               working-directory: /home/nominatim/nominatim-project
337
338             - name: Run reverse-only import
339               run : |
340                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
341                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
342               working-directory: /home/nominatim/data-env-reverse
343
344             - name: Check reverse-only import
345               run: nominatim admin --check-database
346               working-directory: /home/nominatim/data-env-reverse
347
348             - name: Clean up database (reverse-only import)
349               run: nominatim refresh --postcodes --word-tokens
350               working-directory: /home/nominatim/nominatim-project
351
352     install-no-superuser:
353       runs-on: ubuntu-latest
354       needs: create-archive
355
356       steps:
357           - uses: actions/download-artifact@v4
358             with:
359                 name: full-source
360
361           - name: Unpack Nominatim
362             run: tar xf nominatim-src.tar.bz2
363
364           - uses: ./Nominatim/.github/actions/setup-postgresql
365             with:
366                 postgresql-version: 16
367                 postgis-version: 3
368
369           - uses: ./Nominatim/.github/actions/build-nominatim
370             with:
371                 flavour: ubuntu-22
372                 lua: 5.3
373
374           - name: Prepare import environment
375             run: |
376                 mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
377                 rm -rf Nominatim
378
379           - name: Prepare Database
380             run: |
381                 nominatim import --prepare-database
382
383           - name: Create import user
384             run: |
385                 sudo -u postgres createuser osm-import
386                 psql -d nominatim -c "ALTER USER \"osm-import\" WITH PASSWORD 'osm-import'"
387                 psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "osm-import"'
388
389           - name: Run import
390             run: |
391                 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
392
393           - name: Check full import
394             run: nominatim admin --check-database
395
396     codespell:
397       runs-on: ubuntu-latest
398       steps:
399           - uses: codespell-project/actions-codespell@v2
400             with:
401                 only_warn: 1