Skip to content
Snippets Groups Projects

tests: Test the ci-package-builder pipeline

Merged Emanuele Aina requested to merge wip/em/automatically-test-the-ci-itself into master
All threads resolved!
@@ -17,6 +17,7 @@ SCRATCH_REPO_DIR = "/tmp/scratchrepo"
TEST_BRANCH = "wip/test/fake"
WAIT_AFTER_PUSH = 5
def _debian_mangle_version_to_tag(v):
# see https://dep-team.pages.debian.net/deps/dep14/
v = v.replace(":", "%")
@@ -24,6 +25,7 @@ def _debian_mangle_version_to_tag(v):
v = re.sub("\.(?=\.|$|lock$)", ".#", v)
return v
def _get_branch_prefix(project):
sep = "/"
prefix = project.default_branch.split(sep)[0]
@@ -120,9 +122,7 @@ class GitLabToOBSTester:
def _scratch_cleanup_tags(self):
scratch = self.scratch_git
old_tags = list(scratch.tags)
logging.debug(
f"cleaning up the remote tags {old_tags}"
)
logging.debug(f"cleaning up the remote tags {old_tags}")
if old_tags:
pushes = scratch.remotes.origin.push(old_tags, delete=True, verbose=True)
assert not any(p.flags & git.remote.PushInfo.ERROR for p in pushes)
@@ -145,7 +145,9 @@ class GitLabToOBSTester:
logging.debug(
f"pushing {branches} to {self.scratch_gitlab.path_with_namespace}"
)
pushes = scratch.remotes.origin.push(branches, force=True, verbose=True, follow_tags=True)
pushes = scratch.remotes.origin.push(
branches, force=True, verbose=True, follow_tags=True
)
assert not any(p.flags & git.remote.PushInfo.ERROR for p in pushes)
def reset_scratch(self):
@@ -160,9 +162,7 @@ class GitLabToOBSTester:
scratch.create_remote("reference", url)
scratch.remotes.reference.fetch()
head = scratch.remotes.reference.refs[default]
logging.debug(
f"switching to the {TEST_BRANCH} branch as {head.commit.hexsha}"
)
logging.debug(f"switching to the {TEST_BRANCH} branch as {head.commit.hexsha}")
scratch.create_head(TEST_BRANCH, commit=head.commit).checkout()
self._scratch_synchronize_branches(reference)
logging.debug(
@@ -357,18 +357,25 @@ class GitLabToOBSTester:
logging.info("Release MR landed successfully ✅")
def test_release_artifacts(self, commit):
cmd = subprocess.run(["dpkg-parsechangelog","-SVersion"], capture_output=True, check=True, cwd=SCRATCH_REPO_DIR)
cmd = subprocess.run(
["dpkg-parsechangelog", "-SVersion"],
capture_output=True,
check=True,
cwd=SCRATCH_REPO_DIR,
)
version = cmd.stdout.decode().strip()
mangledversion = _debian_mangle_version_to_tag(version)
prefix = self.scratch_gitlab.default_branch.split("/")[0]
tagname = f"{prefix}/{mangledversion}"
self.scratch_git.remotes.origin.fetch(tags=True)
tag = self.scratch_git.tags[tagname]
assert tag.commit == commit, f"tag {tagname} points to {tag.commit}, expected {commit}"
assert (
tag.commit == commit
), f"tag {tagname} points to {tag.commit}, expected {commit}"
project = self._get_obs_test_project_name()
package = self.reference.split("/")[-1]
files = osc.core.meta_get_filelist(self.apiurl, project, package)
dscs = [f for f in files if f.endswith('.dsc')]
dscs = [f for f in files if f.endswith(".dsc")]
assert len(dscs) == 1, "expected a single .dsc, got {dscs}"
dsc = dscs[0]
expected = f"{package}_{version}.dsc"
@@ -430,7 +437,9 @@ if __name__ == "__main__":
scratch=args.scratch_repository,
testing_pipeline_url=args.testing_pipeline_url,
)
t.connect(args.gitlab_instance, args.gitlab_server_url, args.gitlab_auth_token, args.oscrc)
t.connect(
args.gitlab_instance, args.gitlab_server_url, args.gitlab_auth_token, args.oscrc
)
t.prepare_scratch()
t.reset_scratch()
t.obs_prepare_work_areas()
Loading