Merge lp:~sil2100/cupstream2distro/rebuild_in_ppa into lp:cupstream2distro

Proposed by Robert Bruce Park
Status: Work in progress
Proposed branch: lp:~sil2100/cupstream2distro/rebuild_in_ppa
Merge into: lp:cupstream2distro
Diff against target: 95 lines (+52/-12)
1 file modified
citrain/build.py (+52/-12)
To merge this branch: bzr merge lp:~sil2100/cupstream2distro/rebuild_in_ppa
Reviewer Review Type Date Requested Status
CU2D maintainers Pending
Review via email: mp+267273@code.launchpad.net

Description of the change

(sorry for proposing your branch, was just curious to see a diff!)

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

I like where you're going with this PPARebuild class, but I wonder if it should be moved into a new jenkins job rather than having Yet Another Checkbox on the build job? Especially considering that checking that box makes so many other boxes ignored, it seems weird to have one checkbox that can invalidate other checkboxes from a usability perspective.

If we started a new jenkins job for this, the benefit would be that there'd be no options at all except for the package name selector, which would be delightfully simple.

What do you think?

Unmerged revisions

963. By Łukasz Zemczak

Help string for the new option

962. By Łukasz Zemczak

Merge trunk

961. By Łukasz Zemczak

Initial version of the PPARebuild scenario, where landers can request rebuilds of packages in the PPA without re-uploading. No tests, ugly case-handling.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'citrain/build.py'
2--- citrain/build.py 2015-08-06 17:39:28 +0000
3+++ citrain/build.py 2015-08-06 23:17:46 +0000
4@@ -43,6 +43,10 @@
5 Only useful for sync requests. Instead of rebuilding sources for
6 the destination archive, copy binary packages.
7
8+REBUILD_IN_PPA
9+ Do not build anything, just take the selected PACKAGES_TO_REBUILD and
10+ rebuild them in the PPA if possible, without reuploading
11+
12 DEBUG
13 Enable debug infos
14 """
15@@ -631,6 +635,25 @@
16 super(Manual, self).diff_phase()
17
18
19+class PPARebuild(Manual):
20+ """Perform a PPA rebuild of all latest failed builds for the package."""
21+
22+ def upload_phase(self):
23+ """Scan for the recent version builds and retry them"""
24+ latest_version = self.get_archive_version(self.silo_ppa)
25+ builds = self.silo_ppa.getBuildRecords(source_name=self.name)
26+ latest_failed_archs = set()
27+ for b in builds:
28+ build_version = b.current_source_publication.source_package_version
29+ # Only consider rebuilding every arch once
30+ if (build_version == latest_version and b.can_be_retried and
31+ b.arch_tag not in latest_failed_archs):
32+ latest_failed_archs.add(b.arch_tag)
33+ logging.info('Retrying {} build of {} {} in the PPA.'.format(
34+ b.arch_tag, self.name, latest_version))
35+ b.retry()
36+
37+
38 class BinarySync(Manual):
39 """Copy package binaries from one PPA to another, no rebuilding.
40
41@@ -728,6 +751,16 @@
42 self.names = set(env.PACKAGES_TO_REBUILD.split()
43 or self.silo_state.all_projects)
44 include_all = 'true' in (env.FORCE_REBUILD, env.WATCH_ONLY)
45+ if env.REBUILD_IN_PPA:
46+ if not env.PACKAGES_TO_REBUILD:
47+ self.do = lambda *ignore: None
48+ raise BuildError(
49+ 'You need to explicitly list package names when '
50+ 'requesting REBUILD_IN_PPA.')
51+ if include_all:
52+ logging.warning(
53+ 'WATCH_ONLY and FORCE_REBUILD flags are ignored '
54+ 'during REBUILD_IN_PPA.')
55 if not (include_all or env.PACKAGES_TO_REBUILD):
56 # Don't rebuild existing builds without forcing.
57 previous = self.names & set(find_all_uploaded())
58@@ -746,18 +779,25 @@
59
60 def choose_classes(self):
61 """Decide which class to use for each individual package build."""
62- include_binaries = env.INCLUDE_BINARIES_IN_SYNC == 'true'
63- Sync = BinarySync if include_binaries else SourceSync
64- Source = Sync if self.silo_state.source_archive else Manual
65- self.types = {
66- Merge: self.names & set(self.silo_state.mps),
67- Source: self.names & set(self.silo_state.sources),
68- }
69- if self.silo_state.source_archive:
70- Sync.from_archive = lp.load(self.silo_state.source_archive)
71- Sync.from_series = lp.get_series(
72- self.silo_state.source_series, dest=Sync.from_archive)
73- Merge.all_mps = self.silo_state.mps
74+ if env.REBUILD_IN_PPA:
75+ Source = PPARebuild
76+ self.types = {
77+ Merge: set()
78+ Source: self.names
79+ }
80+ else:
81+ include_binaries = env.INCLUDE_BINARIES_IN_SYNC == 'true'
82+ Sync = BinarySync if include_binaries else SourceSync
83+ Source = Sync if self.silo_state.source_archive else Manual
84+ self.types = {
85+ Merge: self.names & set(self.silo_state.mps),
86+ Source: self.names & set(self.silo_state.sources),
87+ }
88+ if self.silo_state.source_archive:
89+ Sync.from_archive = lp.load(self.silo_state.source_archive)
90+ Sync.from_series = lp.get_series(
91+ self.silo_state.source_series, dest=Sync.from_archive)
92+ Merge.all_mps = self.silo_state.mps
93
94 def instantiate_build_objects(self):
95 """Instantiate the chosen classes for each chosen package."""

Subscribers

People subscribed via source and target branches