v30.3-roots.1 · Commit 7: [PATCH 07/68] build: adapt Roots maintenance and assurance to Core 30.3
ci/test/test_release_version.py
Before: /dev/null · After: ci/test/test_release_version.py
File metadata
new file mode 100755 index 0000000000000000000000000000000000000000..b9b24440b82b5b350b0515399542d6c663dcb4fa
Download original patch · Release notes
Diff rows 1–85 of 85. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
ci/test/test_release_version.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright (c) 2026-present The Bitcoin Roots developers
|
|
3
|
+
# Distributed under the MIT software license, see the accompanying
|
|
4
|
+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import re
|
|
8
|
+
import subprocess
|
|
9
|
+
import unittest
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
ROOT = Path(__file__).resolve().parents[2]
|
|
13
|
+
BUILD_CONFIG = ROOT / "CMakeLists.txt"
|
|
14
|
+
ARCHIVE_TOOL = ROOT / "ci/release/archive.py"
|
|
15
|
+
RELEASE_WORKFLOW = ROOT / ".github/workflows/release.yml"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ReleaseVersionTest(unittest.TestCase):
|
|
19
|
+
def test_version_and_release_tag_name_agree(self):
|
|
20
|
+
build_config = BUILD_CONFIG.read_text(encoding="utf-8")
|
|
21
|
+
self.assertIn("set(CLIENT_VERSION_MAJOR 30)", build_config)
|
|
22
|
+
self.assertIn("set(CLIENT_VERSION_MINOR 3)", build_config)
|
|
23
|
+
self.assertIn('string(APPEND CLIENT_VERSION_STRING "-roots.1")', build_config)
|
|
24
|
+
result = subprocess.run(
|
|
25
|
+
["python3", ARCHIVE_TOOL, "root-name", "--tag", "v30.3-roots.1"],
|
|
26
|
+
capture_output=True, text=True, check=True,
|
|
27
|
+
)
|
|
28
|
+
self.assertEqual(result.stdout.strip(), "bitcoin-roots-30.3-roots.1")
|
|
29
|
+
|
|
30
|
+
def test_workflow_builds_tags_and_manual_dry_runs_from_the_tag(self):
|
|
31
|
+
workflow = RELEASE_WORKFLOW.read_text(encoding="utf-8")
|
|
32
|
+
self.assertIn("tags:", workflow)
|
|
33
|
+
self.assertIn("'v[0-9]*-roots.[0-9]*'", workflow)
|
|
34
|
+
self.assertIn("workflow_dispatch:", workflow)
|
|
35
|
+
self.assertNotIn("branches:", workflow)
|
|
36
|
+
self.assertIn("github.event_name == 'push' && github.ref_name || inputs.release_tag", workflow)
|
|
37
|
+
self.assertIn("ref: refs/tags/${{ env.RELEASE_TAG }}", workflow)
|
|
38
|
+
self.assertIn("if: github.event_name == 'push'", workflow)
|
|
39
|
+
self.assertIn('ci/release/validate-release-source.sh "$RELEASE_TAG"', workflow)
|
|
40
|
+
self.assertIn('refs/heads/roots/${core_version}:refs/remotes/origin/roots/${core_version}', workflow)
|
|
41
|
+
self.assertNotIn("origin main:refs/remotes/origin/main", workflow)
|
|
42
|
+
self.assertIn("environment: release", workflow)
|
|
43
|
+
|
|
44
|
+
def test_workflow_builds_complete_artifact_matrix_and_patch(self):
|
|
45
|
+
workflow = RELEASE_WORKFLOW.read_text(encoding="utf-8")
|
|
46
|
+
for artifact in [
|
|
47
|
+
"bitcoin-roots-linux-x86_64",
|
|
48
|
+
"bitcoin-roots-linux-aarch64",
|
|
49
|
+
"bitcoin-roots-darwin-x86_64",
|
|
50
|
+
"bitcoin-roots-darwin-arm64",
|
|
51
|
+
"bitcoin-roots-windows-x86_64",
|
|
52
|
+
]:
|
|
53
|
+
self.assertIn(artifact, workflow)
|
|
54
|
+
self.assertIn("EXPECTED_PACKAGE_COUNT: 5", workflow)
|
|
55
|
+
self.assertIn("ci/release/create-patch-series.sh", workflow)
|
|
56
|
+
self.assertIn("ci/release/prepare-release.sh", workflow)
|
|
57
|
+
self.assertIn("ci/release/sign-manifest.sh", workflow)
|
|
58
|
+
self.assertIn("SHA512SUMS", workflow)
|
|
59
|
+
self.assertIn("gh release upload", workflow)
|
|
60
|
+
self.assertIn("gh release create", workflow)
|
|
61
|
+
|
|
62
|
+
def test_workflow_references_only_present_local_release_files(self):
|
|
63
|
+
workflow = RELEASE_WORKFLOW.read_text(encoding="utf-8")
|
|
64
|
+
local_paths = re.findall(r"(?:ci|contrib)/[A-Za-z0-9_./-]+\.(?:asc|py|sh)", workflow)
|
|
65
|
+
for local_path in local_paths:
|
|
66
|
+
with self.subTest(local_path=local_path):
|
|
67
|
+
self.assertTrue((ROOT / local_path).is_file())
|
|
68
|
+
|
|
69
|
+
def test_workflow_actions_are_intentionally_bounded(self):
|
|
70
|
+
workflow = RELEASE_WORKFLOW.read_text(encoding="utf-8")
|
|
71
|
+
actions = set(re.findall(r"uses: (\S+)", workflow))
|
|
72
|
+
self.assertEqual(
|
|
73
|
+
actions,
|
|
74
|
+
{
|
|
75
|
+
"actions/checkout@v6",
|
|
76
|
+
"actions/download-artifact@v5",
|
|
77
|
+
"actions/upload-artifact@v4",
|
|
78
|
+
"./.github/actions/configure-docker",
|
|
79
|
+
"./.github/actions/configure-environment",
|
|
80
|
+
},
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
unittest.main()
|