1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.devtools.build.v1; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/devtools/build/v1/build_events.proto"; 23import "google/protobuf/duration.proto"; 24import "google/protobuf/empty.proto"; 25 26option cc_enable_arenas = true; 27option go_package = "google.golang.org/genproto/googleapis/devtools/build/v1;build"; 28option java_multiple_files = true; 29option java_outer_classname = "BackendProto"; 30option java_package = "com.google.devtools.build.v1"; 31option php_namespace = "Google\\Cloud\\Build\\V1"; 32 33// A service for publishing BuildEvents. BuildEvents are generated by Build 34// Systems to record actions taken during a Build. Events occur in streams, 35// are identified by a StreamId, and ordered by sequence number in a stream. 36// 37// A Build may contain several streams of BuildEvents, depending on the systems 38// that are involved in the Build. Some BuildEvents are used to declare the 39// beginning and end of major portions of a Build; these are called 40// LifecycleEvents, and are used (for example) to indicate the beginning or end 41// of a Build, and the beginning or end of an Invocation attempt (there can be 42// more than 1 Invocation in a Build if, for example, a failure occurs somewhere 43// and it needs to be retried). 44// 45// Other, build-tool events represent actions taken by the Build tool, such as 46// target objects produced via compilation, tests run, et cetera. There could be 47// more than one build tool stream for an invocation attempt of a build. 48service PublishBuildEvent { 49 option (google.api.default_host) = "buildeventservice.googleapis.com"; 50 option (google.api.oauth_scopes) = 51 "https://www.googleapis.com/auth/cloud-platform"; 52 53 // Publish a build event stating the new state of a build (typically from the 54 // build queue). The BuildEnqueued event must be published before all other 55 // events for the same build ID. 56 // 57 // The backend will persist the event and deliver it to registered frontend 58 // jobs immediately without batching. 59 // 60 // The commit status of the request is reported by the RPC's util_status() 61 // function. The error code is the canonical error code defined in 62 // //util/task/codes.proto. 63 rpc PublishLifecycleEvent(PublishLifecycleEventRequest) 64 returns (google.protobuf.Empty) { 65 option (google.api.http) = { 66 post: "/v1/projects/{project_id=*}/lifecycleEvents:publish" 67 body: "*" 68 additional_bindings { post: "/v1/lifecycleEvents:publish" body: "*" } 69 }; 70 } 71 72 // Publish build tool events belonging to the same stream to a backend job 73 // using bidirectional streaming. 74 rpc PublishBuildToolEventStream(stream PublishBuildToolEventStreamRequest) 75 returns (stream PublishBuildToolEventStreamResponse) { 76 option (google.api.http) = { 77 post: "/v1/projects/{project_id=*}/events:publish" 78 body: "*" 79 additional_bindings { post: "/v1/events:publish" body: "*" } 80 }; 81 option (google.api.method_signature) = 82 "ordered_build_event,notification_keywords,project_id"; 83 } 84} 85 86// Publishes 'lifecycle events' that update the high-level state of a build: 87// - BuildEnqueued: When a build is scheduled. 88// - InvocationAttemptStarted: When work for a build starts; there can be 89// multiple invocations for a build (e.g. retries). 90// - InvocationAttemptCompleted: When work for a build finishes. 91// - BuildFinished: When a build is finished. 92message PublishLifecycleEventRequest { 93 // The service level of the build request. Backends only uses this value when 94 // the BuildEnqueued event is published to determine what level of service 95 // this build should receive. 96 enum ServiceLevel { 97 // Non-interactive builds can tolerate longer event latencies. This is the 98 // default ServiceLevel if callers do not specify one. 99 NONINTERACTIVE = 0; 100 101 // The events of an interactive build should be delivered with low latency. 102 INTERACTIVE = 1; 103 } 104 105 // The interactivity of this build. 106 ServiceLevel service_level = 1; 107 108 // Required. The lifecycle build event. If this is a build tool event, the RPC 109 // will fail with INVALID_REQUEST. 110 OrderedBuildEvent build_event = 2 [(google.api.field_behavior) = REQUIRED]; 111 112 // If the next event for this build or invocation (depending on the event 113 // type) hasn't been published after this duration from when {build_event} 114 // is written to BES, consider this stream expired. If this field is not set, 115 // BES backend will use its own default value. 116 google.protobuf.Duration stream_timeout = 3; 117 118 // Additional information about a build request. These are define by the event 119 // publishers, and the Build Event Service does not validate or interpret 120 // them. They are used while notifying internal systems of new builds and 121 // invocations if the OrderedBuildEvent.event type is 122 // BuildEnqueued/InvocationAttemptStarted. 123 repeated string notification_keywords = 4; 124 125 // Required. The project this build is associated with. 126 // This should match the project used for the initial call to 127 // PublishLifecycleEvent (containing a BuildEnqueued message). 128 string project_id = 6 [(google.api.field_behavior) = REQUIRED]; 129 130 // Whether to require a previously received matching parent lifecycle event 131 // for the current request's event before continuing processing. 132 // - InvocationAttemptStarted and BuildFinished events require a BuildEnqueued 133 // parent event. 134 // - InvocationAttemptFinished events require an InvocationAttemptStarted 135 // parent event. 136 bool check_preceding_lifecycle_events_present = 7; 137} 138 139// States which event has been committed. Any failure to commit will cause 140// RPC errors, hence not recorded by this proto. 141message PublishBuildToolEventStreamResponse { 142 // The stream that contains this event. 143 StreamId stream_id = 1; 144 145 // The sequence number of this event that has been committed. 146 int64 sequence_number = 2; 147} 148 149// Build event with contextual information about the stream it belongs to and 150// its position in that stream. 151message OrderedBuildEvent { 152 // Which build event stream this event belongs to. 153 StreamId stream_id = 1; 154 155 // The position of this event in the stream. The sequence numbers for a build 156 // event stream should be a sequence of consecutive natural numbers starting 157 // from one. (1, 2, 3, ...) 158 int64 sequence_number = 2; 159 160 // The actual event. 161 BuildEvent event = 3; 162} 163 164// Streaming request message for PublishBuildToolEventStream. 165message PublishBuildToolEventStreamRequest { 166 // Required. The build event with position info. 167 // New publishing clients should use this field rather than the 3 above. 168 OrderedBuildEvent ordered_build_event = 4 169 [(google.api.field_behavior) = REQUIRED]; 170 171 // The keywords to be attached to the notification which notifies the start 172 // of a new build event stream. BES only reads this field when sequence_number 173 // or ordered_build_event.sequence_number is 1 in this message. If this field 174 // is empty, BES will not publish notification messages for this stream. 175 repeated string notification_keywords = 5; 176 177 // Required. The project this build is associated with. 178 // This should match the project used for the initial call to 179 // PublishLifecycleEvent (containing a BuildEnqueued message). 180 string project_id = 6 [(google.api.field_behavior) = REQUIRED]; 181 182 // Whether to require a previously received matching InvocationAttemptStarted 183 // event before continuing event processing for the event in the current 184 // request. BES only performs this check for events with sequence_number 1 185 // i.e. the first event in the stream. 186 bool check_preceding_lifecycle_events_present = 7; 187} 188