Skip to content

Commit dea0391

Browse files
ci : cascade the postgis
1 parent 3b66648 commit dea0391

5 files changed

Lines changed: 18 additions & 62 deletions

File tree

.github/workflows/Unit-Test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on:
44
paths-ignore:
55
- "infra/**"
66
branches:
7-
- master
7+
- stage
88
- develop
99
pull_request:
1010
branches:
11-
- master
11+
- stage
1212
- develop
1313

1414
jobs:
@@ -60,7 +60,7 @@ jobs:
6060
run: |
6161
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS postgis;"
6262
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3;"
63-
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3_postgis;"
63+
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3_postgis CASCADE;"
6464
6565
- name: Install osm2pgsql for data loading
6666
run: sudo apt-get install -y osm2pgsql

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on:
44
paths-ignore:
55
- "infra/**"
66
branches:
7-
- master
7+
- stage
88
- develop
99
pull_request:
1010
branches:
11-
- master
11+
- stage
1212
- develop
1313

1414
jobs:
@@ -50,7 +50,7 @@ jobs:
5050
- name: Create H3 extensions
5151
run: |
5252
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3;"
53-
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3_postgis;"
53+
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3_postgis CASCADE;"
5454
5555
- name: Install python requirements for load
5656
run: uv sync --group backend

pyproject.toml_backup

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/backend/importer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ def parse_arguments():
9898

9999

100100
def is_local_file(url):
101+
"""Check if URL points to a local file."""
101102
url_parsed = urlparse(url)
102103
return url_parsed.scheme in ("file", "") and exists(url_parsed.path)
103104

104105

105106
def run_command(cmd, timeout=None):
107+
"""Execute command and raise error on failure."""
106108
try:
107109
subprocess.check_output(cmd, env=os.environ, timeout=timeout)
108110
except subprocess.CalledProcessError as ex:
@@ -111,18 +113,21 @@ def run_command(cmd, timeout=None):
111113

112114

113115
def run_command_no_fail(cmd, timeout=None):
116+
"""Execute command and ignore failures."""
114117
try:
115118
subprocess.check_output(cmd, env=os.environ, timeout=timeout)
116119
except subprocess.CalledProcessError as ex:
117120
print(ex.output)
118121

119122

120123
def run_parallel_commands(cmds):
124+
"""Execute multiple commands in parallel."""
121125
with Pool(processes=len(cmds)) as pool:
122126
pool.map(run_command, cmds)
123127

124128

125129
def download_file(download_dir, source_path):
130+
"""Download file from URL to directory."""
126131
filename = os.path.basename(source_path)
127132
target_path = os.path.join(download_dir, filename)
128133

@@ -142,11 +147,13 @@ def download_file(download_dir, source_path):
142147

143148

144149
def get_resource_path(relative_path):
150+
"""Get absolute path to resource file."""
145151
base_dir = os.path.dirname(__file__)
146152
return os.path.join(base_dir, relative_path)
147153

148154

149155
def run_psql_query(query, dbname="postgres", host=None, port=None, user=None):
156+
"""Execute PostgreSQL query using psql."""
150157
cmd = ["psql", "-h", host, "-p", port, "-U", user, "-d", dbname, "-tAc", query]
151158
try:
152159
result = subprocess.check_output(cmd, env=os.environ, stderr=subprocess.DEVNULL)
@@ -156,6 +163,7 @@ def run_psql_query(query, dbname="postgres", host=None, port=None, user=None):
156163

157164

158165
def create_database(dbname, host, port, user):
166+
"""Create PostgreSQL database if it doesn't exist."""
159167
cmd = [
160168
"psql",
161169
"-h",
@@ -173,6 +181,7 @@ def create_database(dbname, host, port, user):
173181

174182

175183
def enable_extension(extension, dbname, host, port, user, cascade=False):
184+
"""Enable PostgreSQL extension in database."""
176185
cascade_sql = " CASCADE" if cascade else ""
177186
cmd = [
178187
"psql",
@@ -191,6 +200,7 @@ def enable_extension(extension, dbname, host, port, user, cascade=False):
191200

192201

193202
def setup_database_prerequisites(dbname, host, port, user):
203+
"""Set up database with required extensions."""
194204
if (
195205
run_psql_query(
196206
f"SELECT 1 FROM pg_database WHERE datname='{dbname}'",

src/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import logging
2323
import os
2424
from configparser import ConfigParser
25+
2526
from distutils.util import strtobool
2627

2728
# Third party imports
@@ -30,6 +31,7 @@
3031

3132

3233
def get_bool_env_var(key, default=False):
34+
"""Get boolean environment variable value."""
3335
value = os.environ.get(key, default)
3436
return bool(strtobool(str(value)))
3537

0 commit comments

Comments
 (0)