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