Skip to content

Commit

Permalink
feat(bazel/protos): automatically generate typescript implementation …
Browse files Browse the repository at this point in the history
…of bazel test_status proto (#239)

Load bazel test_status proto to the workspace and generate test_status protobuf javscript class
with typescript typings.

PR Close #239
  • Loading branch information
josephperrott committed Sep 23, 2021
1 parent 89b4be9 commit 0a83a42
Show file tree
Hide file tree
Showing 8 changed files with 1,826 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bazel/protos/*.d.ts
bazel/protos/*.js
github-actions/feature-request/post.js
github-actions/feature-request/main.js
github-actions/lock-closed/main.js
Expand Down
8 changes: 7 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ workspace(
managed_directories = {"@npm": ["node_modules"]},
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

# Fetch rules_nodejs so we can install our npm dependencies
http_archive(
Expand Down Expand Up @@ -46,3 +46,9 @@ register_toolchains(
"//tools/git-toolchain:git_macos_arm64_toolchain",
"//tools/git-toolchain:git_windows_toolchain",
)

http_file(
name = "bazel_test_status_proto",
sha256 = "61ce1dc62fdcfd6d68624a403e0f04c5fd5136d933b681467aad1ad2d00dbb03",
urls = ["https://raw.githubusercontent.com/bazelbuild/bazel/4.2.1/src/main/protobuf/test_status.proto"],
)
6 changes: 6 additions & 0 deletions bazel/protos/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("//tools:generate_ts_proto_module.bzl", "generate_ts_proto_module")

generate_ts_proto_module(
name = "test_status",
protofile = "@bazel_test_status_proto//file",
)
355 changes: 355 additions & 0 deletions bazel/protos/test_status_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,355 @@
import * as $protobuf from "protobufjs";
/** Namespace blaze. */
export namespace blaze {

/** FailedTestCasesStatus enum. */
enum FailedTestCasesStatus {
FULL = 1,
PARTIAL = 2,
NOT_AVAILABLE = 3,
EMPTY = 4
}

/** BlazeTestStatus enum. */
enum BlazeTestStatus {
NO_STATUS = 0,
PASSED = 1,
FLAKY = 2,
TIMEOUT = 3,
FAILED = 4,
INCOMPLETE = 5,
REMOTE_FAILURE = 6,
FAILED_TO_BUILD = 7,
BLAZE_HALTED_BEFORE_TESTING = 8
}

/** Properties of a TestCase. */
interface ITestCase {

/** TestCase child */
child?: (blaze.ITestCase[]|null);

/** TestCase name */
name?: (string|null);

/** TestCase className */
className?: (string|null);

/** TestCase runDurationMillis */
runDurationMillis?: (number|Long|null);

/** TestCase result */
result?: (string|null);

/** TestCase type */
type?: (blaze.TestCase.Type|null);

/** TestCase status */
status?: (blaze.TestCase.Status|null);

/** TestCase run */
run?: (boolean|null);
}

/** Represents a TestCase. */
class TestCase implements ITestCase {

/**
* Constructs a new TestCase.
* @param [properties] Properties to set
*/
constructor(properties?: blaze.ITestCase);

/** TestCase child. */
public child: blaze.ITestCase[];

/** TestCase name. */
public name: string;

/** TestCase className. */
public className: string;

/** TestCase runDurationMillis. */
public runDurationMillis: (number|Long);

/** TestCase result. */
public result: string;

/** TestCase type. */
public type: blaze.TestCase.Type;

/** TestCase status. */
public status: blaze.TestCase.Status;

/** TestCase run. */
public run: boolean;

/**
* Creates a new TestCase instance using the specified properties.
* @param [properties] Properties to set
* @returns TestCase instance
*/
public static create(properties?: blaze.ITestCase): blaze.TestCase;

/**
* Encodes the specified TestCase message. Does not implicitly {@link blaze.TestCase.verify|verify} messages.
* @param message TestCase message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: blaze.ITestCase, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Encodes the specified TestCase message, length delimited. Does not implicitly {@link blaze.TestCase.verify|verify} messages.
* @param message TestCase message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: blaze.ITestCase, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Decodes a TestCase message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns TestCase
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): blaze.TestCase;

/**
* Decodes a TestCase message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns TestCase
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): blaze.TestCase;

/**
* Verifies a TestCase message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);

/**
* Creates a TestCase message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns TestCase
*/
public static fromObject(object: { [k: string]: any }): blaze.TestCase;

/**
* Creates a plain object from a TestCase message. Also converts values to other types if specified.
* @param message TestCase
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: blaze.TestCase, options?: $protobuf.IConversionOptions): { [k: string]: any };

/**
* Converts this TestCase to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}

namespace TestCase {

/** Type enum. */
enum Type {
TEST_CASE = 0,
TEST_SUITE = 1,
TEST_DECORATOR = 2,
UNKNOWN = 3
}

/** Status enum. */
enum Status {
PASSED = 0,
FAILED = 1,
ERROR = 2
}
}

/** Properties of a TestResultData. */
interface ITestResultData {

/** TestResultData cachable */
cachable?: (boolean|null);

/** TestResultData testPassed */
testPassed?: (boolean|null);

/** TestResultData status */
status?: (blaze.BlazeTestStatus|null);

/** TestResultData statusDetails */
statusDetails?: (string|null);

/** TestResultData failedLogs */
failedLogs?: (string[]|null);

/** TestResultData warning */
warning?: (string[]|null);

/** TestResultData hasCoverage */
hasCoverage?: (boolean|null);

/** TestResultData remotelyCached */
remotelyCached?: (boolean|null);

/** TestResultData isRemoteStrategy */
isRemoteStrategy?: (boolean|null);

/** TestResultData testTimes */
testTimes?: ((number|Long)[]|null);

/** TestResultData passedLog */
passedLog?: (string|null);

/** TestResultData testProcessTimes */
testProcessTimes?: ((number|Long)[]|null);

/** TestResultData runDurationMillis */
runDurationMillis?: (number|Long|null);

/** TestResultData startTimeMillisEpoch */
startTimeMillisEpoch?: (number|Long|null);

/** TestResultData testCase */
testCase?: (blaze.ITestCase|null);

/** TestResultData failedStatus */
failedStatus?: (blaze.FailedTestCasesStatus|null);
}

/** Represents a TestResultData. */
class TestResultData implements ITestResultData {

/**
* Constructs a new TestResultData.
* @param [properties] Properties to set
*/
constructor(properties?: blaze.ITestResultData);

/** TestResultData cachable. */
public cachable: boolean;

/** TestResultData testPassed. */
public testPassed: boolean;

/** TestResultData status. */
public status: blaze.BlazeTestStatus;

/** TestResultData statusDetails. */
public statusDetails: string;

/** TestResultData failedLogs. */
public failedLogs: string[];

/** TestResultData warning. */
public warning: string[];

/** TestResultData hasCoverage. */
public hasCoverage: boolean;

/** TestResultData remotelyCached. */
public remotelyCached: boolean;

/** TestResultData isRemoteStrategy. */
public isRemoteStrategy: boolean;

/** TestResultData testTimes. */
public testTimes: (number|Long)[];

/** TestResultData passedLog. */
public passedLog: string;

/** TestResultData testProcessTimes. */
public testProcessTimes: (number|Long)[];

/** TestResultData runDurationMillis. */
public runDurationMillis: (number|Long);

/** TestResultData startTimeMillisEpoch. */
public startTimeMillisEpoch: (number|Long);

/** TestResultData testCase. */
public testCase?: (blaze.ITestCase|null);

/** TestResultData failedStatus. */
public failedStatus: blaze.FailedTestCasesStatus;

/**
* Creates a new TestResultData instance using the specified properties.
* @param [properties] Properties to set
* @returns TestResultData instance
*/
public static create(properties?: blaze.ITestResultData): blaze.TestResultData;

/**
* Encodes the specified TestResultData message. Does not implicitly {@link blaze.TestResultData.verify|verify} messages.
* @param message TestResultData message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: blaze.ITestResultData, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Encodes the specified TestResultData message, length delimited. Does not implicitly {@link blaze.TestResultData.verify|verify} messages.
* @param message TestResultData message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: blaze.ITestResultData, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Decodes a TestResultData message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns TestResultData
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): blaze.TestResultData;

/**
* Decodes a TestResultData message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns TestResultData
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): blaze.TestResultData;

/**
* Verifies a TestResultData message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);

/**
* Creates a TestResultData message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns TestResultData
*/
public static fromObject(object: { [k: string]: any }): blaze.TestResultData;

/**
* Creates a plain object from a TestResultData message. Also converts values to other types if specified.
* @param message TestResultData
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: blaze.TestResultData, options?: $protobuf.IConversionOptions): { [k: string]: any };

/**
* Converts this TestResultData to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}
}
Loading

0 comments on commit 0a83a42

Please sign in to comment.