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