]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
a26ad0001a357ee99b1c5cdacca37c5e7db6643c
[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, 22]
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                     - ubuntu: 22
53                       postgresql: 14
54                       postgis: 3
55                       pytest: py.test-3
56                       php: 8.1
57
58         runs-on: ubuntu-${{ matrix.ubuntu }}.04
59
60         steps:
61             - uses: actions/download-artifact@v2
62               with:
63                   name: full-source
64
65             - name: Unpack Nominatim
66               run: tar xf nominatim-src.tar.bz2
67
68             - name: Setup PHP
69               uses: shivammathur/setup-php@v2
70               with:
71                   php-version: ${{ matrix.php }}
72                   tools: phpunit, phpcs, composer
73                   ini-values: opcache.jit=disable
74
75             - uses: actions/setup-python@v2
76               with:
77                 python-version: 3.6
78               if: matrix.ubuntu == 18
79
80             - uses: ./Nominatim/.github/actions/setup-postgresql
81               with:
82                   postgresql-version: ${{ matrix.postgresql }}
83                   postgis-version: ${{ matrix.postgis }}
84
85             - uses: ./Nominatim/.github/actions/build-nominatim
86               with:
87                   ubuntu: ${{ matrix.ubuntu }}
88
89             - name: Install test prerequsites
90               run: sudo apt-get install -y -qq python3-pytest python3-behave
91               if: matrix.ubuntu == 20
92
93             - name: Install test prerequsites
94               run: pip3 install pylint pytest behave==1.2.6
95               if: ${{ (matrix.ubuntu == 18) || (matrix.ubuntu == 22) }}
96
97             - name: Install test prerequsites
98               run: sudo apt-get install -y -qq python3-pytest
99               if: matrix.ubuntu == 22
100
101             - name: Install latest pylint/mypy
102               run: pip3 install -U pylint mypy types-PyYAML types-jinja2 types-psycopg2 types-psutil typing-extensions
103
104             - name: PHP linting
105               run: phpcs --report-width=120 .
106               working-directory: Nominatim
107
108             - name: Python linting
109               run: pylint nominatim
110               working-directory: Nominatim
111
112             - name: Python static typechecking
113               run: mypy --strict nominatim
114               working-directory: Nominatim
115
116
117             - name: PHP unit tests
118               run: phpunit ./
119               working-directory: Nominatim/test/php
120               if: ${{ (matrix.ubuntu == 20) || (matrix.ubuntu == 22) }}
121
122             - name: Python unit tests
123               run: $PYTEST test/python
124               working-directory: Nominatim
125               env:
126                 PYTEST: ${{ matrix.pytest }}
127
128             - name: BDD tests
129               run: |
130                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
131               working-directory: Nominatim/test/bdd
132
133
134     legacy-test:
135         needs: create-archive
136         runs-on: ubuntu-20.04
137
138         steps:
139             - uses: actions/download-artifact@v2
140               with:
141                   name: full-source
142
143             - name: Unpack Nominatim
144               run: tar xf nominatim-src.tar.bz2
145
146             - name: Setup PHP
147               uses: shivammathur/setup-php@v2
148               with:
149                   php-version: 7.4
150
151             - uses: ./Nominatim/.github/actions/setup-postgresql
152               with:
153                   postgresql-version: 13
154                   postgis-version: 3
155
156             - name: Install Postgresql server dev
157               run: sudo apt-get install postgresql-server-dev-13
158
159             - uses: ./Nominatim/.github/actions/build-nominatim
160               with:
161                   ubuntu: 20
162                   cmake-args: -DBUILD_MODULE=on
163
164             - name: Install test prerequsites
165               run: sudo apt-get install -y -qq python3-behave
166
167             - name: BDD tests (legacy tokenizer)
168               run: |
169                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=legacy --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, Ubuntu-22]
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: Ubuntu-22
192                       flavour: ubuntu
193                       image: "ubuntu:22.04"
194                       ubuntu: 22
195                       install_mode: install-apache
196
197         container:
198             image: ${{ matrix.image }}
199             env:
200                 LANG: en_US.UTF-8
201
202         defaults:
203             run:
204                 shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
205
206         steps:
207             - name: Prepare container (Ubuntu)
208               run: |
209                   export APT_LISTCHANGES_FRONTEND=none
210                   export DEBIAN_FRONTEND=noninteractive
211                   apt-get update -qq
212                   apt-get install -y git sudo wget
213                   ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
214               shell: bash
215               if: matrix.flavour == 'ubuntu'
216
217             - name: Prepare container (CentOS)
218               run: |
219                   dnf update -y
220                   dnf install -y sudo glibc-langpack-en
221               shell: bash
222               if: matrix.flavour == 'centos'
223
224             - name: Setup import user
225               run: |
226                   useradd -m nominatim
227                   echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
228                   echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
229               shell: bash
230               env:
231                 OS: ${{ matrix.name }}
232                 INSTALL_MODE: ${{ matrix.install_mode }}
233
234             - uses: actions/download-artifact@v2
235               with:
236                   name: full-source
237                   path: /home/nominatim
238
239             - name: Install Nominatim
240               run: |
241                 export USERNAME=nominatim
242                 export USERHOME=/home/nominatim
243                 export NOSYSTEMD=yes
244                 export HAVE_SELINUX=no
245                 tar xf nominatim-src.tar.bz2
246                 . vagrant.sh
247               working-directory: /home/nominatim
248
249             - name: Prepare import environment
250               run: |
251                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
252                   rm -rf Nominatim
253                   mkdir data-env-reverse
254               working-directory: /home/nominatim
255
256             - name: Prepare import environment (CentOS)
257               run: |
258                   sudo ln -s /usr/local/bin/nominatim /usr/bin/nominatim
259                   echo NOMINATIM_DATABASE_WEBUSER="apache" > nominatim-project/.env
260                   cp nominatim-project/.env data-env-reverse/.env
261               working-directory: /home/nominatim
262               if: matrix.flavour == 'centos'
263
264             - name: Print version
265               run: nominatim --version
266               working-directory: /home/nominatim/nominatim-project
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               if: matrix.flavour == 'ubuntu'
292
293             - name: Run update
294               run: |
295                   pip3 install --user osmium
296                   nominatim replication --init
297                   NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
298               working-directory: /home/nominatim/nominatim-project
299
300             - name: Clean up database
301               run: nominatim refresh --postcodes --word-tokens
302               working-directory: /home/nominatim/nominatim-project
303
304             - name: Run reverse-only import
305               run : |
306                   echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
307                   nominatim import --osm-file ../test.pbf --reverse-only --no-updates
308               working-directory: /home/nominatim/data-env-reverse
309
310             - name: Check reverse-only import
311               run: nominatim admin --check-database
312               working-directory: /home/nominatim/data-env-reverse
313
314             - name: Clean up database (reverse-only import)
315               run: nominatim refresh --postcodes --word-tokens
316               working-directory: /home/nominatim/nominatim-project