From b6e6663716544152319ce1d09dbc0b4a7aa996c7 Mon Sep 17 00:00:00 2001 From: robfrank Date: Fri, 23 Oct 2026 01:19:18 +0200 Subject: [PATCH] feat(#7): release and RC jar-name tests, and RC builds pass build.sh's wheel check extract_version is tested end to end from release and RC engine jar names (module and CLI, pep440 and docker). Running build.sh's local-jars wheel check for the same versions found it mapped 26.11.1-RC1 to 26.11.1.RC1, which no RC wheel (26.11.1rc1) matches: it now follows maven_to_pep440's rules. tests/test_build_wheel_check.py runs that heredoc unchanged. Co-Authored-By: Claude Opus 5.5 --- scripts/build.sh | 5 ++- tests/test_build_wheel_check.py | 58 +++++++++++++++++++++++++++++++++ tests/test_extract_version.py | 43 ++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 tests/test_build_wheel_check.py diff --git a/scripts/build.sh b/scripts/build.sh index 4ac30bf..284b3f3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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): diff --git a/tests/test_build_wheel_check.py b/tests/test_build_wheel_check.py new file mode 100644 index 0000000..3ab0b27 --- /dev/null +++ b/tests/test_build_wheel_check.py @@ -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 diff --git a/tests/test_extract_version.py b/tests/test_extract_version.py index 2dbd8e3..42f1c1f 100644 --- a/tests/test_extract_version.py +++ b/tests/test_extract_version.py @@ -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