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