]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
293743df03f5e3546cb60a28f439f77b6a896c43
[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: ["ubuntu-20", "ubuntu-24"]
41                 include:
42                     - flavour: ubuntu-20
43                       ubuntu: 20
44                       postgresql: 12
45                       postgis: 3
46                       lua: '5.1'
47                     - flavour: ubuntu-24
48                       ubuntu: 24
49                       postgresql: 17
50                       postgis: 3
51                       lua: '5.3'
52
53         runs-on: ubuntu-${{ matrix.ubuntu }}.04
54
55         steps:
56             - uses: actions/download-artifact@v4
57               with:
58                   name: full-source
59
60             - name: Unpack Nominatim
61               run: tar xf nominatim-src.tar.bz2
62
63             - uses: actions/setup-python@v5
64               with:
65                 python-version: 3.7
66               if: matrix.flavour == 'oldstuff'
67
68             - uses: ./Nominatim/.github/actions/setup-postgresql
69               with:
70                   postgresql-version: ${{ matrix.postgresql }}
71                   postgis-version: ${{ matrix.postgis }}
72
73             - uses: ./Nominatim/.github/actions/build-nominatim
74               with:
75                   flavour: ${{ matrix.flavour }}
76                   lua: ${{ matrix.lua }}
77
78             - name: Install test prerequisites
79               run: pip3 install behave==1.2.6
80
81             - name: Install test prerequisites
82               run: sudo apt-get install -y -qq python3-pytest python3-pytest-asyncio uvicorn
83
84             - name: Install newer pytest-asyncio
85               run: pip3 install -U pytest-asyncio
86               if: matrix.flavour == 'ubuntu-20'
87
88             - name: Install Python webservers
89               run: pip3 install falcon starlette asgi_lifespan
90
91             - name: Install latest flake8
92               run: pip3 install -U flake8
93
94             - name: Python linting
95               run: python3 -m flake8 src
96               working-directory: Nominatim
97
98             - name: Python unit tests
99               run: python3 -m pytest test/python
100               working-directory: Nominatim
101
102             - name: BDD tests
103               run: |
104                   export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
105                   python3 -m behave -DREMOVE_TEMPLATE=1 --format=progress3
106               working-directory: Nominatim/test/bdd
107
108             - name: Install mypy and typechecking info
109               run: pip3 install -U mypy osmium uvicorn types-PyYAML types-jinja2 types-psycopg2 types-psutil types-requests types-ujson types-Pygments typing-extensions
110
111             - name: Python static typechecking
112               run: python3 -m mypy --strict --python-version 3.8 src
113               working-directory: Nominatim
114
115     install:
116         runs-on: ubuntu-latest
117         needs: create-archive
118
119         strategy:
120             matrix:
121                 name: [Ubuntu-22, Ubuntu-24]
122                 include:
123                     - name: Ubuntu-22
124                       image: "ubuntu:22.04"
125                       ubuntu: 22
126                       install_mode: install-apache
127                     - name: Ubuntu-24
128                       image: "ubuntu:24.04"
129                       ubuntu: 24
130                       install_mode: install-apache
131
132         container:
133             image: ${{ matrix.image }}
134             env:
135                 LANG: en_US.UTF-8
136
137         defaults:
138             run:
139                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
140
141         steps:
142             - name: Prepare container (Ubuntu)
143               run: |
144                   export APT_LISTCHANGES_FRONTEND=none
145                   export DEBIAN_FRONTEND=noninteractive
146                   apt-get update -qq
147                   apt-get install -y git sudo wget
148                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
149               shell: bash
150
151             - name: Setup import user
152               run: |
153                   useradd -m nominatim
154                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
155                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
156               shell: bash
157               env:
158                 OS: ${{ matrix.name }}
159                 INSTALL_MODE: ${{ matrix.install_mode }}
160
161             - uses: actions/download-artifact@v4
162               with:
163                   name: full-source
164                   path: /home/nominatim
165
166             - name: Install Nominatim
167               run: |
168                 export USERNAME=nominatim
169                 export USERHOME=/home/nominatim
170                 export NOSYSTEMD=yes
171                 export HAVE_SELINUX=no
172                 tar xf nominatim-src.tar.bz2
173                 . vagrant.sh
174               working-directory: /home/nominatim
175
176             - name: Prepare import environment
177               run: |
178                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
179                   mv Nominatim/settings/flex-base.lua flex-base.lua
180                   mv Nominatim/settings/import-extratags.lua import-extratags.lua
181                   mv Nominatim/settings/taginfo.lua taginfo.lua
182                   rm -rf Nominatim
183                   mkdir data-env-reverse
184               working-directory: /home/nominatim
185
186             - name: Add nominatim to path
187               run: |
188                 sudo ln -s /home/nominatim/nominatim-venv/bin/nominatim /usr/local/bin/nominatim
189               if: matrix.ubuntu == 24
190
191             - name: Need lua binary
192               run: |
193                 sudo apt-get install -y lua5.4 lua-dkjson
194               if: matrix.ubuntu == 24
195
196             - name: Print version
197               run: nominatim --version
198               working-directory: /home/nominatim/nominatim-project
199
200             - name: Print taginfo
201               run: lua taginfo.lua
202               working-directory: /home/nominatim
203
204             - name: Collect host OS information
205               run: nominatim admin --collect-os-info
206               working-directory: /home/nominatim/nominatim-project
207
208             - name: Import
209               run: nominatim import --osm-file ../test.pbf
210               working-directory: /home/nominatim/nominatim-project
211
212             - name: Import special phrases
213               run: nominatim special-phrases --import-from-wiki
214               working-directory: /home/nominatim/nominatim-project
215
216             - name: Check full import
217               run: nominatim admin --check-database
218               working-directory: /home/nominatim/nominatim-project
219
220             - name: Warm up database
221               run: nominatim admin --warm
222               working-directory: /home/nominatim/nominatim-project
223
224             - name: Prepare update (Ubuntu)
225               run: apt-get install -y python3-pip
226               shell: bash
227
228             - name: Install osmium (Ubuntu 22)
229               run: |
230                   pip3 install --user osmium
231               if: matrix.ubuntu == 22
232
233             - name: Install osmium (Ubuntu 24)
234               run: |
235                   /home/nominatim/nominatim-venv/bin/pip install osmium
236               if: matrix.ubuntu == 24
237
238             - name: Run update
239               run: |
240                   nominatim replication --init
241                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
242               working-directory: /home/nominatim/nominatim-project
243
244             - name: Clean up database
245               run: nominatim refresh --postcodes --word-tokens
246               working-directory: /home/nominatim/nominatim-project
247
248             - name: Run reverse-only import
249               run : |
250                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
251                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
252               working-directory: /home/nominatim/data-env-reverse
253
254             - name: Check reverse-only import
255               run: nominatim admin --check-database
256               working-directory: /home/nominatim/data-env-reverse
257
258             - name: Clean up database (reverse-only import)
259               run: nominatim refresh --postcodes --word-tokens
260               working-directory: /home/nominatim/nominatim-project
261
262     install-no-superuser:
263       runs-on: ubuntu-latest
264       needs: create-archive
265
266       steps:
267           - uses: actions/download-artifact@v4
268             with:
269                 name: full-source
270
271           - name: Unpack Nominatim
272             run: tar xf nominatim-src.tar.bz2
273
274           - uses: ./Nominatim/.github/actions/setup-postgresql
275             with:
276                 postgresql-version: 16
277                 postgis-version: 3
278
279           - uses: ./Nominatim/.github/actions/build-nominatim
280             with:
281                 flavour: ubuntu-22
282                 lua: 5.3
283
284           - name: Prepare import environment
285             run: |
286                 mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
287                 rm -rf Nominatim
288
289           - name: Prepare Database
290             run: |
291                 nominatim import --prepare-database
292
293           - name: Create import user
294             run: |
295                 sudo -u postgres createuser osm-import
296                 psql -d nominatim -c "ALTER USER \"osm-import\" WITH PASSWORD 'osm-import'"
297                 psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "osm-import"'
298
299           - name: Run import
300             run: |
301                 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
302
303           - name: Check full import
304             run: nominatim admin --check-database
305
306     migrate:
307       runs-on: ubuntu-24.04
308       needs: create-archive
309
310       steps:
311           - uses: actions/download-artifact@v4
312             with:
313                 name: full-source
314
315           - name: Unpack Nominatim
316             run: tar xf nominatim-src.tar.bz2
317
318           - uses: ./Nominatim/.github/actions/setup-postgresql
319             with:
320                 postgresql-version: 17
321                 postgis-version: 3
322
323           - name: Install Python dependencies
324             run: |
325               sudo apt-get install --no-install-recommends virtualenv osm2pgsql
326
327           - name: Install Nominatim master version
328             run: |
329               virtualenv master
330               cd Nominatim
331               ../master/bin/pip install packaging/nominatim-db
332
333           - name: Install Nominatim from pypi
334             run: |
335               virtualenv release
336               ./release/bin/pip install nominatim-db
337
338           - name: Import Nominatim database using release
339             run: |
340               ./release/bin/nominatim import --osm-file Nominatim/test/testdb/apidb-test-data.pbf
341               ./release/bin/nominatim add-data --file Nominatim/test/testdb/additional_api_test.data.osm
342
343           - name: Migrate to master version
344             run: |
345               ./master/bin/nominatim admin --migrate
346               ./release/bin/nominatim add-data --file Nominatim/test/testdb/additional_api_test.data.osm
347
348     codespell:
349       runs-on: ubuntu-latest
350       steps:
351           - uses: codespell-project/actions-codespell@v2
352             with:
353                 only_warn: 1