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