launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29890
[Merge] ~pelpsi/launchpad:duplicate_ci_jobs into launchpad:master
Simone Pelosi has proposed merging ~pelpsi/launchpad:duplicate_ci_jobs into launchpad:master.
Commit message:
Stages now depend on series
Stages now is a dictionary where each key corresponds
to the series and the value is the old stages array.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/440534
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pelpsi/launchpad:duplicate_ci_jobs into launchpad:master.
diff --git a/lib/lp/code/model/cibuild.py b/lib/lp/code/model/cibuild.py
index 23cb47a..3bd927d 100644
--- a/lib/lp/code/model/cibuild.py
+++ b/lib/lp/code/model/cibuild.py
@@ -85,17 +85,18 @@ from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
def get_stages(configuration):
"""Extract the job stages for this configuration."""
- stages = []
+ stages = {}
if not configuration.pipeline:
raise CannotBuild("No pipeline stages defined")
for stage in configuration.pipeline:
- jobs = []
for job_name in stage:
if job_name not in configuration.jobs:
raise CannotBuild("No job definition for %r" % job_name)
for i in range(len(configuration.jobs[job_name])):
- jobs.append((job_name, i))
- stages.append(jobs)
+ series = configuration.jobs[job_name][i]["series"]
+ if series not in stages:
+ stages[series] = []
+ stages[series].append([(job_name, i)])
return stages
@@ -750,13 +751,14 @@ class CIBuildSet(SpecificBuildFarmJobSourceMixin):
e,
)
continue
+ # issue would be around here
for das in determine_DASes_to_build(configuration, logger=logger):
self._tryToRequestBuild(
git_repository,
commit["sha1"],
configuration,
das,
- stages,
+ stages[das.distroseries.name],
logger,
)
diff --git a/lib/lp/code/model/tests/test_cibuild.py b/lib/lp/code/model/tests/test_cibuild.py
index 722ecb2..c6cf309 100644
--- a/lib/lp/code/model/tests/test_cibuild.py
+++ b/lib/lp/code/model/tests/test_cibuild.py
@@ -853,9 +853,7 @@ class TestCIBuildSet(TestCaseWithFactory):
self.assertEqual(ref.commit_sha1, build.commit_sha1)
self.assertEqual("focal", build.distro_arch_series.distroseries.name)
self.assertEqual("amd64", build.distro_arch_series.architecturetag)
- self.assertEqual(
- [[("build", 0), ("build", 1)], [("test", 0)]], build.stages
- )
+ self.assertEqual([[("build", 1)], [("test", 0)]], build.stages)
self.assertThat(
reports,
MatchesSetwise(
@@ -867,11 +865,59 @@ class TestCIBuildSet(TestCaseWithFactory):
commit_sha1=ref.commit_sha1,
ci_build=build,
)
- for title in ("build:0", "build:1", "test:0")
+ for title in ("build:1", "test:0")
)
),
)
+ def test_requestBuildsForRefs_creates_correct_amount_of_builds(self):
+ ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
+ focal = self.factory.makeDistroSeries(
+ distribution=ubuntu,
+ name="focal",
+ )
+ jammy = self.factory.makeDistroSeries(
+ distribution=ubuntu,
+ name="jammy",
+ )
+ for series in [focal, jammy]:
+ self.factory.makeBuildableDistroArchSeries(
+ distroseries=series, architecturetag="amd64"
+ )
+ configuration = dedent(
+ """\
+ pipeline:
+ - build
+ - test
+
+ jobs:
+ build:
+ series: jammy
+ architectures: amd64
+ run: echo jammy
+ test:
+ series: focal
+ architectures: amd64
+ run: echo focal
+ """
+ ).encode()
+ repository = self.factory.makeGitRepository()
+ ref_paths = ["refs/heads/master"]
+ [ref] = self.factory.makeGitRefs(repository, ref_paths)
+ encoded_commit_json = {
+ "sha1": ref.commit_sha1,
+ "blobs": {".launchpad.yaml": configuration},
+ }
+ self.useFixture(GitHostingFixture(commits=[encoded_commit_json]))
+
+ getUtility(ICIBuildSet).requestBuildsForRefs(repository, ref_paths)
+
+ # builds = getUtility(ICIBuildSet).findByGitRepository(repository)
+ reports = list(
+ getUtility(IRevisionStatusReportSet).findByRepository(repository)
+ )
+ self.assertEqual(len(reports), 2)
+
def test_requestBuildsForRefs_no_commits_at_all(self):
repository = self.factory.makeGitRepository()
ref_paths = ["refs/heads/master"]