mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 13:24:07 +00:00
Merge pull request #2294 from lonvia/update-actions
CI: add import test against Python 3.5 and fix discovered issues
This commit is contained in:
2
.github/actions/build-nominatim/action.yml
vendored
2
.github/actions/build-nominatim/action.yml
vendored
@@ -6,7 +6,7 @@ runs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -y -qq libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev libicu-dev python3-psycopg2 python3-pyosmium python3-dotenv python3-psutil python3-jinja2 python3-icu python3-argparse-manpage
|
sudo apt-get install -y -qq libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev libicu-dev python3-psycopg2 python3-pyosmium python3-dotenv python3-psutil python3-jinja2 python3-icu
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Download dependencies
|
- name: Download dependencies
|
||||||
|
|||||||
29
.github/workflows/ci-tests.yml
vendored
29
.github/workflows/ci-tests.yml
vendored
@@ -82,7 +82,18 @@ jobs:
|
|||||||
verbose: true
|
verbose: true
|
||||||
|
|
||||||
import:
|
import:
|
||||||
runs-on: ubuntu-20.04
|
strategy:
|
||||||
|
matrix:
|
||||||
|
ubuntu: [18, 20]
|
||||||
|
include:
|
||||||
|
- ubuntu: 18
|
||||||
|
postgresql: 9.5
|
||||||
|
postgis: 2.5
|
||||||
|
- ubuntu: 20
|
||||||
|
postgresql: 13
|
||||||
|
postgis: 3
|
||||||
|
|
||||||
|
runs-on: ubuntu-${{ matrix.ubuntu }}.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -108,12 +119,24 @@ jobs:
|
|||||||
monaco-latest.osm.pbf
|
monaco-latest.osm.pbf
|
||||||
key: nominatim-test-data-${{ steps.get-date.outputs.date }}
|
key: nominatim-test-data-${{ steps.get-date.outputs.date }}
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.5
|
||||||
|
if: matrix.ubuntu == 18
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||||
with:
|
with:
|
||||||
postgresql-version: 13
|
postgresql-version: ${{ matrix.postgresql }}
|
||||||
postgis-version: 3
|
postgis-version: ${{ matrix.postgis }}
|
||||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||||
|
|
||||||
|
- name: Install extra dependencies for Ubuntu 18
|
||||||
|
run: |
|
||||||
|
sudo apt-get install libicu-dev
|
||||||
|
pip3 install python-dotenv psycopg2==2.7.7 jinja2==2.8 psutil==5.4.2 pyicu osmium
|
||||||
|
shell: bash
|
||||||
|
if: matrix.ubuntu == 18
|
||||||
|
|
||||||
- name: Clean installation
|
- name: Clean installation
|
||||||
run: rm -rf Nominatim build
|
run: rm -rf Nominatim build
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Configuration:
|
|||||||
self.project_dir = project_dir
|
self.project_dir = project_dir
|
||||||
self.config_dir = config_dir
|
self.config_dir = config_dir
|
||||||
self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
|
self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
|
||||||
if project_dir is not None:
|
if project_dir is not None and (project_dir / '.env').is_file():
|
||||||
self._config.update(dotenv_values(str((project_dir / '.env').resolve())))
|
self._config.update(dotenv_values(str((project_dir / '.env').resolve())))
|
||||||
|
|
||||||
# Add defaults for variables that are left empty to set the default.
|
# Add defaults for variables that are left empty to set the default.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from psycopg2.extras import wait_select
|
|||||||
try:
|
try:
|
||||||
import psycopg2.errors # pylint: disable=no-name-in-module,import-error
|
import psycopg2.errors # pylint: disable=no-name-in-module,import-error
|
||||||
__has_psycopg2_errors__ = True
|
__has_psycopg2_errors__ = True
|
||||||
except ModuleNotFoundError:
|
except ImportError:
|
||||||
__has_psycopg2_errors__ = False
|
__has_psycopg2_errors__ = False
|
||||||
|
|
||||||
LOG = logging.getLogger()
|
LOG = logging.getLogger()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from nominatim.tools.exec_utils import get_url
|
|||||||
from nominatim.errors import UsageError
|
from nominatim.errors import UsageError
|
||||||
|
|
||||||
LOG = logging.getLogger()
|
LOG = logging.getLogger()
|
||||||
|
ISODATE_FORMAT = '%Y-%m-%dT%H:%M:%S'
|
||||||
|
|
||||||
def compute_database_date(conn):
|
def compute_database_date(conn):
|
||||||
""" Determine the date of the database from the newest object in the
|
""" Determine the date of the database from the newest object in the
|
||||||
@@ -34,9 +35,9 @@ def compute_database_date(conn):
|
|||||||
"URL used: %s", node_url)
|
"URL used: %s", node_url)
|
||||||
raise UsageError("Bad API data.")
|
raise UsageError("Bad API data.")
|
||||||
|
|
||||||
LOG.debug("Found timestamp %s", match[1])
|
LOG.debug("Found timestamp %s", match.group(1))
|
||||||
|
|
||||||
return dt.datetime.fromisoformat(match[1]).replace(tzinfo=dt.timezone.utc)
|
return dt.datetime.strptime(match.group(1), ISODATE_FORMAT).replace(tzinfo=dt.timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
def set_status(conn, date, seq=None, indexed=True):
|
def set_status(conn, date, seq=None, indexed=True):
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ def _get_indexes(conn):
|
|||||||
'idx_placex_parent_place_id',
|
'idx_placex_parent_place_id',
|
||||||
'idx_placex_geometry_reverse_lookuppolygon',
|
'idx_placex_geometry_reverse_lookuppolygon',
|
||||||
'idx_placex_geometry_placenode',
|
'idx_placex_geometry_placenode',
|
||||||
'idx_placex_housenumber',
|
|
||||||
'idx_osmline_parent_place_id',
|
'idx_osmline_parent_place_id',
|
||||||
'idx_osmline_parent_osm_id',
|
'idx_osmline_parent_osm_id',
|
||||||
'idx_postcode_id',
|
'idx_postcode_id',
|
||||||
@@ -100,6 +99,9 @@ def _get_indexes(conn):
|
|||||||
'idx_location_area_country_place_id',
|
'idx_location_area_country_place_id',
|
||||||
'idx_place_osm_unique'
|
'idx_place_osm_unique'
|
||||||
))
|
))
|
||||||
|
if conn.server_version_tuple() >= (11, 0, 0):
|
||||||
|
indexes.extend(('idx_placex_housenumber',
|
||||||
|
'idx_osmline_parent_osm_id_with_hnr'))
|
||||||
|
|
||||||
return indexes
|
return indexes
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ def run_osm2pgsql(options):
|
|||||||
""" Run osm2pgsql with the given options.
|
""" Run osm2pgsql with the given options.
|
||||||
"""
|
"""
|
||||||
env = get_pg_env(options['dsn'])
|
env = get_pg_env(options['dsn'])
|
||||||
cmd = [options['osm2pgsql'],
|
cmd = [str(options['osm2pgsql']),
|
||||||
'--hstore', '--latlon', '--slim',
|
'--hstore', '--latlon', '--slim',
|
||||||
'--with-forward-dependencies', 'false',
|
'--with-forward-dependencies', 'false',
|
||||||
'--log-progress', 'true',
|
'--log-progress', 'true',
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from nominatim.errors import UsageError
|
|||||||
try:
|
try:
|
||||||
from osmium.replication.server import ReplicationServer
|
from osmium.replication.server import ReplicationServer
|
||||||
from osmium import WriteHandler
|
from osmium import WriteHandler
|
||||||
except ModuleNotFoundError as exc:
|
except ImportError as exc:
|
||||||
logging.getLogger().fatal("pyosmium not installed. Replication functions not available.\n"
|
logging.getLogger().fatal("pyosmium not installed. Replication functions not available.\n"
|
||||||
"To install pyosmium via pip: pip3 install osmium")
|
"To install pyosmium via pip: pip3 install osmium")
|
||||||
raise UsageError("replication tools not available") from exc
|
raise UsageError("replication tools not available") from exc
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class SpecialPhrasesImporter():
|
|||||||
if self.config.PHRASE_CONFIG:
|
if self.config.PHRASE_CONFIG:
|
||||||
settings_path = self._convert_php_settings_if_needed(self.config.PHRASE_CONFIG)
|
settings_path = self._convert_php_settings_if_needed(self.config.PHRASE_CONFIG)
|
||||||
|
|
||||||
with open(settings_path, "r") as json_settings:
|
with settings_path.open("r") as json_settings:
|
||||||
settings = json.load(json_settings)
|
settings = json.load(json_settings)
|
||||||
return settings['blackList'], settings['whiteList']
|
return settings['blackList'], settings['whiteList']
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ OSM_NODE_DATA = """\
|
|||||||
</osm>
|
</osm>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def iso_date(date):
|
||||||
|
return dt.datetime.strptime(date, nominatim.db.status.ISODATE_FORMAT)\
|
||||||
|
.replace(tzinfo=dt.timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
def test_compute_database_date_valid(monkeypatch, status_table, place_row, temp_db_conn):
|
def test_compute_database_date_valid(monkeypatch, status_table, place_row, temp_db_conn):
|
||||||
place_row(osm_type='N', osm_id=45673)
|
place_row(osm_type='N', osm_id=45673)
|
||||||
|
|
||||||
@@ -32,7 +37,7 @@ def test_compute_database_date_valid(monkeypatch, status_table, place_row, temp_
|
|||||||
date = nominatim.db.status.compute_database_date(temp_db_conn)
|
date = nominatim.db.status.compute_database_date(temp_db_conn)
|
||||||
|
|
||||||
assert requested_url == ['https://www.openstreetmap.org/api/0.6/node/45673/1']
|
assert requested_url == ['https://www.openstreetmap.org/api/0.6/node/45673/1']
|
||||||
assert date == dt.datetime.fromisoformat('2006-01-27T22:09:10').replace(tzinfo=dt.timezone.utc)
|
assert date == iso_date('2006-01-27T22:09:10')
|
||||||
|
|
||||||
|
|
||||||
def test_compute_database_broken_api(monkeypatch, status_table, place_row, temp_db_conn):
|
def test_compute_database_broken_api(monkeypatch, status_table, place_row, temp_db_conn):
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ def test_init_replication_success(monkeypatch, status_table, place_row, temp_db_
|
|||||||
|
|
||||||
temp_db_cursor.execute("SELECT * FROM import_status")
|
temp_db_cursor.execute("SELECT * FROM import_status")
|
||||||
|
|
||||||
expected_date = dt.datetime.fromisoformat('2006-01-27T19:09:10').replace(tzinfo=dt.timezone.utc)
|
expected_date = dt.datetime.strptime('2006-01-27T19:09:10', status.ISODATE_FORMAT)\
|
||||||
|
.replace(tzinfo=dt.timezone.utc)
|
||||||
assert temp_db_cursor.rowcount == 1
|
assert temp_db_cursor.rowcount == 1
|
||||||
assert temp_db_cursor.fetchone() == [expected_date, 234, True]
|
assert temp_db_cursor.fetchone() == [expected_date, 234, True]
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
python3-pip python3-setuptools python3-devel \
|
python3-pip python3-setuptools python3-devel \
|
||||||
expat-devel zlib-devel libicu-dev
|
expat-devel zlib-devel libicu-dev
|
||||||
|
|
||||||
pip3 install --user psycopg2 python-dotenv psutil Jinja2 PyICU argparse-manpage
|
pip3 install --user psycopg2 python-dotenv psutil Jinja2 PyICU
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
python3-pip python3-setuptools python3-devel \
|
python3-pip python3-setuptools python3-devel \
|
||||||
expat-devel zlib-devel libicu-dev
|
expat-devel zlib-devel libicu-dev
|
||||||
|
|
||||||
pip3 install --user psycopg2 python-dotenv psutil Jinja2 PyICU argparse-manpage
|
pip3 install --user psycopg2 python-dotenv psutil Jinja2 PyICU
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
|
|||||||
postgresql-server-dev-10 postgresql-10-postgis-2.4 \
|
postgresql-server-dev-10 postgresql-10-postgis-2.4 \
|
||||||
postgresql-contrib-10 postgresql-10-postgis-scripts \
|
postgresql-contrib-10 postgresql-10-postgis-scripts \
|
||||||
php php-pgsql php-intl libicu-dev python3-pip \
|
php php-pgsql php-intl libicu-dev python3-pip \
|
||||||
python3-psycopg2 python3-psutil python3-jinja2 python3-icu git \
|
python3-psycopg2 python3-psutil python3-jinja2 python3-icu git
|
||||||
python3-argparse-manpage
|
|
||||||
|
|
||||||
# The python-dotenv package that comes with Ubuntu 18.04 is too old, so
|
# The python-dotenv package that comes with Ubuntu 18.04 is too old, so
|
||||||
# install the latest version from pip:
|
# install the latest version from pip:
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
|
|||||||
postgresql-server-dev-12 postgresql-12-postgis-3 \
|
postgresql-server-dev-12 postgresql-12-postgis-3 \
|
||||||
postgresql-contrib-12 postgresql-12-postgis-3-scripts \
|
postgresql-contrib-12 postgresql-12-postgis-3-scripts \
|
||||||
php php-pgsql php-intl libicu-dev python3-dotenv \
|
php php-pgsql php-intl libicu-dev python3-dotenv \
|
||||||
python3-psycopg2 python3-psutil python3-jinja2 python3-icu git \
|
python3-psycopg2 python3-psutil python3-jinja2 python3-icu git
|
||||||
python3-argparse-manpage
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# System Configuration
|
# System Configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user