Merge lp:~robru/cupstream2distro/set-ppa-description into lp:cupstream2distro

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 1050
Merged at revision: 1047
Proposed branch: lp:~robru/cupstream2distro/set-ppa-description
Merge into: lp:cupstream2distro
Diff against target: 152 lines (+66/-1)
2 files modified
cupstream2distro/silomanager.py (+46/-1)
tests/unit/test_silomanager.py (+20/-0)
To merge this branch: bzr merge lp:~robru/cupstream2distro/set-ppa-description
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Bruce Park (community) Approve
Review via email: mp+269321@code.launchpad.net

Commit message

Set PPA description with silo summary.

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

You really ought to set self._ppa = None in load_config as well, otherwise you might get very confused later ...

Revision history for this message
Robert Bruce Park (robru) wrote :

Thanks Colin, I don't think it's an issue because ".ppa = ..." is only ever called once in one place, and also the ppa is not something that can change during the life of the SiloState object (the train isn't a long-running process, it starts up with each jenkins job and then exits when done). So it's really a non issue (in fact I should drop the setter entirely, but I'll clean that kind of thing up later)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1050
http://jenkins.qa.ubuntu.com/job/cu2d-choo-choo-ci/720/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/cu2d-choo-choo-ci/720/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cupstream2distro/silomanager.py'
2--- cupstream2distro/silomanager.py 2015-08-22 05:04:58 +0000
3+++ cupstream2distro/silomanager.py 2015-08-27 15:56:24 +0000
4@@ -64,6 +64,26 @@
5 TOKEN_SCRUB = re.compile('token=[a-z0-9-]+', flags=re.IGNORECASE)
6
7
8+PPA_DESCRIPTION = """\
9+Landers: {landers}
10+Status: {status}
11+Destination: {dest}
12+Series: {series} {dual}
13+Packages: {packages}
14+Merges:
15+{merges}
16+
17+Actions:
18+{action_build}
19+{action_publish}
20+{action_clean}
21+
22+More info:
23+{request_url}
24+{status_url}
25+"""
26+
27+
28 default_excepthook = sys.excepthook
29
30
31@@ -102,6 +122,7 @@
32 CONFIG_FILENAME = 'config'
33 _config = None
34 _configfile = None
35+ _ppa = None
36
37 @classmethod
38 def iterate(cls, ignore=None):
39@@ -213,6 +234,27 @@
40 self._config = json.load(data)
41 self._mtime = self.get_mtime()
42
43+ def push_to_ppa_description(self):
44+ """Set the Silo PPA description to something meaningful."""
45+ joburl = '{}job/{}-{{}}/build'.format(
46+ env.JENKINS_URL, self.siloname.replace('/', '-'))
47+ self.ppa.description = PPA_DESCRIPTION.format(
48+ action_build=joburl.format('1-build'),
49+ action_publish=joburl.format('2-publish'),
50+ action_clean=joburl.format('3-merge-clean'),
51+ dest=self.dest.web_link,
52+ dual=self.dual or '',
53+ landers=' '.join(self.landers),
54+ merges='\n'.join(['\n'.join(urls) for urls in self.mps.values()]),
55+ packages=' '.join(self.all_projects),
56+ series=self.series.name,
57+ status_url=env.BUILD_URL + 'consoleFull',
58+ status=self.message,
59+ request_url=env.JENKINS_URL.replace('ci-', 'requests.ci-') +
60+ '#/ticket/{}'.format(self.requestid)).replace(
61+ 'api.launchpad.net/devel', 'launchpad.net')
62+ self.ppa.lp_save()
63+
64 def push_to_bileto(self):
65 """Submit status information to Bileto."""
66 if not BILETO_IP:
67@@ -238,6 +280,7 @@
68 def save_config(self):
69 """Write out the JSON blob."""
70 self.push_to_bileto()
71+ self.push_to_ppa_description()
72 if self._mtime != self.get_mtime():
73 prev = SiloState(self.siloname, do_load=False)
74 prev._configfile = self.configfile
75@@ -468,7 +511,9 @@
76 @property
77 def ppa(self):
78 """Return launchpadlib object representing the silo ppa."""
79- return lp.load(self._config['global']['ppa'])
80+ if self._ppa is None:
81+ self._ppa = lp.load(self._config['global']['ppa'])
82+ return self._ppa
83
84 @ppa.setter
85 def ppa(self, value):
86
87=== modified file 'tests/unit/test_silomanager.py'
88--- tests/unit/test_silomanager.py 2015-08-22 03:51:06 +0000
89+++ tests/unit/test_silomanager.py 2015-08-27 15:56:24 +0000
90@@ -321,6 +321,18 @@
91 self.state._configfile = 'does_not_exist'
92 self.assertRaises(IOError, self.state.load_config)
93
94+ def test_silostate_push_to_ppa_description(self):
95+ """Invoke the correct lplib runes for ppa description setting."""
96+ self.state._ppa = Mock()
97+ self.state.push_to_ppa_description()
98+ self.assertIn(
99+ 'Landers: mzanetti greyback kgunn',
100+ self.state._ppa.description)
101+ self.assertNotIn(
102+ 'https://api.launchpad.net/devel/',
103+ self.state._ppa.description)
104+ self.state._ppa.lp_save.assert_called_once_with()
105+
106 @patch('cupstream2distro.silomanager.BILETO_IP', '8.8.8.8')
107 @patch('cupstream2distro.silomanager.BILETO_API', 'example.com')
108 def test_silostate_push_to_bileto(self):
109@@ -373,8 +385,10 @@
110 tmp = join(self.tempdir, 'config')
111 self.state._configfile = tmp
112 self.state._mtime = self.state.get_mtime()
113+ self.state.push_to_ppa_description = Mock()
114 self.state.push_to_bileto = Mock()
115 self.state.save_config()
116+ self.state.push_to_ppa_description.assert_called_once_with()
117 self.state.push_to_bileto.assert_called_once_with()
118 json_idx.assert_called_once_with()
119 new_state = SiloState('phony-siloname', do_load=False)
120@@ -395,8 +409,10 @@
121 tmp = join(self.tempdir, 'config')
122 self.state._configfile = tmp
123 self.state._mtime = self.state.get_mtime()
124+ self.state.push_to_ppa_description = Mock()
125 self.state.push_to_bileto = Mock()
126 self.state.save_config()
127+ self.state.push_to_ppa_description.assert_called_once_with()
128 self.state.push_to_bileto.assert_called_once_with()
129 time.sleep(0.01)
130 self.state.save_config()
131@@ -417,8 +433,10 @@
132 self.state._configfile = tmp
133 self.state._mtime = self.state.get_mtime()
134 self.state.message = 'First.'
135+ self.state.push_to_ppa_description = Mock()
136 self.state.push_to_bileto = Mock()
137 self.state.save_config()
138+ self.state.push_to_ppa_description.assert_called_once_with()
139 self.state.push_to_bileto.assert_called_once_with()
140 self.state._mtime = 0
141 self.state.message = 'Second.'
142@@ -704,8 +722,10 @@
143 self.assertGreater(first, 0)
144 self.state._configfile = tmp
145 self.state._mtime = self.state.get_mtime()
146+ self.state.push_to_ppa_description = Mock()
147 self.state.push_to_bileto = Mock()
148 self.state.save_config()
149+ self.state.push_to_ppa_description.assert_called_once_with()
150 self.state.push_to_bileto.assert_called_once_with()
151 second = self.state.get_mtime()
152 self.assertGreater(second, first)

Subscribers

People subscribed via source and target branches