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