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