Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/release/consumers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
"""Commands for the clean projects in .github/release/consumers that build against a staged release."""

import re
from pathlib import Path

GRADLE_PROJECT = ".github/release/consumers/gradle"
MAVEN_POM = ".github/release/consumers/maven/pom.xml"
GRADLE_FLAGS = ["--no-daemon", "--no-configuration-cache", "--stacktrace"]
PROBE_CLASS = "ly.count.consumer.Probe"
REPOSITORY_ID = "countly"
# Maven 3.9 records the repository as "countly=", Maven 3.10 as "countly-<hex hash of its URL>=". A hex-only suffix
# keeps the "countly-public" repository out.
STAGED_SOURCE = re.compile(rf"{REPOSITORY_ID}(-[0-9a-f]+)?=")


def gradle_command(gradlew, repository, public_repository, plan, artifact):
Expand Down Expand Up @@ -51,6 +55,6 @@ def maven_source_problems(local_repository, plan, consumed):
problems.append(f"Maven did not download {artifact.coordinates}:{plan.version}")
continue
sources = [line.split(">", 1)[1] for line in record.read_text(encoding="utf-8").splitlines() if ">" in line and not line.startswith("#")]
if not sources or any(source != f"{REPOSITORY_ID}=" for source in sources):
if not sources or any(not STAGED_SOURCE.fullmatch(source) for source in sources):
problems.append(f"Maven resolved {artifact.coordinates}:{plan.version} from another repository than the staged release")
return problems
10 changes: 10 additions & 0 deletions .github/release/tests/test_consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ def test_maven_must_resolve_the_release_from_the_staged_folder(self):
self.write_record(local, self.ui, "26.8.1", "java-ui-26.8.1.jar>central=\njava-ui-26.8.1.pom>countly=\n")
self.assertEqual(maven_source_problems(local, self.ui_plan, self.ui), ["Maven resolved ly.count.sdk:java-ui:26.8.1 from another repository than the staged release"])

def test_maven_3_10_records_the_staged_folder_with_a_hash_of_its_url(self):
"""Maven 3.10 writes the repository ID followed by a hash of its URL; the public repository must still fail."""
local = tempfile.mkdtemp()
staged = "countly-58d9892363928677300153295cdc58687f00b301="
self.write_record(local, self.java, "26.9.0", f"java-26.9.0.jar>{staged}\njava-26.9.0.pom>{staged}\n")
self.assertEqual(maven_source_problems(local, self.core_plan, self.java), [])
public = "countly-public-0c2d4b3f1e8a7c6d5b4a3f2e1d0c9b8a7f6e5d4c="
self.write_record(local, self.java, "26.9.0", f"java-26.9.0.jar>{public}\njava-26.9.0.pom>{staged}\n")
self.assertEqual(maven_source_problems(local, self.core_plan, self.java), ["Maven resolved ly.count.sdk:java:26.9.0 from another repository than the staged release"])

def test_the_core_of_a_ui_release_may_come_from_anywhere(self):
local = tempfile.mkdtemp()
self.write_record(local, self.ui, "26.8.1", "java-ui-26.8.1.jar>countly=\njava-ui-26.8.1.pom>countly=\n")
Expand Down
Loading