]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / .github / workflows / ci-tests.yml
1 name: CI Tests
2
3 on: [ push, pull_request ]
4
5 jobs:
6     tests:
7         runs-on: ubuntu-20.04
8
9         strategy:
10             matrix:
11                 postgresql: [9.5, 13]
12                 include:
13                     - postgresql: 9.5
14                       postgis: 2.5
15                     - postgresql: 13
16                       postgis: 3
17
18         steps:
19             - uses: actions/checkout@v2
20               with:
21                   submodules: true
22                   path: Nominatim
23
24             - name: Setup PHP
25               uses: shivammathur/setup-php@v2
26               with:
27                   php-version: '7.4'
28                   tools: phpunit, phpcs, composer
29
30             - name: Get Date
31               id: get-date
32               run: |
33                   echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
34               shell: bash
35
36             - uses: actions/cache@v2
37               with:
38                   path: |
39                      country_grid.sql.gz
40                   key: nominatim-country-data-${{ steps.get-date.outputs.date }}
41
42             - uses: ./Nominatim/.github/actions/setup-postgresql
43               with:
44                   postgresql-version: ${{ matrix.postgresql }}
45                   postgis-version: ${{ matrix.postgis }}
46             - uses: ./Nominatim/.github/actions/build-nominatim
47
48             - name: Install test prerequsites
49               run: sudo apt-get install -y -qq php-codesniffer pylint python3-pytest python3-behave python3-pytest-cov php-codecoverage php-xdebug
50
51             - name: PHP linting
52               run: phpcs --report-width=120 .
53               working-directory: Nominatim
54
55             - name: Python linting
56               run: pylint --extension-pkg-whitelist=osmium nominatim
57               working-directory: Nominatim
58
59             - name: PHP unit tests
60               run: phpunit --coverage-clover ../../coverage-php.xml ./
61               working-directory: Nominatim/test/php
62
63             - name: Python unit tests
64               run: py.test-3 --cov=nominatim --cov-report=xml test/python
65               working-directory: Nominatim
66
67             - name: BDD tests
68               run: |
69                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3 -DPHPCOV=./cov
70                   composer require phpunit/phpcov:7.0.2
71                   vendor/bin/phpcov merge --clover ../../coverage-bdd.xml ./cov
72               working-directory: Nominatim/test/bdd
73
74             - name: BDD tests (legacy_icu tokenizer)
75               run: |
76                   behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=legacy_icu --format=progress3
77               working-directory: Nominatim/test/bdd
78
79             - name: Upload coverage to Codecov
80               uses: codecov/codecov-action@v1
81               with:
82                 files: ./Nominatim/coverage*.xml
83                 directory: ./
84                 name: codecov-umbrella
85                 fail_ci_if_error: false
86                 path_to_write_report: ./coverage/codecov_report.txt
87                 verbose: true
88
89     import:
90         strategy:
91             matrix:
92                 ubuntu: [18, 20]
93                 include:
94                     - ubuntu: 18
95                       postgresql: 9.5
96                       postgis: 2.5
97                     - ubuntu: 20
98                       postgresql: 13
99                       postgis: 3
100
101         runs-on: ubuntu-${{ matrix.ubuntu }}.04
102
103         steps:
104             - uses: actions/checkout@v2
105               with:
106                   submodules: true
107                   path: Nominatim
108
109             - name: Get Date
110               id: get-date
111               run: |
112                   echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
113               shell: bash
114
115             - uses: actions/cache@v2
116               with:
117                   path: |
118                      country_grid.sql.gz
119                   key: nominatim-country-data-${{ steps.get-date.outputs.date }}
120
121             - uses: actions/cache@v2
122               with:
123                   path: |
124                      monaco-latest.osm.pbf
125                   key: nominatim-test-data-${{ steps.get-date.outputs.date }}
126
127             - uses: actions/setup-python@v2
128               with:
129                 python-version: 3.5
130               if: matrix.ubuntu == 18
131
132             - uses: ./Nominatim/.github/actions/setup-postgresql
133               with:
134                   postgresql-version: ${{ matrix.postgresql }}
135                   postgis-version: ${{ matrix.postgis }}
136             - uses: ./Nominatim/.github/actions/build-nominatim
137
138             - name: Install extra dependencies for Ubuntu 18
139               run: |
140                 sudo apt-get install libicu-dev
141                 pip3 install python-dotenv psycopg2==2.7.7 jinja2==2.8 psutil==5.4.2 pyicu osmium
142               shell: bash
143               if: matrix.ubuntu == 18
144
145             - name: Clean installation
146               run: rm -rf Nominatim build
147               shell: bash
148
149             - name: Prepare import environment
150               run: |
151                   if [ ! -f monaco-latest.osm.pbf ]; then
152                       wget --no-verbose https://download.geofabrik.de/europe/monaco-latest.osm.pbf
153                   fi
154                   mkdir data-env
155                   cd data-env
156               shell: bash
157
158             - name: Import
159               run: nominatim import --osm-file ../monaco-latest.osm.pbf
160               shell: bash
161               working-directory: data-env
162
163             - name: Import special phrases
164               run: nominatim special-phrases --import-from-wiki
165               working-directory: data-env
166
167             - name: Check full import
168               run: nominatim admin --check-database
169               working-directory: data-env
170
171             - name: Warm up database
172               run: nominatim admin --warm
173               working-directory: data-env
174
175             - name: Run update
176               run: |
177                    nominatim replication --init
178                    nominatim replication --once
179               working-directory: data-env
180
181             - name: Run reverse-only import
182               run : nominatim import --osm-file ../monaco-latest.osm.pbf --reverse-only --no-updates
183               working-directory: data-env
184               env:
185                   NOMINATIM_DATABASE_DSN: pgsql:dbname=reverse
186
187             - name: Check reverse import
188               run: nominatim admin --check-database
189               working-directory: data-env