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