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