Merge lp:~matiasb/launchpad-buildd/add-build-request-id into lp:launchpad-buildd

Proposed by Matias Bordese
Status: Merged
Merged at revision: 372
Proposed branch: lp:~matiasb/launchpad-buildd/add-build-request-id
Merge into: lp:launchpad-buildd
Diff against target: 101 lines (+50/-3)
2 files modified
lpbuildd/target/build_snap.py (+11/-1)
lpbuildd/target/tests/test_build_snap.py (+39/-2)
To merge this branch: bzr merge lp:~matiasb/launchpad-buildd/add-build-request-id
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+366458@code.launchpad.net

Commit message

Add build_request_id and build_request_timestamp to SNAPCRAFT_IMAGE_INFO if provided.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

This looks OK from a launchpad-buildd point of view, but I think you should get review from somebody who's authoritative for adding more keys to SNAPCRAFT_IMAGE_INFO and hence to image-info in the snap manifest. Sergio? A store or snapd architect? Somebody like that ...

review: Approve
Revision history for this message
Matias Bordese (matiasb) :
Revision history for this message
Colin Watson (cjwatson) :
373. By Matias Bordese

Add build_request_timestamp to image_info.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lpbuildd/target/build_snap.py'
2--- lpbuildd/target/build_snap.py 2019-03-06 22:45:38 +0000
3+++ lpbuildd/target/build_snap.py 2019-04-25 13:45:08 +0000
4@@ -63,6 +63,12 @@
5 "(supported snaps: {}, snapcraft)".format(
6 ", ".join(cls.core_snap_names))))
7 parser.add_argument(
8+ "--build-request-id",
9+ help="ID of the request triggering this build on Launchpad")
10+ parser.add_argument(
11+ "--build-request-timestamp",
12+ help="RFC3339 timestamp of the Launchpad build request")
13+ parser.add_argument(
14 "--build-url", help="URL of this build on Launchpad")
15 parser.add_argument("--proxy-url", help="builder proxy url")
16 parser.add_argument(
17@@ -195,9 +201,13 @@
18 @property
19 def image_info(self):
20 data = {}
21+ if self.args.build_request_id is not None:
22+ data["build_request_id"] = self.args.build_request_id
23+ if self.args.build_request_timestamp is not None:
24+ data["build_request_timestamp"] = self.args.build_request_timestamp
25 if self.args.build_url is not None:
26 data["build_url"] = self.args.build_url
27- return json.dumps(data)
28+ return json.dumps(data, sort_keys=True)
29
30 def pull(self):
31 """Run pull phase."""
32
33=== modified file 'lpbuildd/target/tests/test_build_snap.py'
34--- lpbuildd/target/tests/test_build_snap.py 2019-03-12 16:09:00 +0000
35+++ lpbuildd/target/tests/test_build_snap.py 2019-04-25 13:45:08 +0000
36@@ -448,6 +448,40 @@
37 SNAPCRAFT_IMAGE_INFO="{}", SNAPCRAFT_BUILD_ENVIRONMENT="host"),
38 ]))
39
40+ def test_build_including_build_request_id(self):
41+ args = [
42+ "buildsnap",
43+ "--backend=fake", "--series=xenial", "--arch=amd64", "1",
44+ "--build-request-id", "13", "--branch", "lp:foo", "test-snap",
45+ ]
46+ build_snap = parse_args(args=args).operation
47+ build_snap.build()
48+ self.assertThat(build_snap.backend.run.calls, MatchesListwise([
49+ RanBuildCommand(
50+ ["snapcraft"], cwd="/build/test-snap",
51+ SNAPCRAFT_BUILD_INFO="1",
52+ SNAPCRAFT_IMAGE_INFO='{"build_request_id": "13"}',
53+ SNAPCRAFT_BUILD_ENVIRONMENT="host"),
54+ ]))
55+
56+ def test_build_including_build_request_timestamp(self):
57+ args = [
58+ "buildsnap",
59+ "--backend=fake", "--series=xenial", "--arch=amd64", "1",
60+ "--build-request-timestamp", "2018-04-13T14:50:02Z",
61+ "--branch", "lp:foo", "test-snap",
62+ ]
63+ build_snap = parse_args(args=args).operation
64+ build_snap.build()
65+ self.assertThat(build_snap.backend.run.calls, MatchesListwise([
66+ RanBuildCommand(
67+ ["snapcraft"], cwd="/build/test-snap",
68+ SNAPCRAFT_BUILD_INFO="1",
69+ SNAPCRAFT_IMAGE_INFO=(
70+ '{"build_request_timestamp": "2018-04-13T14:50:02Z"}'),
71+ SNAPCRAFT_BUILD_ENVIRONMENT="host"),
72+ ]))
73+
74 # XXX cjwatson 2017-08-07: Test revoke_token. It may be easiest to
75 # convert it to requests first.
76
77@@ -455,6 +489,7 @@
78 args = [
79 "buildsnap",
80 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
81+ "--build-request-id", "13",
82 "--build-url", "https://launchpad.example/build",
83 "--branch", "lp:foo", "test-snap",
84 ]
85@@ -471,13 +506,15 @@
86 SNAPCRAFT_LOCAL_SOURCES="1", SNAPCRAFT_SETUP_CORE="1",
87 SNAPCRAFT_BUILD_INFO="1",
88 SNAPCRAFT_IMAGE_INFO=(
89- '{"build_url": "https://launchpad.example/build"}'),
90+ '{"build_request_id": "13",'
91+ ' "build_url": "https://launchpad.example/build"}'),
92 SNAPCRAFT_BUILD_ENVIRONMENT="host")),
93 AnyMatch(RanBuildCommand(
94 ["snapcraft"], cwd="/build/test-snap",
95 SNAPCRAFT_BUILD_INFO="1",
96 SNAPCRAFT_IMAGE_INFO=(
97- '{"build_url": "https://launchpad.example/build"}'),
98+ '{"build_request_id": "13",'
99+ ' "build_url": "https://launchpad.example/build"}'),
100 SNAPCRAFT_BUILD_ENVIRONMENT="host")),
101 ))
102

Subscribers

People subscribed via source and target branches