]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
add tests for cleaning housenumbers
[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@v2
11               with:
12                 submodules: true
13
14             - uses: actions/cache@v2
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@v2
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                 ubuntu: [18, 20]
41                 include:
42                     - ubuntu: 18
43                       postgresql: 9.5
44                       postgis: 2.5
45                       pytest: pytest
46                       php: 7.2
47                     - ubuntu: 20
48                       postgresql: 13
49                       postgis: 3
50                       pytest: py.test-3
51                       php: 7.4
52
53         runs-on: ubuntu-${{ matrix.ubuntu }}.04
54
55         steps:
56             - uses: actions/download-artifact@v2
57               with:
58                   name: full-source
59
60             - name: Unpack Nominatim
61               run: tar xf nominatim-src.tar.bz2
62
63             - name: Setup PHP
64               uses: shivammathur/setup-php@v2
65               with:
66                   php-version: ${{ matrix.php }}
67                   coverage: xdebug
68                   tools: phpunit, phpcs, composer
69
70             - uses: actions/setup-python@v2
71               with:
72                 python-version: 3.6
73               if: matrix.ubuntu == 18
74
75             - uses: ./Nominatim/.github/actions/setup-postgresql
76               with:
77                   postgresql-version: ${{ matrix.postgresql }}
78                   postgis-version: ${{ matrix.postgis }}
79
80             - uses: ./Nominatim/.github/actions/build-nominatim
81               with:
82                   ubuntu: ${{ matrix.ubuntu }}
83
84             - name: Install test prerequsites
85               run: sudo apt-get install -y -qq pylint python3-pytest python3-behave python3-pytest-cov php-codecoverage
86               if: matrix.ubuntu == 20
87
88             - name: Install test prerequsites
89               run: pip3 install pylint==2.6.0 pytest pytest-cov behave==1.2.6
90               if: matrix.ubuntu == 18
91
92             - name: PHP linting
93               run: phpcs --report-width=120 .
94               working-directory: Nominatim
95
96             - name: Python linting
97               run: pylint nominatim
98               working-directory: Nominatim
99
100             - name: PHP unit tests
101               run: phpunit --coverage-clover ../../coverage-php.xml ./
102               working-directory: Nominatim/test/php
103               if: matrix.ubuntu == 20
104
105             - name: Python unit tests
106               run: $PYTEST --cov=nominatim --cov-report=xml test/python
107               working-directory: Nominatim
108               env:
109                 PYTEST: ${{ matrix.pytest }}
110
111             - name: BDD tests
112               run: |
113                   mkdir cov
114                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3 -DPHPCOV=./cov
115                   composer require phpunit/phpcov:7.0.2
116                   vendor/bin/phpcov merge --clover ../../coverage-bdd.xml ./cov
117               working-directory: Nominatim/test/bdd
118               if: matrix.ubuntu == 20
119
120             - name: BDD tests
121               run: |
122                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
123               working-directory: Nominatim/test/bdd
124               if: matrix.ubuntu == 18
125
126             - name: Upload coverage to Codecov
127               uses: codecov/codecov-action@v1
128               with:
129                 files: ./Nominatim/coverage*.xml
130                 directory: ./
131                 name: codecov-umbrella
132                 fail_ci_if_error: false
133                 path_to_write_report: ./coverage/codecov_report.txt
134                 verbose: true
135               if: matrix.ubuntu == 20
136
137
138     icu-test:
139         needs: create-archive
140         strategy:
141             matrix:
142                 ubuntu: [20]
143                 include:
144                     - ubuntu: 20
145                       postgresql: 13
146                       postgis: 3
147                       pytest: py.test-3
148                       php: 7.4
149
150         runs-on: ubuntu-${{ matrix.ubuntu }}.04
151
152         steps:
153             - uses: actions/download-artifact@v2
154               with:
155                   name: full-source
156
157             - name: Unpack Nominatim
158               run: tar xf nominatim-src.tar.bz2
159
160             - name: Setup PHP
161               uses: shivammathur/setup-php@v2
162               with:
163                   php-version: ${{ matrix.php }}
164                   coverage: xdebug
165                   tools: phpunit, phpcs, composer
166
167             - uses: actions/setup-python@v2
168               with:
169                 python-version: 3.6
170               if: matrix.ubuntu == 18
171
172             - uses: ./Nominatim/.github/actions/setup-postgresql
173               with:
174                   postgresql-version: ${{ matrix.postgresql }}
175                   postgis-version: ${{ matrix.postgis }}
176
177             - uses: ./Nominatim/.github/actions/build-nominatim
178               with:
179                   ubuntu: ${{ matrix.ubuntu }}
180
181             - name: Install test prerequsites
182               run: sudo apt-get install -y -qq python3-behave
183               if: matrix.ubuntu == 20
184
185             - name: Install test prerequsites
186               run: pip3 install behave==1.2.6
187               if: matrix.ubuntu == 18
188
189             - name: BDD tests (icu tokenizer)
190               run: |
191                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=icu --format=progress3
192               working-directory: Nominatim/test/bdd
193
194
195     install:
196         runs-on: ubuntu-latest
197         needs: create-archive
198
199         strategy:
200             matrix:
201                 name: [Ubuntu-18, Ubuntu-20, Centos-8]
202                 include:
203                     - name: Ubuntu-18
204                       flavour: ubuntu
205                       image: "ubuntu:18.04"
206                       ubuntu: 18
207                       install_mode: install-nginx
208                     - name: Ubuntu-20
209                       flavour: ubuntu
210                       image: "ubuntu:20.04"
211                       ubuntu: 20
212                       install_mode: install-apache
213                     - name: Centos-8
214                       flavour: centos
215                       image: "centos:8"
216
217         container:
218             image: ${{ matrix.image }}
219             env:
220                 LANG: en_US.UTF-8
221
222         defaults:
223             run:
224                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
225
226         steps:
227             - name: Prepare container (Ubuntu)
228               run: |
229                   export APT_LISTCHANGES_FRONTEND=none
230                   export DEBIAN_FRONTEND=noninteractive
231                   apt-get update -qq
232                   apt-get install -y git sudo wget
233                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
234               shell: bash
235               if: matrix.flavour == 'ubuntu'
236
237             - name: Prepare container (CentOS)
238               run: |
239                   dnf update -y
240                   dnf install -y sudo glibc-langpack-en
241               shell: bash
242               if: matrix.flavour == 'centos'
243
244             - name: Setup import user
245               run: |
246                   useradd -m nominatim
247                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
248                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
249               shell: bash
250               env:
251                 OS: ${{ matrix.name }}
252                 INSTALL_MODE: ${{ matrix.install_mode }}
253
254             - uses: actions/download-artifact@v2
255               with:
256                   name: full-source
257                   path: /home/nominatim
258
259             - name: Install Nominatim
260               run: |
261                 export USERNAME=nominatim
262                 export USERHOME=/home/nominatim
263                 export NOSYSTEMD=yes
264                 export HAVE_SELINUX=no
265                 tar xf nominatim-src.tar.bz2
266                 . vagrant.sh
267               working-directory: /home/nominatim
268
269             - name: Prepare import environment
270               run: |
271                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
272                   rm -rf Nominatim
273                   mkdir data-env-reverse
274               working-directory: /home/nominatim
275
276             - name: Prepare import environment (CentOS)
277               run: |
278                   sudo ln -s /usr/local/bin/nominatim /usr/bin/nominatim
279                   echo NOMINATIM_DATABASE_WEBUSER="apache" > nominatim-project/.env
280                   cp nominatim-project/.env data-env-reverse/.env
281               working-directory: /home/nominatim
282               if: matrix.flavour == 'centos'
283
284             - name: Import
285               run: nominatim import --osm-file ../test.pbf
286               working-directory: /home/nominatim/nominatim-project
287
288             - name: Import special phrases
289               run: nominatim special-phrases --import-from-wiki
290               working-directory: /home/nominatim/nominatim-project
291
292             - name: Check full import
293               run: nominatim admin --check-database
294               working-directory: /home/nominatim/nominatim-project
295
296             - name: Warm up database
297               run: nominatim admin --warm
298               working-directory: /home/nominatim/nominatim-project
299
300             - name: Prepare update (Ubuntu)
301               run: apt-get install -y python3-pip
302               shell: bash
303               if: matrix.flavour == 'ubuntu'
304
305             - name: Run update
306               run: |
307                   pip3 install --user osmium
308                   nominatim replication --init
309                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
310               working-directory: /home/nominatim/nominatim-project
311
312             - name: Clean up database
313               run: nominatim refresh --postcodes --word-tokens
314               working-directory: /home/nominatim/nominatim-project
315
316             - name: Run reverse-only import
317               run : |
318                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
319                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
320               working-directory: /home/nominatim/data-env-reverse
321
322             - name: Check reverse-only import
323               run: nominatim admin --check-database
324               working-directory: /home/nominatim/data-env-reverse
325
326             - name: Clean up database (reverse-only import)
327               run: nominatim refresh --postcodes --word-tokens
328               working-directory: /home/nominatim/nominatim-project