xref: /aosp_15_r20/external/googleapis/google/devtools/resultstore/v2/action.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
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.resultstore.v2;
18
19import "google/api/resource.proto";
20import "google/devtools/resultstore/v2/common.proto";
21import "google/devtools/resultstore/v2/coverage.proto";
22import "google/devtools/resultstore/v2/file.proto";
23import "google/devtools/resultstore/v2/file_processing_error.proto";
24import "google/devtools/resultstore/v2/test_suite.proto";
25import "google/protobuf/duration.proto";
26
27option go_package = "google.golang.org/genproto/googleapis/devtools/resultstore/v2;resultstore";
28option java_multiple_files = true;
29option java_outer_classname = "ActionProto";
30option java_package = "com.google.devtools.resultstore.v2";
31
32// An action that happened as part of a configured target. This action could be
33// a build, a test, or another type of action, as specified in action_type
34// oneof.
35//
36// Each parent ConfiguredTarget resource should have at least one Action as its
37// child resource before the invocation is finalized. For a simple build, at
38// least one build action should be created to represent the build result, and
39// at least one test action should be created to represent the test result, if
40// any.
41message Action {
42  option (google.api.resource) = {
43    type: "resultstore.googleapis.com/Action"
44    pattern: "invocations/{invocation}/targets/{target}/configuredTargets/{configured_target}/actions/{action}"
45  };
46
47  // The resource ID components that identify the Action.
48  message Id {
49    // The Invocation ID.
50    string invocation_id = 1;
51
52    // The Target ID.
53    string target_id = 2;
54
55    // The Configuration ID.
56    string configuration_id = 3;
57
58    // The Action ID.
59    string action_id = 4;
60  }
61
62  // The resource name.  Its format must be:
63  // invocations/${INVOCATION_ID}/targets/${url_encode(TARGET_ID)}/configuredTargets/url_encode(${CONFIG_ID})/actions/${url_encode(ACTION_ID)}
64  //
65  // See CreateActionRequest proto for more information.
66  string name = 1;
67
68  // The resource ID components that identify the Action. They must match the
69  // resource name after proper encoding.
70  Id id = 2;
71
72  // The status of the action.
73  StatusAttributes status_attributes = 3;
74
75  // The timing of the whole action. For TestActions, the start time may be
76  // before the test actually started, and the duration may last until after the
77  // test actually finished.
78  Timing timing = 4;
79
80  // The type of the action. The type of an action may not change over the
81  // lifetime of the invocation. If one of these fields is to be set, it must be
82  // set in the CreateAction method. It may be set to an empty message that is
83  // populated in later methods or post-processing. A generic "untyped" action
84  // can be created by not setting any of these fields. An untyped action will
85  // be untyped for the lifetime of the invocation.
86  oneof action_type {
87    // Used only when this action represents a build action.
88    BuildAction build_action = 9;
89
90    // Only for test actions.
91    TestAction test_action = 10;
92  }
93
94  // General attributes of the action.
95  ActionAttributes action_attributes = 5;
96
97  // A list of resources that this action depended upon. May be used to provide
98  // the cause of a build failure in the case of a failed build action.
99  repeated Dependency action_dependencies = 14;
100
101  // Arbitrary name-value pairs.
102  // This is implemented as a multi-map. Multiple properties are allowed with
103  // the same key. Properties will be returned in lexicographical order by key.
104  repeated Property properties = 7;
105
106  // A list of file references for action level files.
107  // The file IDs must be unique within this list. Duplicate file IDs will
108  // result in an error. Files will be returned in lexicographical order by ID.
109  //
110  // Files with the following reserved file IDs cause specific post-processing
111  // or have special handling. These files must be immediately available to
112  // ResultStore for processing when the reference is uploaded.
113  //
114  // For build actions:
115  // stdout: The stdout of the action
116  // stderr: The stderr of the action
117  // baseline.lcov: Baseline coverage file to be parsed by the server. This
118  //     uses a stripped down implementation of the LCOV standard.
119  //     http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
120  //
121  // For test actions:
122  // test.xml: The test suite / test case data in XML format.
123  // test.log: The combined stdout and stderr of the test process.
124  // test.lcov: Coverage file to be parsed by the server. This uses a stripped
125  //     down implementation of the LCOV standard.
126  //     http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
127  repeated File files = 8;
128
129  // List of names of file sets that are referenced from this Action.
130  // Each name must point to a file set under the same Invocation. The name
131  // format must be: invocations/${INVOCATION_ID}/fileSets/${FILE_SET_ID}
132  repeated string file_sets = 15;
133
134  // Coverage data was collected while running the build or test action. This
135  // usually includes line coverage, and may also include branch coverage.
136  // For test actions, this is usually only for the source files which were
137  // actually executed by that particular action.
138  // For build actions, this is the baseline coverage, which captures the
139  // instrumented files and lines, without any lines being executed. This
140  // ensures files that are never covered at all are included.
141  ActionCoverage coverage = 11;
142
143  // ResultStore will read and parse Files with reserved IDs listed above. Read
144  // and parse errors for all these Files are reported here.
145  // This is implemented as a map, with one FileProcessingErrors for each file.
146  // Typically produced when parsing Files, but may also be provided directly
147  // by clients.
148  repeated FileProcessingErrors file_processing_errors = 13;
149}
150
151// A build action, such as building a java library.
152message BuildAction {
153  // The type of the action.  This is intended to be a clue as to how the output
154  // of the action should be parsed. For example "javac" for a Java compile
155  // action.
156  string type = 1;
157
158  // The "primary" input artifact processed by this action.  E.g., the .cc file
159  // of a C++ compile action.  Empty string ("") if the action has no input
160  // artifacts or no "primary" input artifact.
161  string primary_input_path = 2;
162
163  // The "primary" output artifact processed by this action.  E.g., the .o file
164  // of a C++ compile action.  Empty string ("") if the action has no output
165  // artifacts or no "primary" output artifact.
166  string primary_output_path = 3;
167}
168
169// A test action, such as running a JUnit4 test binary.
170message TestAction {
171  // Timing data for execution of the test action.
172  TestTiming test_timing = 1;
173
174  // If the test is divided up into shards to improve performance, set this to
175  // indicate which shard this test action is for. Value must be in interval
176  // [0, total_shard_count). Defaults to 0, which is appropriate if all test
177  // cases are run in the same process.
178  int32 shard_number = 2;
179
180  // If the user requested that every test be run multiple times, as is often
181  // done to measure flakiness, set this to indicate which run this test action
182  // is for. Value must be in interval [0, total_run_count). Defaults to 0,
183  // which is appropriate if multiple runs were not requested.
184  int32 run_number = 3;
185
186  // If flaky tests are automatically retried, set this to indicate which
187  // attempt this test action is for. (e.g. 0 for the first attempt, 1 for
188  // second, and so on). Defaults to 0, which is appropriate if this is the only
189  // attempt.
190  int32 attempt_number = 4;
191
192  // A tree of test suites and test cases that were run by this test action.
193  // Each test case has its own status information, including stack traces.
194  // Typically produced by parsing an XML Log, but may also be provided directly
195  // by clients.
196  TestSuite test_suite = 5;
197
198  // Warnings for this test action.
199  repeated TestWarning warnings = 8;
200
201  // Estimated memory consumption of the test action, in bytes. A default value
202  // of 0 means there is no memory consumption estimate specified.
203  int64 estimated_memory_bytes = 10;
204}
205
206// General attributes of an action
207message ActionAttributes {
208  // Strategy used for executing the action.
209  ExecutionStrategy execution_strategy = 1;
210
211  // Exit code of the process that ran the action. A non-zero value means
212  // failure.
213  int32 exit_code = 2;
214
215  // Where the action was run.
216  string hostname = 3;
217
218  // Information about the input files used in all actions under this configured
219  // target.
220  InputFileInfo input_file_info = 4;
221}
222
223// File count and size information for the input files to a configured target.
224message InputFileInfo {
225  // The number of input files (counting every file, even if a duplicate).
226  int64 count = 1;
227
228  // The number of distinct input files.
229  int64 distinct_count = 2;
230
231  // The max number of input files allowed by the build system (counting every
232  // file, even if a duplicate).
233  int64 count_limit = 3;
234
235  // The total size of the distinct input files.
236  int64 distinct_bytes = 4;
237
238  // The max allowed total size of the distinct input files.
239  int64 distinct_byte_limit = 5;
240}
241
242// Timing data for tests executed locally on the machine running the build.
243message LocalTestTiming {
244  // Time taken by the test process, typically surrounded by a small wrapper
245  // script.
246  google.protobuf.Duration test_process_duration = 1;
247}
248
249// Timing data for one attempt to execute a test action remotely.
250message RemoteTestAttemptTiming {
251  // Idle period before the test process is invoked on the remote machine.
252  google.protobuf.Duration queue_duration = 1;
253
254  // Time to upload data dependencies from the local machine to the remote
255  // machine running the test, or to the distributed cache.
256  google.protobuf.Duration upload_duration = 2;
257
258  // Time to set up the remote machine.
259  // Not to be confused with setup time in
260  // xUnit test frameworks, which falls within the test_process_time.
261  google.protobuf.Duration machine_setup_duration = 3;
262
263  // Time taken by the test process, typically surrounded by a small wrapper
264  // script.
265  // For Java tests, this includes JVM setup, flag parsing, class path setup,
266  // parsing files to setup the suite, and finally running your test methods.
267  // In many cases, only a small fraction of the test process time is spent
268  // running the test methods.
269  google.protobuf.Duration test_process_duration = 4;
270
271  // Time spent retrieving test logs and any other test outputs, back to the
272  // local machine.
273  google.protobuf.Duration download_duration = 5;
274}
275
276// Timing data for the part of the test execution that is done remotely.
277message RemoteTestTiming {
278  // Time taken locally to determine what to do.
279  google.protobuf.Duration local_analysis_duration = 1;
280
281  // Normally there is only one attempt, but the system may retry on internal
282  // errors, leading to multiple attempts.
283  repeated RemoteTestAttemptTiming attempts = 2;
284}
285
286// Timing data for execution of a test action. The action may be performed
287// locally, on the machine running the build, or remotely.
288message TestTiming {
289  // Test timing for either a local or remote execution.
290  oneof location {
291    // Used for local test actions.
292    LocalTestTiming local = 1;
293
294    // Used for remote test actions.
295    RemoteTestTiming remote = 2;
296  }
297
298  // The amount of CPU time spent by the test process executing system calls
299  // within the kernel, as opposed to library code. Time the test process spent
300  // blocked does not count towards this figure.
301  google.protobuf.Duration system_time_duration = 3;
302
303  // The amount of CPU time spent by the test process executing user-mode code
304  // outside the kernel, as opposed to library code. Time the test process
305  // spent blocked does not count towards this figure. You can add user_time to
306  // system_time to get total CPU time taken by the test process.
307  google.protobuf.Duration user_time_duration = 4;
308
309  // Most build systems cache build results to speed up incremental builds.
310  // Some also cache test results too. This indicates whether the test results
311  // were found in a cache, and where that cache was located.
312  TestCaching test_caching = 5;
313}
314
315// A warning from a test execution.
316message TestWarning {
317  // Contains the message detailing the warning.
318  string warning_message = 1;
319}
320
321// Indicates how/where this Action was executed.
322enum ExecutionStrategy {
323  // The action did not indicate how it was executed.
324  EXECUTION_STRATEGY_UNSPECIFIED = 0;
325
326  // The action was executed in some other form.
327  OTHER_ENVIRONMENT = 1;
328
329  // The action used a remote build service.
330  REMOTE_SERVICE = 2;
331
332  // The action was executed locally, in parallel with other actions.
333  LOCAL_PARALLEL = 3;
334
335  // The action was executed locally, without parallelism.
336  LOCAL_SEQUENTIAL = 4;
337}
338
339// Most build systems cache build results to speed up incremental builds.
340// Some also cache test results too. This indicates whether the test results
341// were found in a cache, and where that cache was located.
342enum TestCaching {
343  // The implicit default enum value. Should never be set.
344  TEST_CACHING_UNSPECIFIED = 0;
345
346  // The test result was found in a local cache, so it wasn't run again.
347  LOCAL_CACHE_HIT = 1;
348
349  // The test result was found in a remote cache, so it wasn't run again.
350  REMOTE_CACHE_HIT = 2;
351
352  // The test result was not found in any cache, so it had to be run again.
353  CACHE_MISS = 3;
354}
355