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