]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
ea0efa47f062e420b4ea8623dfc97f71e16a1e54
[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: Prepare Database
309               run: |
310                   nominatim import --prepare-database
311               working-directory: /home/nominatim/nominatim-project
312
313             - name: Create import user
314               run: |
315                   sudo -u postgres createuser -S osm-import -P osm-import
316               working-directory: /home/nominatim/nominatim-project
317
318             - name: Grant import user rights
319               run: |
320                   sudo -u postgres psql -c "GRANT INSERT, UPDATE ON ALL TABLES IN SCHEMA public TO \"osm-import\";"
321               working-directory: /home/nominatim/nominatim-project
322
323             - name: Run import
324               run: |
325                   NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;user=osm-import;password=osm-import" nominatim import --continue import-from-file --osm-file ../test.pbf
326               working-directory: /home/nominatim/nominatim-project
327
328             - name: Import special phrases
329               run: nominatim special-phrases --import-from-wiki
330               working-directory: /home/nominatim/nominatim-project
331
332             - name: Check full import
333               run: nominatim admin --check-database
334               working-directory: /home/nominatim/nominatim-project
335
336             - name: Warm up database
337               run: nominatim admin --warm
338               working-directory: /home/nominatim/nominatim-project
339
340             - name: Prepare update (Ubuntu)
341               run: apt-get install -y python3-pip
342               shell: bash
343
344             - name: Run update
345               run: |
346                   pip3 install --user osmium
347                   nominatim replication --init
348                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
349               working-directory: /home/nominatim/nominatim-project
350
351             - name: Clean up database
352               run: nominatim refresh --postcodes --word-tokens
353               working-directory: /home/nominatim/nominatim-project
354
355             - name: Run reverse-only import
356               run : |
357                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
358                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
359               working-directory: /home/nominatim/data-env-reverse
360
361             - name: Check reverse-only import
362               run: nominatim admin --check-database
363               working-directory: /home/nominatim/data-env-reverse
364
365             - name: Clean up database (reverse-only import)
366               run: nominatim refresh --postcodes --word-tokens
367               working-directory: /home/nominatim/nominatim-project