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