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