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