Skip to content

Commit 609e03d

Browse files
release mode
1 parent 1a1c96d commit 609e03d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ jobs:
100100
run: pytest
101101
env:
102102
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
103+
GEOENGINE_TEST_BUILD_TYPE: "release"
103104
- name: Examples
104105
run: |
105106
python -m pip install -e .[examples]
106107
python test_all_notebooks.py
107108
env:
108109
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
110+
GEOENGINE_TEST_BUILD_TYPE: "release"
109111

110112
# Checks the library using minimum version resolution
111113
# `uv` has this feature built-in, c.f. https://github.com/astral-sh/uv
@@ -198,6 +200,7 @@ jobs:
198200
pytest --cov=geoengine --cov-report=lcov
199201
env:
200202
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
203+
GEOENGINE_TEST_BUILD_TYPE: "release"
201204
- name: Upload coverage to Coveralls
202205
uses: coverallsapp/github-action@v2
203206
with:
@@ -209,3 +212,4 @@ jobs:
209212
python test_all_notebooks.py
210213
env:
211214
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
215+
GEOENGINE_TEST_BUILD_TYPE: "release"

tests/ge_test.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from collections.abc import Iterator
66
from contextlib import contextmanager
7+
from enum import Enum
78
from pathlib import Path
89
import random
910
import string
@@ -18,6 +19,7 @@
1819
import psycopg
1920

2021
TEST_CODE_PATH_VAR = 'GEOENGINE_TEST_CODE_PATH'
22+
TEST_BUILD_TYPE_VAR = 'GEOENGINE_TEST_BUILD_TYPE'
2123

2224
POSTGRES_HOST = 'localhost'
2325
POSTGRES_PORT = 5432
@@ -35,7 +37,12 @@ def GeoEngineTestInstance(port: Optional[int] = None) -> Iterator['GeoEngineProc
3537
if TEST_CODE_PATH_VAR not in os.environ:
3638
raise RuntimeError(f'Environment variable {TEST_CODE_PATH_VAR} not set')
3739

38-
geo_engine_binaries = GeoEngineBinaries(Path(os.environ[TEST_CODE_PATH_VAR]))
40+
if os.environ.get('GEOENGINE_TEST_BUILD_TYPE', 'debug').lower() == 'release':
41+
build_type = BuildType.RELEASE
42+
else:
43+
build_type = BuildType.DEBUG
44+
45+
geo_engine_binaries = GeoEngineBinaries(Path(os.environ[TEST_CODE_PATH_VAR]), build_type)
3946

4047
try:
4148
ge = GeoEngineProcess(
@@ -49,6 +56,12 @@ def GeoEngineTestInstance(port: Optional[int] = None) -> Iterator['GeoEngineProc
4956
ge._stop() # pylint: disable=protected-access
5057

5158

59+
class BuildType(Enum):
60+
'''Build type of the cargo build.'''
61+
DEBUG = 'debug'
62+
RELEASE = 'release'
63+
64+
5265
def get_open_port() -> int:
5366
'''Get an open port on the local machine.'''
5467
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
@@ -76,10 +89,11 @@ class GeoEngineBinaries:
7689
_lock = threading.Lock()
7790

7891
_code_path: Path
92+
_build_type: BuildType
7993
_server_binary_path: Path
8094
_cli_binary_path: Path
8195

82-
def __new__(cls, code_path: Path) -> 'GeoEngineBinaries':
96+
def __new__(cls, code_path: Path, build_type: BuildType) -> 'GeoEngineBinaries':
8397
'''Create Geo Engine binaries for testing.'''
8498

8599
if cls._instance is not None:
@@ -89,6 +103,7 @@ def __new__(cls, code_path: Path) -> 'GeoEngineBinaries':
89103
if cls._instance is None:
90104
cls._instance = super().__new__(cls)
91105
cls._instance._code_path = code_path
106+
cls._instance._build_type = build_type
92107

93108
cls._instance._build_geo_engine()
94109

@@ -102,21 +117,21 @@ def _build_geo_engine(self) -> None:
102117
if cargo_bin is None:
103118
raise RuntimeError('Cargo not found')
104119

105-
logging.info("Building Geo Engine binaries… this may take a while.")
120+
logging.info("Building Geo Engine binaries in %s mode… this may take a while.", self._build_type.value)
106121

107122
subprocess.run(
108123
[
109124
cargo_bin,
110125
'build',
111126
'--locked',
112127
'--bins',
113-
],
128+
] + (['--release'] if self._build_type == BuildType.RELEASE else []),
114129
check=True,
115130
cwd=self._code_path,
116131
)
117132

118133
self._server_binary_path = self._code_path / 'target/debug/geoengine-server'
119-
self._cli_binary_path = self._code_path / 'target/debug/geoengine-cli'
134+
self._cli_binary_path = self._code_path / 'target' / self._build_type.value / 'geoengine-cli'
120135

121136
if not self._server_binary_path.exists():
122137
raise RuntimeError(f'Server binary not found at {self._server_binary_path}')

0 commit comments

Comments
 (0)