]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
bac20d98094104501a744b78111bf6a6c528641e
[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: BDD tests (icu tokenizer)
127               run: |
128                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=icu --format=progress3
129               working-directory: Nominatim/test/bdd
130
131             - name: Upload coverage to Codecov
132               uses: codecov/codecov-action@v1
133               with:
134                 files: ./Nominatim/coverage*.xml
135                 directory: ./
136                 name: codecov-umbrella
137                 fail_ci_if_error: false
138                 path_to_write_report: ./coverage/codecov_report.txt
139                 verbose: true
140               if: matrix.ubuntu == 20
141
142
143     install:
144         runs-on: ubuntu-latest
145         needs: create-archive
146
147         strategy:
148             matrix:
149                 name: [Ubuntu-18, Ubuntu-20, Centos-8]
150                 include:
151                     - name: Ubuntu-18
152                       flavour: ubuntu
153                       image: "ubuntu:18.04"
154                       ubuntu: 18
155                       install_mode: install-nginx
156                     - name: Ubuntu-20
157                       flavour: ubuntu
158                       image: "ubuntu:20.04"
159                       ubuntu: 20
160                       install_mode: install-apache
161                     - name: Centos-8
162                       flavour: centos
163                       image: "centos:8"
164
165         container:
166             image: ${{ matrix.image }}
167             env:
168                 LANG: en_US.UTF-8
169
170         defaults:
171             run:
172                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
173
174         steps:
175             - name: Prepare container (Ubuntu)
176               run: |
177                   export APT_LISTCHANGES_FRONTEND=none
178                   export DEBIAN_FRONTEND=noninteractive
179                   apt-get update -qq
180                   apt-get install -y git sudo wget
181                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
182               shell: bash
183               if: matrix.flavour == 'ubuntu'
184
185             - name: Prepare container (CentOS)
186               run: |
187                   dnf update -y
188                   dnf install -y sudo
189               shell: bash
190               if: matrix.flavour == 'centos'
191
192             - name: Setup import user
193               run: |
194                   useradd -m nominatim
195                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
196                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
197               shell: bash
198               env:
199                 OS: ${{ matrix.name }}
200                 INSTALL_MODE: ${{ matrix.install_mode }}
201
202             - uses: actions/download-artifact@v2
203               with:
204                   name: full-source
205                   path: /home/nominatim
206
207             - name: Install Nominatim
208               run: |
209                 export USERNAME=nominatim
210                 export USERHOME=/home/nominatim
211                 export NOSYSTEMD=yes
212                 export HAVE_SELINUX=no
213                 tar xf nominatim-src.tar.bz2
214                 . vagrant.sh
215               working-directory: /home/nominatim
216
217             - name: Prepare import environment
218               run: |
219                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
220                   rm -rf Nominatim
221                   mkdir data-env-reverse
222               working-directory: /home/nominatim
223
224             - name: Prepare import environment (CentOS)
225               run: |
226                   sudo ln -s /usr/local/bin/nominatim /usr/bin/nominatim
227                   echo NOMINATIM_DATABASE_WEBUSER="apache" > nominatim-project/.env
228                   cp nominatim-project/.env data-env-reverse/.env
229               working-directory: /home/nominatim
230               if: matrix.flavour == 'centos'
231
232             - name: Import
233               run: nominatim import --osm-file ../test.pbf
234               working-directory: /home/nominatim/nominatim-project
235
236             - name: Import special phrases
237               run: nominatim special-phrases --import-from-wiki
238               working-directory: /home/nominatim/nominatim-project
239
240             - name: Check full import
241               run: nominatim admin --check-database
242               working-directory: /home/nominatim/nominatim-project
243
244             - name: Warm up database
245               run: nominatim admin --warm
246               working-directory: /home/nominatim/nominatim-project
247
248             - name: Prepare update (Ubuntu)
249               run: apt-get install -y python3-pip
250               shell: bash
251               if: matrix.flavour == 'ubuntu'
252
253             - name: Run update
254               run: |
255                   pip3 install --user osmium
256                   nominatim replication --init
257                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
258               working-directory: /home/nominatim/nominatim-project
259
260             - name: Run reverse-only import
261               run : |
262                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
263                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
264               working-directory: /home/nominatim/data-env-reverse
265
266             - name: Check reverse import
267               run: nominatim admin --check-database
268               working-directory: /home/nominatim/data-env-reverse