From 0a2a43f9aab1e3875f03f643f6414eb67834c883 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 19 Apr 2022 13:53:20 -0700 Subject: [PATCH] Set keywords on appropriate lifecycle events. 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 --- .../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 dfe6c49376fdca..b2531a84eb6864 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(