Merge ~the-meulengracht/snappy-hwe-snaps/+git/jenkins-jobs:master into ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master

Proposed by Philip Meulengracht
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 09608e565bf593dfa8123f3d47b977b51df9c587
Merged at revision: 6e98ab97183668c16336e9f1fbd2f3b03f577761
Proposed branch: ~the-meulengracht/snappy-hwe-snaps/+git/jenkins-jobs:master
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master
Diff against target: 181 lines (+127/-9)
2 files modified
jobs/infrastructure/prepare-0-install.sh (+2/-5)
tools/vote-on-merge-proposal.py (+125/-4)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Alfonso Sanchez-Beato Approve
Review via email: mp+422819@code.launchpad.net

Description of the change

Use the snap of documentation-builder instead of the python package, it caused conflicts.

Add missing methods from the JLP library that had been removed

To post a comment you must log in.
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jobs/infrastructure/prepare-0-install.sh b/jobs/infrastructure/prepare-0-install.sh
2index afffe90..06a9f84 100644
3--- a/jobs/infrastructure/prepare-0-install.sh
4+++ b/jobs/infrastructure/prepare-0-install.sh
5@@ -86,13 +86,10 @@ fi
6 # Install snaps
7 $SUDO snap install snapcraft
8 $SUDO snap install yq
9+$SUDO snap install documentation-builder
10
11 export http_proxy="{http_proxy}"
12-export https_proxy="{https_proxy}"
13+export https_proxy="{http_proxy}"
14
15-# documentation-builder is normally available as a snap but we can't
16-# use snaps yet on our agents.
17 $SUDO pip3 install --upgrade pip
18-$SUDO pip3 install --ignore-installed PyYAML
19 $SUDO pip3 install jenkins-job-builder pid
20-$SUDO pip3 install ubuntudesign.documentation-builder
21diff --git a/tools/vote-on-merge-proposal.py b/tools/vote-on-merge-proposal.py
22index 96838a7..89f7153 100755
23--- a/tools/vote-on-merge-proposal.py
24+++ b/tools/vote-on-merge-proposal.py
25@@ -21,6 +21,7 @@ import time
26 import logging
27 import os
28 import re
29+from textwrap import dedent
30 from shutil import rmtree
31 from argparse import ArgumentParser
32 from launchpadlib.credentials import RequestTokenAuthorizationEngine
33@@ -204,6 +205,128 @@ def get_vote_subject(mp):
34 mp.target_branch.display_name)
35
36
37+def _get_result_line(result, url):
38+ """Helper method for get_executed_test_runs_message.
39+
40+ Given a result and url it returns a string.
41+ In case the result is failed it provides a link to console output:
42+ FAILED: http://[...]/./distribution=quantal,flavor=amd64/267/console
43+
44+ In case the result is success or unstable (some tests failed) it provides
45+ a link to the job:
46+ SUCCESS: http://[...]/distribution=quantal,flavor=amd64/267
47+
48+ :param result: one of SUCCESS, UNSTABLE or FAILURE (comes from jenkins)
49+ :param url: url of the build or configuration in case of matrix job
50+ """
51+
52+ url = url.rstrip('/')
53+ if result == 'SUCCESS' or result == 'UNSTABLE':
54+ if url.endswith('console'):
55+ # strip "/console"
56+ url = url[:-8]
57+ return "\n {result}: {output}".format(
58+ result=result,
59+ output=url)
60+
61+
62+def get_executed_test_runs_message(url):
63+ """Return a string with executed runs for a given jenkins build url.
64+
65+ :param url: url with jenkins build
66+
67+ This is an example result of this function:
68+ ----snip----
69+Executed test runs:
70+ FAILURE: http://[...]/./distribution=raring,flavor=amd64/3/console
71+ FAILURE: http://[...]/./distribution=raring,flavor=i386/3/console
72+ SUCCESS: http://[...]/job-freestyle/7
73+ deb: http://[...]/job-freestyle/7/artifact/work/output/*zip*/output.zip
74+ UNSTABLE: http://jenkins/job/freestyle-downstream/12
75+Coverity artifacts:
76+ http://[...]/artifact/results/coverity/CID_10895.html
77+ http://[...]/results/coverity/CID_10896.html
78+ http://[...]/results/coverity/CID_10895.html
79+ http://[...]/results/coverity/CID_10896.html
80+ ----snip----
81+ """
82+
83+ ret = "\nExecuted test runs:"
84+ jenkins = jenkinsutils.get_json_jenkins()
85+ builds = jenkinsutils.get_executed_builds(jenkins, url)
86+ coverity_artifacts = []
87+ for build in builds:
88+ ret += _get_result_line(
89+ build['result'],
90+ jenkinsutils.hide_jenkins_url(build['output']))
91+ if build['output'].endswith('console'):
92+ build_url = build['output'][:-len('console')]
93+ artifacts = jenkinsutils.get_coverity_artifacts(jenkins, build_url)
94+ debs = jenkinsutils.get_deb_artifacts(jenkins, build_url)
95+ if debs:
96+ ret += "\n deb: {}".format(jenkinsutils.hide_jenkins_url(debs))
97+ coverity_artifacts += artifacts
98+ if coverity_artifacts:
99+ ret += "\nCoverity artifacts:"
100+ for artifact in coverity_artifacts:
101+ ret += "\n {}".format(jenkinsutils.hide_jenkins_url(artifact))
102+
103+ return ret
104+
105+
106+def format_message_for_mp_update(build_url, message=None,
107+ include_rebuild_link=True):
108+ """Return a formatted message that is then posted as comment to the merge
109+ proposal.
110+
111+ The message consists of:
112+ * message
113+ * executed test-runs (and links to artifacts such as deb files)
114+ * rubuild link
115+
116+ :params build_url: jenkins url of the build in question
117+ :params message: custom message (usually PASSED/FAILED)
118+ :include_rebuild_link: boolean which affects the generation of rebuild link
119+
120+ Example:
121+ ----snip----
122+ PASSED: Continuous integration, rev:114
123+ http://s-jenkins.ubuntu-ci:8080/job/jenkins-launchpad-plugin-ci/267/
124+ Executed test runs:
125+ SUCCESS: http://[...]/distribution=quantal,flavor=amd64/267
126+
127+ Click here to trigger a rebuild:
128+ http://s-jenkins.ubuntu-ci:8080/job/jenkins-launchpad-plugin-ci/267/rebuild
129+ ----snip----
130+
131+ """
132+ formatted_message = dedent('''\
133+ {message}{build_url}{executed_test_runs}
134+ ''')
135+ if include_rebuild_link:
136+ formatted_message = formatted_message + dedent('''\
137+
138+ Click here to trigger a rebuild:
139+ {rebuild_url}
140+ ''')
141+ if not message:
142+ message = ''
143+ if not build_url:
144+ build_url = ''
145+ executed_test_runs_message = ''
146+ else:
147+ executed_test_runs_message = \
148+ get_executed_test_runs_message(build_url)
149+
150+ rebuild_url = '{build_url}/rebuild'.format(
151+ build_url=build_url.rstrip('/'))
152+ return formatted_message.format(
153+ message=message,
154+ build_url=jenkinsutils.hide_jenkins_url(build_url),
155+ rebuild_url=jenkinsutils.hide_jenkins_url(rebuild_url),
156+ executed_test_runs=executed_test_runs_message)
157+
158+
159 def approve_mp(mp, revision, build_url):
160 """Approve a given merge proposal a revision.
161
162@@ -215,8 +338,7 @@ def approve_mp(mp, revision, build_url):
163 """
164 state = 'PASSED: Continuous integration, rev:' + str(revision)
165 logger.debug(state)
166- content = jenkinsutils.format_message_for_mp_update(build_url,
167- state + "\n")
168+ content = format_message_for_mp_update(build_url, state + "\n")
169 mp.createComment(review_type=get_config_option('launchpad_review_type'),
170 vote=LaunchpadVote.APPROVE, subject=get_vote_subject(mp),
171 content=content)
172@@ -238,8 +360,7 @@ def disapprove_mp(mp, revision, build_url, reason=None):
173 state = "{state}\n{reason}".format(state=state, reason=reason)
174
175 logger.debug(state)
176- content = jenkinsutils.format_message_for_mp_update(
177- build_url, state + "\n")
178+ content = format_message_for_mp_update(build_url, state + "\n")
179 mp.createComment(review_type=get_config_option('launchpad_review_type'),
180 vote=LaunchpadVote.NEEDS_FIXING,
181 subject=get_vote_subject(mp),

Subscribers

People subscribed via source and target branches