]> git.openstreetmap.org Git - nominatim.git/blob - .github/workflows/ci-tests.yml
enable pytest testing in CI
[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
23             - name: Setup PHP
24               uses: shivammathur/setup-php@v2
25               with:
26                   php-version: '7.4'
27                   tools: phpunit, phpcs
28
29             - name: Get Date
30               id: get-date
31               run: |
32                   echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
33               shell: bash
34
35             - uses: actions/cache@v2
36               with:
37                   path: |
38                      {{ github.workspace }}/data/country_osm_grid.sql.gz
39                      {{ github.workspace }}/monaco-latest.osm.pbf
40                   key: nominatim-data-${{ steps.get-date.outputs.date }}
41
42             - uses: ./.github/actions/setup-postgresql
43               with:
44                   postgresql-version: ${{ matrix.postgresql }}
45                   postgis-version: ${{ matrix.postgis }}
46             - uses: ./.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
50
51             - name: PHP linting
52               run: phpcs --report-width=120 .
53
54             - name: Python linting
55               run: pylint nominatim
56
57             - name: PHP unit tests
58               run: phpunit ./
59               working-directory: test/php
60
61             - name: Python unit tests
62               run: pytest test/python
63
64             - name: BDD tests
65               run: behave -DREMOVE_TEMPLATE=1 --format=progress3
66               working-directory: test/bdd
67
68     import:
69         runs-on: ubuntu-20.04
70
71         steps:
72             - uses: actions/checkout@v2
73               with:
74                   submodules: true
75
76             - name: Get Date
77               id: get-date
78               run: |
79                   echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
80               shell: bash
81
82             - uses: actions/cache@v2
83               with:
84                   path: |
85                      {{ github.workspace }}/data/country_osm_grid.sql.gz
86                      {{ github.workspace }}/monaco-latest.osm.pbf
87                   key: nominatim-data-${{ steps.get-date.outputs.date }}
88
89             - uses: ./.github/actions/setup-postgresql
90               with:
91                   postgresql-version: 13
92                   postgis-version: 3
93             - uses: ./.github/actions/build-nominatim
94
95             - name: Create configuration
96               run: |
97                    echo "NOMINATIM_PYOSMIUM_BINARY=/usr/lib/python3-pyosmium/pyosmium-get-changes" >> .env
98               working-directory: build
99
100             - name: Download import data
101               run: |
102                   if [ ! -f monaco-latest.osm.pbf ]; then
103                       wget --no-verbose https://download.geofabrik.de/europe/monaco-latest.osm.pbf
104                   fi
105               shell: bash
106
107             - name: Import
108               run: ./nominatim import --osm-file ../monaco-latest.osm.pbf
109               working-directory: build
110
111             - name: Import special phrases
112               run: ./nominatim special-phrases --from-wiki | psql -d nominatim
113               working-directory: build
114
115             - name: Check import
116               run: ./nominatim check-database
117               working-directory: build
118
119             - name: Run update
120               run: |
121                    ./nominatim replication --init
122                    ./nominatim replication --once
123               working-directory: build
124
125             - name: Run reverse-only import
126               run : |
127                   dropdb nominatim
128                   php ./nominatim import --osm-file ../monaco-latest.osm.pbf --reverse-only
129               working-directory: build