]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
Merge pull request #2599 from StephanGeorg/patch-1
[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.6
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                   tools: phpunit, phpcs, composer
68
69             - uses: actions/setup-python@v2
70               with:
71                 python-version: 3.6
72               if: matrix.ubuntu == 18
73
74             - uses: ./Nominatim/.github/actions/setup-postgresql
75               with:
76                   postgresql-version: ${{ matrix.postgresql }}
77                   postgis-version: ${{ matrix.postgis }}
78
79             - uses: ./Nominatim/.github/actions/build-nominatim
80               with:
81                   ubuntu: ${{ matrix.ubuntu }}
82
83             - name: Install test prerequsites
84               run: sudo apt-get install -y -qq pylint python3-pytest python3-behave
85               if: matrix.ubuntu == 20
86
87             - name: Install test prerequsites
88               run: pip3 install pylint==2.6.0 pytest behave==1.2.6
89               if: matrix.ubuntu == 18
90
91             - name: PHP linting
92               run: phpcs --report-width=120 .
93               working-directory: Nominatim
94
95             - name: Python linting
96               run: pylint nominatim
97               working-directory: Nominatim
98
99             - name: PHP unit tests
100               run: phpunit ./
101               working-directory: Nominatim/test/php
102               if: matrix.ubuntu == 20
103
104             - name: Python unit tests
105               run: $PYTEST test/python
106               working-directory: Nominatim
107               env:
108                 PYTEST: ${{ matrix.pytest }}
109
110             - name: BDD tests
111               run: |
112                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
113               working-directory: Nominatim/test/bdd
114
115
116     icu-test:
117         needs: create-archive
118         strategy:
119             matrix:
120                 ubuntu: [20]
121                 include:
122                     - ubuntu: 20
123                       postgresql: 13
124                       postgis: 3
125                       pytest: py.test-3
126                       php: 7.4
127
128         runs-on: ubuntu-${{ matrix.ubuntu }}.04
129
130         steps:
131             - uses: actions/download-artifact@v2
132               with:
133                   name: full-source
134
135             - name: Unpack Nominatim
136               run: tar xf nominatim-src.tar.bz2
137
138             - name: Setup PHP
139               uses: shivammathur/setup-php@v2
140               with:
141                   php-version: ${{ matrix.php }}
142                   coverage: xdebug
143                   tools: phpunit, phpcs, composer
144
145             - uses: actions/setup-python@v2
146               with:
147                 python-version: 3.6
148               if: matrix.ubuntu == 18
149
150             - uses: ./Nominatim/.github/actions/setup-postgresql
151               with:
152                   postgresql-version: ${{ matrix.postgresql }}
153                   postgis-version: ${{ matrix.postgis }}
154
155             - uses: ./Nominatim/.github/actions/build-nominatim
156               with:
157                   ubuntu: ${{ matrix.ubuntu }}
158
159             - name: Install test prerequsites
160               run: sudo apt-get install -y -qq python3-behave
161               if: matrix.ubuntu == 20
162
163             - name: Install test prerequsites
164               run: pip3 install behave==1.2.6
165               if: matrix.ubuntu == 18
166
167             - name: BDD tests (icu tokenizer)
168               run: |
169                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=icu --format=progress3
170               working-directory: Nominatim/test/bdd
171
172
173     install:
174         runs-on: ubuntu-latest
175         needs: create-archive
176
177         strategy:
178             matrix:
179                 name: [Ubuntu-18, Ubuntu-20, Centos-8]
180                 include:
181                     - name: Ubuntu-18
182                       flavour: ubuntu
183                       image: "ubuntu:18.04"
184                       ubuntu: 18
185                       install_mode: install-nginx
186                     - name: Ubuntu-20
187                       flavour: ubuntu
188                       image: "ubuntu:20.04"
189                       ubuntu: 20
190                       install_mode: install-apache
191                     - name: Centos-8
192                       flavour: centos
193                       image: "centos:8"
194
195         container:
196             image: ${{ matrix.image }}
197             env:
198                 LANG: en_US.UTF-8
199
200         defaults:
201             run:
202                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
203
204         steps:
205             - name: Prepare container (Ubuntu)
206               run: |
207                   export APT_LISTCHANGES_FRONTEND=none
208                   export DEBIAN_FRONTEND=noninteractive
209                   apt-get update -qq
210                   apt-get install -y git sudo wget
211                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
212               shell: bash
213               if: matrix.flavour == 'ubuntu'
214
215             - name: Prepare container (CentOS)
216               run: |
217                   dnf update -y
218                   dnf install -y sudo glibc-langpack-en
219               shell: bash
220               if: matrix.flavour == 'centos'
221
222             - name: Setup import user
223               run: |
224                   useradd -m nominatim
225                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
226                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
227               shell: bash
228               env:
229                 OS: ${{ matrix.name }}
230                 INSTALL_MODE: ${{ matrix.install_mode }}
231
232             - uses: actions/download-artifact@v2
233               with:
234                   name: full-source
235                   path: /home/nominatim
236
237             - name: Install Nominatim
238               run: |
239                 export USERNAME=nominatim
240                 export USERHOME=/home/nominatim
241                 export NOSYSTEMD=yes
242                 export HAVE_SELINUX=no
243                 tar xf nominatim-src.tar.bz2
244                 . vagrant.sh
245               working-directory: /home/nominatim
246
247             - name: Prepare import environment
248               run: |
249                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
250                   rm -rf Nominatim
251                   mkdir data-env-reverse
252               working-directory: /home/nominatim
253
254             - name: Prepare import environment (CentOS)
255               run: |
256                   sudo ln -s /usr/local/bin/nominatim /usr/bin/nominatim
257                   echo NOMINATIM_DATABASE_WEBUSER="apache" > nominatim-project/.env
258                   cp nominatim-project/.env data-env-reverse/.env
259               working-directory: /home/nominatim
260               if: matrix.flavour == 'centos'
261
262             - name: Import
263               run: nominatim import --osm-file ../test.pbf
264               working-directory: /home/nominatim/nominatim-project
265
266             - name: Import special phrases
267               run: nominatim special-phrases --import-from-wiki
268               working-directory: /home/nominatim/nominatim-project
269
270             - name: Check full import
271               run: nominatim admin --check-database
272               working-directory: /home/nominatim/nominatim-project
273
274             - name: Warm up database
275               run: nominatim admin --warm
276               working-directory: /home/nominatim/nominatim-project
277
278             - name: Prepare update (Ubuntu)
279               run: apt-get install -y python3-pip
280               shell: bash
281               if: matrix.flavour == 'ubuntu'
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