]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
remove support for sanic framework
[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@v3
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
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
117
118             - name: Install latest pylint
119               run: pip3 install -U pylint asgi_lifespan
120
121             - name: PHP linting
122               run: phpcs --report-width=120 .
123               working-directory: Nominatim
124
125             - name: Python linting
126               run: python3 -m pylint nominatim
127               working-directory: Nominatim
128
129             - name: PHP unit tests
130               run: phpunit ./
131               working-directory: Nominatim/test/php
132
133             - name: Python unit tests
134               run: python3 -m pytest test/python
135               working-directory: Nominatim
136
137             - name: BDD tests
138               run: |
139                   python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
140               working-directory: Nominatim/test/bdd
141
142             - name: Install mypy and typechecking info
143               run: pip3 install -U mypy osmium uvicorn types-PyYAML types-jinja2 types-psycopg2 types-psutil types-requests types-ujson types-Pygments typing-extensions
144               if: matrix.flavour != 'oldstuff'
145
146             - name: Python static typechecking
147               run: python3 -m mypy --strict nominatim
148               working-directory: Nominatim
149               if: matrix.flavour != 'oldstuff'
150
151     legacy-test:
152         needs: create-archive
153         runs-on: ubuntu-20.04
154
155         steps:
156             - uses: actions/download-artifact@v3
157               with:
158                   name: full-source
159
160             - name: Unpack Nominatim
161               run: tar xf nominatim-src.tar.bz2
162
163             - name: Setup PHP
164               uses: shivammathur/setup-php@v2
165               with:
166                   php-version: '7.4'
167
168             - uses: ./Nominatim/.github/actions/setup-postgresql
169               with:
170                   postgresql-version: 13
171                   postgis-version: 3
172
173             - name: Install Postgresql server dev
174               run: sudo apt-get install postgresql-server-dev-13
175
176             - uses: ./Nominatim/.github/actions/build-nominatim
177               with:
178                   cmake-args: -DBUILD_MODULE=on
179
180             - name: Install test prerequsites
181               run: sudo apt-get install -y -qq python3-behave
182
183             - name: BDD tests (legacy tokenizer)
184               run: |
185                   python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=legacy --format=progress3
186               working-directory: Nominatim/test/bdd
187
188
189     install:
190         runs-on: ubuntu-latest
191         needs: create-archive
192
193         strategy:
194             matrix:
195                 name: [Ubuntu-20, Ubuntu-22]
196                 include:
197                     - name: Ubuntu-20
198                       image: "ubuntu:20.04"
199                       ubuntu: 20
200                       install_mode: install-apache
201                     - name: Ubuntu-22
202                       image: "ubuntu:22.04"
203                       ubuntu: 22
204                       install_mode: install-apache
205
206         container:
207             image: ${{ matrix.image }}
208             env:
209                 LANG: en_US.UTF-8
210
211         defaults:
212             run:
213                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
214
215         steps:
216             - name: Prepare container (Ubuntu)
217               run: |
218                   export APT_LISTCHANGES_FRONTEND=none
219                   export DEBIAN_FRONTEND=noninteractive
220                   apt-get update -qq
221                   apt-get install -y git sudo wget
222                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
223               shell: bash
224
225             - name: Setup import user
226               run: |
227                   useradd -m nominatim
228                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
229                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
230               shell: bash
231               env:
232                 OS: ${{ matrix.name }}
233                 INSTALL_MODE: ${{ matrix.install_mode }}
234
235             - uses: actions/download-artifact@v3
236               with:
237                   name: full-source
238                   path: /home/nominatim
239
240             - name: Install Nominatim
241               run: |
242                 export USERNAME=nominatim
243                 export USERHOME=/home/nominatim
244                 export NOSYSTEMD=yes
245                 export HAVE_SELINUX=no
246                 tar xf nominatim-src.tar.bz2
247                 . vagrant.sh
248               working-directory: /home/nominatim
249
250             - name: Prepare import environment
251               run: |
252                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
253                   mv Nominatim/settings/flex-base.lua flex-base.lua
254                   mv Nominatim/settings/import-extratags.lua import-extratags.lua
255                   mv Nominatim/settings/taginfo.lua taginfo.lua
256                   rm -rf Nominatim
257                   mkdir data-env-reverse
258               working-directory: /home/nominatim
259
260             - name: Print version
261               run: nominatim --version
262               working-directory: /home/nominatim/nominatim-project
263
264             - name: Print taginfo
265               run: lua taginfo.lua
266               working-directory: /home/nominatim
267
268             - name: Collect host OS information
269               run: nominatim admin --collect-os-info
270               working-directory: /home/nominatim/nominatim-project
271
272             - name: Import
273               run: nominatim import --osm-file ../test.pbf
274               working-directory: /home/nominatim/nominatim-project
275
276             - name: Import special phrases
277               run: nominatim special-phrases --import-from-wiki
278               working-directory: /home/nominatim/nominatim-project
279
280             - name: Check full import
281               run: nominatim admin --check-database
282               working-directory: /home/nominatim/nominatim-project
283
284             - name: Warm up database
285               run: nominatim admin --warm
286               working-directory: /home/nominatim/nominatim-project
287
288             - name: Prepare update (Ubuntu)
289               run: apt-get install -y python3-pip
290               shell: bash
291
292             - name: Run update
293               run: |
294                   pip3 install --user osmium
295                   nominatim replication --init
296                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
297               working-directory: /home/nominatim/nominatim-project
298
299             - name: Clean up database
300               run: nominatim refresh --postcodes --word-tokens
301               working-directory: /home/nominatim/nominatim-project
302
303             - name: Run reverse-only import
304               run : |
305                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
306                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
307               working-directory: /home/nominatim/data-env-reverse
308
309             - name: Check reverse-only import
310               run: nominatim admin --check-database
311               working-directory: /home/nominatim/data-env-reverse
312
313             - name: Clean up database (reverse-only import)
314               run: nominatim refresh --postcodes --word-tokens
315               working-directory: /home/nominatim/nominatim-project