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
=== modified file 'lpbuildd/target/build_snap.py'
--- lpbuildd/target/build_snap.py 2019-03-06 22:45:38 +0000
+++ lpbuildd/target/build_snap.py 2019-04-25 13:45:08 +0000
@@ -63,6 +63,12 @@
63 "(supported snaps: {}, snapcraft)".format(63 "(supported snaps: {}, snapcraft)".format(
64 ", ".join(cls.core_snap_names))))64 ", ".join(cls.core_snap_names))))
65 parser.add_argument(65 parser.add_argument(
66 "--build-request-id",
67 help="ID of the request triggering this build on Launchpad")
68 parser.add_argument(
69 "--build-request-timestamp",
70 help="RFC3339 timestamp of the Launchpad build request")
71 parser.add_argument(
66 "--build-url", help="URL of this build on Launchpad")72 "--build-url", help="URL of this build on Launchpad")
67 parser.add_argument("--proxy-url", help="builder proxy url")73 parser.add_argument("--proxy-url", help="builder proxy url")
68 parser.add_argument(74 parser.add_argument(
@@ -195,9 +201,13 @@
195 @property201 @property
196 def image_info(self):202 def image_info(self):
197 data = {}203 data = {}
204 if self.args.build_request_id is not None:
205 data["build_request_id"] = self.args.build_request_id
206 if self.args.build_request_timestamp is not None:
207 data["build_request_timestamp"] = self.args.build_request_timestamp
198 if self.args.build_url is not None:208 if self.args.build_url is not None:
199 data["build_url"] = self.args.build_url209 data["build_url"] = self.args.build_url
200 return json.dumps(data)210 return json.dumps(data, sort_keys=True)
201211
202 def pull(self):212 def pull(self):
203 """Run pull phase."""213 """Run pull phase."""
204214
=== modified file 'lpbuildd/target/tests/test_build_snap.py'
--- lpbuildd/target/tests/test_build_snap.py 2019-03-12 16:09:00 +0000
+++ lpbuildd/target/tests/test_build_snap.py 2019-04-25 13:45:08 +0000
@@ -448,6 +448,40 @@
448 SNAPCRAFT_IMAGE_INFO="{}", SNAPCRAFT_BUILD_ENVIRONMENT="host"),448 SNAPCRAFT_IMAGE_INFO="{}", SNAPCRAFT_BUILD_ENVIRONMENT="host"),
449 ]))449 ]))
450450
451 def test_build_including_build_request_id(self):
452 args = [
453 "buildsnap",
454 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
455 "--build-request-id", "13", "--branch", "lp:foo", "test-snap",
456 ]
457 build_snap = parse_args(args=args).operation
458 build_snap.build()
459 self.assertThat(build_snap.backend.run.calls, MatchesListwise([
460 RanBuildCommand(
461 ["snapcraft"], cwd="/build/test-snap",
462 SNAPCRAFT_BUILD_INFO="1",
463 SNAPCRAFT_IMAGE_INFO='{"build_request_id": "13"}',
464 SNAPCRAFT_BUILD_ENVIRONMENT="host"),
465 ]))
466
467 def test_build_including_build_request_timestamp(self):
468 args = [
469 "buildsnap",
470 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
471 "--build-request-timestamp", "2018-04-13T14:50:02Z",
472 "--branch", "lp:foo", "test-snap",
473 ]
474 build_snap = parse_args(args=args).operation
475 build_snap.build()
476 self.assertThat(build_snap.backend.run.calls, MatchesListwise([
477 RanBuildCommand(
478 ["snapcraft"], cwd="/build/test-snap",
479 SNAPCRAFT_BUILD_INFO="1",
480 SNAPCRAFT_IMAGE_INFO=(
481 '{"build_request_timestamp": "2018-04-13T14:50:02Z"}'),
482 SNAPCRAFT_BUILD_ENVIRONMENT="host"),
483 ]))
484
451 # XXX cjwatson 2017-08-07: Test revoke_token. It may be easiest to485 # XXX cjwatson 2017-08-07: Test revoke_token. It may be easiest to
452 # convert it to requests first.486 # convert it to requests first.
453487
@@ -455,6 +489,7 @@
455 args = [489 args = [
456 "buildsnap",490 "buildsnap",
457 "--backend=fake", "--series=xenial", "--arch=amd64", "1",491 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
492 "--build-request-id", "13",
458 "--build-url", "https://launchpad.example/build",493 "--build-url", "https://launchpad.example/build",
459 "--branch", "lp:foo", "test-snap",494 "--branch", "lp:foo", "test-snap",
460 ]495 ]
@@ -471,13 +506,15 @@
471 SNAPCRAFT_LOCAL_SOURCES="1", SNAPCRAFT_SETUP_CORE="1",506 SNAPCRAFT_LOCAL_SOURCES="1", SNAPCRAFT_SETUP_CORE="1",
472 SNAPCRAFT_BUILD_INFO="1",507 SNAPCRAFT_BUILD_INFO="1",
473 SNAPCRAFT_IMAGE_INFO=(508 SNAPCRAFT_IMAGE_INFO=(
474 '{"build_url": "https://launchpad.example/build"}'),509 '{"build_request_id": "13",'
510 ' "build_url": "https://launchpad.example/build"}'),
475 SNAPCRAFT_BUILD_ENVIRONMENT="host")),511 SNAPCRAFT_BUILD_ENVIRONMENT="host")),
476 AnyMatch(RanBuildCommand(512 AnyMatch(RanBuildCommand(
477 ["snapcraft"], cwd="/build/test-snap",513 ["snapcraft"], cwd="/build/test-snap",
478 SNAPCRAFT_BUILD_INFO="1",514 SNAPCRAFT_BUILD_INFO="1",
479 SNAPCRAFT_IMAGE_INFO=(515 SNAPCRAFT_IMAGE_INFO=(
480 '{"build_url": "https://launchpad.example/build"}'),516 '{"build_request_id": "13",'
517 ' "build_url": "https://launchpad.example/build"}'),
481 SNAPCRAFT_BUILD_ENVIRONMENT="host")),518 SNAPCRAFT_BUILD_ENVIRONMENT="host")),
482 ))519 ))
483520

Subscribers

People subscribed via source and target branches