Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ ARCADEDB_VERSION = os.environ["ARCADEDB_VERSION"]
# (NEW_WHEELS), else the newest wheel of the version this run asked for
# (BUILD_VERSION when set, as the wheel's own version follows it), and assert
# the version, so picking the wrong file fails loudly.
_want = (os.environ.get("BUILD_VERSION") or ARCADEDB_VERSION).replace("-SNAPSHOT", "").replace("-", ".")
# The wheel version's base, by extract_version.py's maven_to_pep440 rules:
# 26.11.1-SNAPSHOT -> 26.11.1 (.devN follows), 26.11.1-RC1 -> 26.11.1rc1 (#7).
_want = (os.environ.get("BUILD_VERSION") or ARCADEDB_VERSION).replace("-SNAPSHOT", "")
_want = _want.replace("-RC", "rc").replace("-", "")


def _is_wanted(wheel_path):
Expand Down
58 changes: 58 additions & 0 deletions tests/test_build_wheel_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""build.sh's local-jars check accepts the wheel each engine version builds.

After a build from a local jars directory, build.sh runs an inline Python check
(the ``python3 - << 'PY'`` heredoc) that finds this build's wheel in dist/ by
version and compares the integration jar inside it with the local one. It
turned the engine version into the wheel version with its own string rules,
which mapped ``26.11.1-RC1`` to ``26.11.1.RC1``: no RC wheel (``26.11.1rc1``)
ever matched, and an RC build failed with "no arcadedb_embedded-... wheel in
dist/" (#7). This runs that heredoc, unchanged, for each kind of version.
"""

from __future__ import annotations

import os
import subprocess # nosec B404 - test-controlled child process
import sys
import zipfile
from pathlib import Path

import pytest

BUILD_SH = Path(__file__).resolve().parents[1] / "scripts" / "build.sh"


def _wheel_check_source() -> str:
text = BUILD_SH.read_text(encoding="utf-8")
start = text.index("python3 - << 'PY'\n") + len("python3 - << 'PY'\n")
end = text.index("\nPY\n", start)
return text[start:end] + "\n"


@pytest.mark.parametrize(
"engine, wheel_version",
[
("26.11.1-SNAPSHOT", "26.11.1.dev0"),
("26.10.2", "26.10.2"),
("26.11.1-RC1", "26.11.1rc1"),
],
)
def test_wheel_check_finds_this_builds_wheel(tmp_path, engine, wheel_version):
jar_name = f"arcadedb-integration-{engine}.jar"
(tmp_path / "local-jars" / "lib").mkdir(parents=True)
(tmp_path / "local-jars" / "lib" / jar_name).write_bytes(b"integration")
(tmp_path / "dist").mkdir()
wheel = tmp_path / "dist" / f"arcadedb_embedded-{wheel_version}-py3-none-any.whl"
with zipfile.ZipFile(wheel, "w") as zf:
zf.writestr(f"arcadedb_embedded/jars/{jar_name}", b"integration")

env = dict(os.environ, ARCADEDB_VERSION=engine, BUILD_VERSION="", NEW_WHEELS="")
out = subprocess.run( # nosec B603 - fixed argv, no shell
[sys.executable, "-c", _wheel_check_source()],
cwd=tmp_path,
env=env,
capture_output=True,
text=True,
)
assert out.returncode == 0, out.stderr
assert "matches local-jars/lib" in out.stdout
43 changes: 43 additions & 0 deletions tests/test_extract_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,46 @@ def test_cli_prints_docker_format(tmp_path):
check=True,
)
assert out.stdout.strip() == "26.11.1-SNAPSHOT"


# Release and release-candidate jars, end to end from the file name: the
# package version (write_version.py writes it) and the --format=docker string,
# which download-jars passes on as ARCADEDB_TAG and build.sh's local-jars check
# reads (#7). None of these touches the .devN tracker, which only SNAPSHOT
# versions use. --python-patch is for manual runs: no build path passes it.
JAR_NAME_CASES = [
# jar version, --python-patch, pep440, docker
("26.10.2", 0, "26.10.2", "26.10.2"),
("26.10.2", 1, "26.10.2.post1", "26.10.2"),
("26.11.1-RC1", 0, "26.11.1rc1", "26.11.1-RC1"),
("26.11.1-RC2", 1, "26.11.1rc2.post1", "26.11.1-RC2"),
]


@pytest.mark.parametrize("raw, patch, pep440, docker", JAR_NAME_CASES)
def test_release_jar_name_through_extract_version(tmp_path, raw, patch, pep440, docker):
d = _jars(
tmp_path,
f"arcadedb-engine-{raw}.jar",
f"arcadedb-server-{raw}.jar",
"jline-3.30.0.jar",
)
assert mod.extract_version(d, patch_version=patch) == pep440
assert mod.extract_version(d, fmt="docker") == docker


@pytest.mark.parametrize("raw, patch, pep440, docker", JAR_NAME_CASES)
def test_release_jar_name_through_the_cli(tmp_path, raw, patch, pep440, docker):
d = _jars(tmp_path, f"arcadedb-engine-{raw}.jar")

def cli(*args):
return subprocess.run( # nosec B603 - fixed argv, no shell
[sys.executable, str(SCRIPT_PATH), str(d), *args],
capture_output=True,
text=True,
check=True,
).stdout.strip()

assert cli("--format=pep440", f"--python-patch={patch}") == pep440
# --python-patch only shapes the PEP 440 version, never the image tag
assert cli("--format=docker", f"--python-patch={patch}") == docker
Loading