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