v29.4-roots.4 · Commit 37: [PATCH 37/37] fix(release): honor the configured Roots version tag
ci/test/test_release_version.py
Before: ci/test/test_release_version.py · After: ci/test/test_release_version.py
File metadata
index 3f9c10981755cf33ad4955842730f9d3ceefa1b8..1804259092a36e423742014382de2d1065425597 100755
Download original patch · Release notes
Diff rows 1–58 of 58. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
ci/test/test_release_version.py
CHANGED
|
@@ -6,6 +6,7 @@
|
|
| 6 |
from pathlib import Path
|
| 7 |
import re
|
| 8 |
import subprocess
|
|
|
|
| 9 |
import unittest
|
| 10 |
|
| 11 |
|
|
@@ -16,6 +17,51 @@ RELEASE_WORKFLOW = ROOT / ".github/workflows/release.yml"
|
|
| 16 |
|
| 17 |
|
| 18 |
class ReleaseVersionTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def test_l7_version_and_release_tag_name_agree(self):
|
| 20 |
build_config = BUILD_CONFIG.read_text(encoding="utf-8")
|
| 21 |
self.assertIn("set(CLIENT_VERSION_MAJOR 29)", build_config)
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
import re
|
| 8 |
import subprocess
|
| 9 |
+
import tempfile
|
| 10 |
import unittest
|
| 11 |
|
| 12 |
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
class ReleaseVersionTest(unittest.TestCase):
|
| 20 |
+
def configure_release_version(self, tag=None):
|
| 21 |
+
build_config = BUILD_CONFIG.read_text(encoding="utf-8")
|
| 22 |
+
version_block = build_config.split('set(CLIENT_VERSION_STRING ', 1)[1]
|
| 23 |
+
version_block = 'set(CLIENT_VERSION_STRING ' + version_block.split('#=============================', 1)[0]
|
| 24 |
+
with tempfile.TemporaryDirectory(prefix="roots-release-version-") as directory:
|
| 25 |
+
source = Path(directory)
|
| 26 |
+
metadata = "\n".join(
|
| 27 |
+
re.search(rf"set\({name} [^)]+\)", build_config).group(0)
|
| 28 |
+
for name in ("CLIENT_VERSION_MAJOR", "CLIENT_VERSION_MINOR", "CLIENT_VERSION_RC")
|
| 29 |
+
)
|
| 30 |
+
(source / "CMakeLists.txt").write_text(
|
| 31 |
+
"cmake_minimum_required(VERSION 3.22)\n"
|
| 32 |
+
"project(ReleaseVersionTest LANGUAGES NONE)\n"
|
| 33 |
+
+ metadata + "\n" + version_block
|
| 34 |
+
+ f'configure_file("{ROOT / "cmake/bitcoin-build-config.h.in"}" '
|
| 35 |
+
'"${CMAKE_BINARY_DIR}/bitcoin-build-config.h" @ONLY)\n',
|
| 36 |
+
encoding="utf-8",
|
| 37 |
+
)
|
| 38 |
+
command = ["cmake", "-S", str(source), "-B", str(source / "build")]
|
| 39 |
+
if tag is not None:
|
| 40 |
+
command.append(f"-DCLIENT_VERSION_TAG={tag}")
|
| 41 |
+
result = subprocess.run(command, capture_output=True, text=True)
|
| 42 |
+
header = source / "build/bitcoin-build-config.h"
|
| 43 |
+
return result, header.read_text(encoding="utf-8") if header.exists() else ""
|
| 44 |
+
|
| 45 |
+
def test_release_tag_sets_compiled_version_without_git_metadata(self):
|
| 46 |
+
for tag in ("v29.4-roots.2", "v29.4-roots.4"):
|
| 47 |
+
with self.subTest(tag=tag):
|
| 48 |
+
result, header = self.configure_release_version(tag)
|
| 49 |
+
self.assertEqual(result.returncode, 0, result.stderr)
|
| 50 |
+
self.assertIn(f'#define CLIENT_VERSION_STRING "{tag[1:]}"', header)
|
| 51 |
+
self.assertNotIn("Manually-specified variables were not used", result.stderr)
|
| 52 |
+
|
| 53 |
+
def test_release_tag_rejects_wrong_base_and_invalid_roots_version(self):
|
| 54 |
+
for tag in ("v30.0-roots.4", "v29x4-roots.4", "v29.4-roots.0", "v29.4-knots.4", ""):
|
| 55 |
+
with self.subTest(tag=tag):
|
| 56 |
+
result, _ = self.configure_release_version(tag)
|
| 57 |
+
self.assertNotEqual(result.returncode, 0)
|
| 58 |
+
self.assertIn("CLIENT_VERSION_TAG must be a Roots release tag", result.stderr)
|
| 59 |
+
|
| 60 |
+
def test_untagged_build_keeps_default_roots_version(self):
|
| 61 |
+
result, header = self.configure_release_version()
|
| 62 |
+
self.assertEqual(result.returncode, 0, result.stderr)
|
| 63 |
+
self.assertIn('#define CLIENT_VERSION_STRING "29.4-roots.1"', header)
|
| 64 |
+
|
| 65 |
def test_l7_version_and_release_tag_name_agree(self):
|
| 66 |
build_config = BUILD_CONFIG.read_text(encoding="utf-8")
|
| 67 |
self.assertIn("set(CLIENT_VERSION_MAJOR 29)", build_config)
|