v30.3-roots.1 · Commit 59: [PATCH 59/68] ci: verify the branded macOS deployment archive
ci/test/test_release_version.py
Before: ci/test/test_release_version.py · After: ci/test/test_release_version.py
File metadata
index 58d7cb6324765eee95a71a52880ec5871a132cec..9da3c7bbc9ad63136d554d46b72b6716ad6eb97c 100755
Download original patch · Release notes
Diff rows 1–50 of 50. 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
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
5
5
|
|
|
6
6
|
from pathlib import Path
|
|
7
|
+
import os
|
|
7
8
|
import re
|
|
9
|
+
import shutil
|
|
8
10
|
import subprocess
|
|
9
11
|
import tempfile
|
|
10
12
|
import unittest
|
|
13
|
+
import zipfile
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
ROOT = Path(__file__).resolve().parents[2]
|
|
@@ -74,6 +77,37 @@ class ReleaseVersionTest(unittest.TestCase):
|
|
|
74
77
|
)
|
|
75
78
|
self.assertEqual(result.stdout.strip(), "bitcoin-roots-30.3-roots.1")
|
|
76
79
|
|
|
80
|
+
def test_macos_deployment_verifies_the_branded_archive(self):
|
|
81
|
+
script = (ROOT / "ci/test/03_test_script.sh").read_text(encoding="utf-8")
|
|
82
|
+
start = script.index('if [[ "$CI_OS_NAME" == "macos"')
|
|
83
|
+
block = script[start:script.index('if [ "$RUN_UNIT_TESTS"', start)]
|
|
84
|
+
client_name = re.search(r'set\(CLIENT_NAME "([^"]+)"\)', BUILD_CONFIG.read_text()).group(1)
|
|
85
|
+
with tempfile.TemporaryDirectory(prefix="roots-macos-deployment-") as directory:
|
|
86
|
+
build = Path(directory)
|
|
87
|
+
with zipfile.ZipFile(build / f"{client_name.replace(' ', '-')}.zip", "w") as archive:
|
|
88
|
+
archive.writestr("Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt", "fixture")
|
|
89
|
+
tools = build / "tools"
|
|
90
|
+
tools.mkdir()
|
|
91
|
+
codesign = tools / "codesign"
|
|
92
|
+
codesign.write_text(
|
|
93
|
+
'#!/bin/sh\nprintf "%s\\n" "$*" > "$CODESIGN_LOG"\nexit "$CODESIGN_STATUS"\n',
|
|
94
|
+
encoding="utf-8",
|
|
95
|
+
)
|
|
96
|
+
codesign.chmod(0o755)
|
|
97
|
+
log = build / "codesign.log"
|
|
98
|
+
for status in (0, 1):
|
|
99
|
+
with self.subTest(codesign_status=status):
|
|
100
|
+
shutil.rmtree(build / "deploy", ignore_errors=True)
|
|
101
|
+
result = subprocess.run(
|
|
102
|
+
["bash", "-ec", block],
|
|
103
|
+
env={**os.environ, "PATH": f"{tools}:{os.environ['PATH']}",
|
|
104
|
+
"BASE_BUILD_DIR": str(build), "CI_OS_NAME": "macos", "GOAL": "install deploy",
|
|
105
|
+
"CODESIGN_LOG": str(log), "CODESIGN_STATUS": str(status)},
|
|
106
|
+
capture_output=True, text=True,
|
|
107
|
+
)
|
|
108
|
+
self.assertEqual(result.returncode, status, result.stderr)
|
|
109
|
+
self.assertEqual(log.read_text().strip(), f"--verify {build}/deploy/Bitcoin-Qt.app")
|
|
110
|
+
|
|
77
111
|
def test_workflow_builds_tags_and_rehearses_explicit_canonical_commits(self):
|
|
78
112
|
workflow = RELEASE_WORKFLOW.read_text(encoding="utf-8")
|
|
79
113
|
self.assertIn("tags:", workflow)
|