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