Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 8: [PATCH 08/68] ci: restore Roots assurance on Core 30.3 interfaces

ci/test/test_create_patch_series.py

Before: ci/test/test_create_patch_series.py · After: ci/test/test_create_patch_series.py

File metadata
index 3c9bac53b7094e56532fa69720c4cee83192afcc..56194dbde5fd4bc41bdc2467bc876b9d107bc477 100755

Download original patch · Release notes

Diff rows 1–55 of 55. 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_create_patch_series.py CHANGED
@@ -27,7 +27,10 @@ class CreatePatchSeriesTest(unittest.TestCase):
27
  self.git(repository, "config", "user.name", "Patch test")
28
  self.git(repository, "config", "user.email", "patch@example.invalid")
29
  (repository / "source").write_text("core\n", encoding="utf-8")
30
- self.git(repository, "add", "source")
 
 
 
31
  self.git(repository, "commit", "-m", "core", capture_output=True)
32
  core_commit = self.git(repository, "rev-parse", "HEAD", capture_output=True, text=True).stdout.strip()
33
  self.git(repository, "tag", "-a", "v29.4", "-m", "Core v29.4")
@@ -37,13 +40,14 @@ class CreatePatchSeriesTest(unittest.TestCase):
37
  (repository / "binary.dat").write_bytes(bytes(range(256)))
38
  self.git(repository, "add", "binary.dat")
39
  self.git(repository, "commit", "-m", "roots binary", capture_output=True)
 
 
40
  self.git(repository, "tag", "-a", RELEASE_TAG, "-m", RELEASE_TAG)
41
- release_tree = self.git(repository, "rev-parse", "HEAD^{tree}", capture_output=True, text=True).stdout.strip()
42
  self.git(repository, "checkout", "--detach", RELEASE_TAG, capture_output=True)
43
- return repository, core_commit, release_tree
44
 
45
- def test_generates_binary_full_index_series_that_replays_identically(self):
46
- repository, core_commit, release_tree = self.make_release_repository()
47
  output = repository / "artifacts/bitcoin-roots-29.4-roots.1.patch"
48
  environment = {**os.environ, "RELEASE_CANONICAL_REF": "refs/heads/roots/29.4"}
49
  subprocess.run([SCRIPT, RELEASE_TAG, output], cwd=repository, env=environment, check=True)
@@ -52,6 +56,8 @@ class CreatePatchSeriesTest(unittest.TestCase):
52
  self.assertIn("GIT binary patch", patch)
53
  self.assertIn(f"base-commit: {core_commit}", patch)
54
  self.assertGreaterEqual(patch.count("Subject: [PATCH"), 2)
 
 
55
 
56
  with tempfile.TemporaryDirectory() as replay_dir:
57
  replay = Path(replay_dir) / "repository"
@@ -61,11 +67,15 @@ class CreatePatchSeriesTest(unittest.TestCase):
61
  replay, "-c", "user.name=Patch replay", "-c", "user.email=replay@example.invalid",
62
  "am", "-3", output, capture_output=True,
63
  )
64
- replayed_tree = self.git(replay, "rev-parse", "HEAD^{tree}", capture_output=True, text=True).stdout.strip()
65
- self.assertEqual(replayed_tree, release_tree)
 
 
 
 
66
 
67
  def test_rejects_noncanonical_release(self):
68
- repository, _, _ = self.make_release_repository()
69
  self.git(repository, "branch", "--force", "roots/29.4", "v29.4")
70
  output = repository / "release.patch"
71
  result = subprocess.run(
 
27
  self.git(repository, "config", "user.name", "Patch test")
28
  self.git(repository, "config", "user.email", "patch@example.invalid")
29
  (repository / "source").write_text("core\n", encoding="utf-8")
30
+ workflow = repository / ".github/workflows/ci.yml"
31
+ workflow.parent.mkdir(parents=True)
32
+ workflow.write_text("name: Core CI\n", encoding="utf-8")
33
+ self.git(repository, "add", "source", ".github")
34
  self.git(repository, "commit", "-m", "core", capture_output=True)
35
  core_commit = self.git(repository, "rev-parse", "HEAD", capture_output=True, text=True).stdout.strip()
36
  self.git(repository, "tag", "-a", "v29.4", "-m", "Core v29.4")
 
40
  (repository / "binary.dat").write_bytes(bytes(range(256)))
41
  self.git(repository, "add", "binary.dat")
42
  self.git(repository, "commit", "-m", "roots binary", capture_output=True)
43
+ workflow.write_text("name: Roots CI\n", encoding="utf-8")
44
+ self.git(repository, "commit", "-am", "ci: use Roots tests", capture_output=True)
45
  self.git(repository, "tag", "-a", RELEASE_TAG, "-m", RELEASE_TAG)
 
46
  self.git(repository, "checkout", "--detach", RELEASE_TAG, capture_output=True)
47
+ return repository, core_commit
48
 
49
+ def test_generates_product_series_and_omits_github_automation(self):
50
+ repository, core_commit = self.make_release_repository()
51
  output = repository / "artifacts/bitcoin-roots-29.4-roots.1.patch"
52
  environment = {**os.environ, "RELEASE_CANONICAL_REF": "refs/heads/roots/29.4"}
53
  subprocess.run([SCRIPT, RELEASE_TAG, output], cwd=repository, env=environment, check=True)
 
56
  self.assertIn("GIT binary patch", patch)
57
  self.assertIn(f"base-commit: {core_commit}", patch)
58
  self.assertGreaterEqual(patch.count("Subject: [PATCH"), 2)
59
+ self.assertNotIn("diff --git a/.github/", patch)
60
+ self.assertNotIn("ci: use Roots tests", patch)
61
 
62
  with tempfile.TemporaryDirectory() as replay_dir:
63
  replay = Path(replay_dir) / "repository"
 
67
  replay, "-c", "user.name=Patch replay", "-c", "user.email=replay@example.invalid",
68
  "am", "-3", output, capture_output=True,
69
  )
70
+ self.git(
71
+ replay, "diff", "--quiet", RELEASE_TAG, "HEAD", "--",
72
+ ".", ":(exclude).github/**",
73
+ )
74
+ self.git(replay, "diff", "--quiet", core_commit, "HEAD", "--", ".github")
75
+ self.assertEqual((replay / ".github/workflows/ci.yml").read_text(encoding="utf-8"), "name: Core CI\n")
76
 
77
  def test_rejects_noncanonical_release(self):
78
+ repository, _ = self.make_release_repository()
79
  self.git(repository, "branch", "--force", "roots/29.4", "v29.4")
80
  output = repository / "release.patch"
81
  result = subprocess.run(