]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
c0d0dcea6f66c30363bc1fd8a1b52262f5156c00
[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
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-coverage
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: |
65                   python3-coverage run -m pytest ./test/python
66                   python3-coverage xml -o ./coverage-pytest.xml
67
68               working-directory: Nominatim
69
70             - name: BDD tests
71               run: |
72                   python3-coverage run -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
73                   python3-coverage xml -o ../../coverage-bdd.xml
74
75               working-directory: Nominatim/test/bdd
76
77             - name: Upload coverage to Codecov
78               uses: codecov/codecov-action@v1
79               with:
80                 files: ./Nominatim/coverage*.xml
81                 directory: ./
82                 flags: unittests
83                 name: codecov-umbrella
84                 fail_ci_if_error: true
85                 path_to_write_report: ./coverage/codecov_report.txt
86                 verbose: true
87
88     import:
89         runs-on: ubuntu-20.04
90
91         steps:
92             - uses: actions/checkout@v2
93               with:
94                   submodules: true
95                   path: Nominatim
96
97             - name: Get Date
98               id: get-date
99               run: |
100                   echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
101               shell: bash
102
103             - uses: actions/cache@v2
104               with:
105                   path: |
106                      country_grid.sql.gz
107                   key: nominatim-country-data-${{ steps.get-date.outputs.date }}
108
109             - uses: actions/cache@v2
110               with:
111                   path: |
112                      monaco-latest.osm.pbf
113                   key: nominatim-test-data-${{ steps.get-date.outputs.date }}
114
115             - uses: ./Nominatim/.github/actions/setup-postgresql
116               with:
117                   postgresql-version: 13
118                   postgis-version: 3
119             - uses: ./Nominatim/.github/actions/build-nominatim
120
121             - name: Clean installation
122               run: rm -rf Nominatim build
123               shell: bash
124
125             - name: Prepare import environment
126               run: |
127                   if [ ! -f monaco-latest.osm.pbf ]; then
128                       wget --no-verbose https://download.geofabrik.de/europe/monaco-latest.osm.pbf
129                   fi
130                   mkdir data-env
131                   cd data-env
132               shell: bash
133
134             - name: Import
135               run: nominatim import --osm-file ../monaco-latest.osm.pbf
136               shell: bash
137               working-directory: data-env
138
139             - name: Import special phrases
140               run: nominatim special-phrases --import-from-wiki
141               working-directory: data-env
142
143             - name: Check import
144               run: nominatim admin --check-database
145               working-directory: data-env
146
147             - name: Run update
148               run: |
149                    nominatim replication --init
150                    nominatim replication --once
151               working-directory: data-env
152
153             - name: Run reverse-only import
154               run : nominatim import --osm-file ../monaco-latest.osm.pbf --reverse-only
155               working-directory: data-env
156               env:
157                   NOMINATIM_DATABASE_DSN: pgsql:dbname=reverse