]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
use autocommit when creating tables and indexes
[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                   rm -rf Nominatim
189                   mkdir data-env-reverse
190               working-directory: /home/nominatim
191
192             - name: Add nominatim to path
193               run: |
194                 sudo ln -s /home/nominatim/nominatim-venv/bin/nominatim /usr/local/bin/nominatim
195
196             - name: Need lua binary
197               run: |
198                 sudo apt-get install -y lua5.4 lua-dkjson
199
200             - name: Print version
201               run: nominatim --version
202               working-directory: /home/nominatim/nominatim-project
203
204             - name: Print taginfo
205               run: lua ./nominatim-venv/lib/*/site-packages/nominatim_db/resources/lib-lua/taginfo.lua
206               working-directory: /home/nominatim
207
208             - name: Collect host OS information
209               run: nominatim admin --collect-os-info
210               working-directory: /home/nominatim/nominatim-project
211
212             - name: Import
213               run: nominatim import --osm-file ../test.pbf
214               working-directory: /home/nominatim/nominatim-project
215
216             - name: Import special phrases
217               run: nominatim special-phrases --import-from-wiki
218               working-directory: /home/nominatim/nominatim-project
219
220             - name: Check full import
221               run: nominatim admin --check-database
222               working-directory: /home/nominatim/nominatim-project
223
224             - name: Warm up database
225               run: nominatim admin --warm
226               working-directory: /home/nominatim/nominatim-project
227
228             - name: Install osmium
229               run: |
230                   /home/nominatim/nominatim-venv/bin/pip install osmium
231
232             - name: Run update
233               run: |
234                   nominatim replication --init
235                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
236               working-directory: /home/nominatim/nominatim-project
237
238             - name: Clean up database
239               run: nominatim refresh --postcodes --word-tokens
240               working-directory: /home/nominatim/nominatim-project
241
242             - name: Run reverse-only import
243               run : |
244                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
245                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
246               working-directory: /home/nominatim/data-env-reverse
247
248             - name: Check reverse-only import
249               run: nominatim admin --check-database
250               working-directory: /home/nominatim/data-env-reverse
251
252             - name: Clean up database (reverse-only import)
253               run: nominatim refresh --postcodes --word-tokens
254               working-directory: /home/nominatim/nominatim-project
255
256     install-no-superuser:
257       runs-on: ubuntu-24.04
258       needs: create-archive
259
260       steps:
261           - uses: actions/download-artifact@v4
262             with:
263                 name: full-source
264
265           - name: Unpack Nominatim
266             run: tar xf nominatim-src.tar.bz2
267
268           - uses: ./Nominatim/.github/actions/setup-postgresql
269             with:
270                 postgresql-version: 16
271
272           - uses: ./Nominatim/.github/actions/build-nominatim
273
274           - name: Prepare import environment
275             run: |
276                 mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
277                 rm -rf Nominatim
278
279           - name: Prepare Database
280             run: |
281                 ./venv/bin/nominatim import --prepare-database
282
283           - name: Create import user
284             run: |
285                 sudo -u postgres createuser osm-import
286                 psql -d nominatim -c "ALTER USER \"osm-import\" WITH PASSWORD 'osm-import'"
287                 psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "osm-import"'
288
289           - name: Run import
290             run: |
291                 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
292
293           - name: Check full import
294             run: ./venv/bin/nominatim admin --check-database
295
296     migrate:
297       runs-on: ubuntu-24.04
298       needs: create-archive
299
300       steps:
301           - uses: actions/download-artifact@v4
302             with:
303                 name: full-source
304
305           - name: Unpack Nominatim
306             run: tar xf nominatim-src.tar.bz2
307
308           - uses: ./Nominatim/.github/actions/setup-postgresql
309             with:
310                 postgresql-version: 17
311
312           - name: Install Python dependencies
313             run: |
314               sudo apt-get install --no-install-recommends virtualenv osm2pgsql
315
316           - name: Install Nominatim master version
317             run: |
318               virtualenv master
319               cd Nominatim
320               ../master/bin/pip install packaging/nominatim-db
321
322           - name: Install Nominatim from pypi
323             run: |
324               virtualenv release
325               ./release/bin/pip install nominatim-db
326
327           - name: Import Nominatim database using release
328             run: |
329               ./release/bin/nominatim import --osm-file Nominatim/test/testdb/apidb-test-data.pbf
330               ./release/bin/nominatim add-data --file Nominatim/test/testdb/additional_api_test.data.osm
331
332           - name: Migrate to master version
333             run: |
334               ./master/bin/nominatim admin --migrate
335               ./release/bin/nominatim add-data --file Nominatim/test/testdb/additional_api_test.data.osm
336
337     codespell:
338       runs-on: ubuntu-latest
339       steps:
340           - uses: codespell-project/actions-codespell@v2
341             with:
342                 only_warn: 1