From 6b293f49d6bbe52c1e0d95891bd238b95dd5a792 Mon Sep 17 00:00:00 2001 From: Chenchu Kolli Date: Mon, 9 May 2022 19:01:00 -0500 Subject: [PATCH] Set keywords on appropriate lifecycle events. (#15440) The docs for the PublishLifecycleEventRequest say that the notification_keywords field should be set if the build event is InvocationAttemptStarted or BuildEnqueued. However, Bazel did not conform to this spec. Closes #14857. PiperOrigin-RevId: 442902471 Co-authored-by: Benjamin Peterson --- .../lib/buildeventservice/BuildEventServiceProtoUtil.java | 8 ++++++++ .../buildeventservice/BuildEventServiceProtoUtilTest.java | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtil.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtil.java index f7751f1f7e56cb..d2ac49720d7658 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtil.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtil.java @@ -161,6 +161,14 @@ public PublishLifecycleEventRequest.Builder lifecycleEvent(@Nullable String proj if (projectId != null) { builder.setProjectId(projectId); } + switch (lifecycleEvent.getEventCase()) { + case BUILD_ENQUEUED: + case INVOCATION_ATTEMPT_STARTED: + builder.addAllNotificationKeywords(getKeywords()); + break; + default: + break; + } return builder; } diff --git a/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java b/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java index 9f55becb950579..af4da706088379 100644 --- a/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java +++ b/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java @@ -70,6 +70,7 @@ public void testBuildEnqueued() { PublishLifecycleEventRequest.newBuilder() .setServiceLevel(ServiceLevel.INTERACTIVE) .setProjectId(PROJECT_ID) + .addAllNotificationKeywords(EXPECTED_KEYWORDS) .setBuildEvent( OrderedBuildEvent.newBuilder() .setStreamId( @@ -92,6 +93,7 @@ public void testInvocationAttemptStarted() { PublishLifecycleEventRequest.newBuilder() .setServiceLevel(ServiceLevel.INTERACTIVE) .setProjectId(PROJECT_ID) + .addAllNotificationKeywords(EXPECTED_KEYWORDS) .setBuildEvent( OrderedBuildEvent.newBuilder() .setStreamId(