# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: executed_tests.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import List

import betterproto


@dataclass
class Digest(betterproto.Message):
    """Taken directly from the bazel reapi, for compat"""

    # The hash. In the case of SHA-256, it will always be a lowercase hex string
    # exactly 64 characters long. in expectation, this should always be the
    # sha256
    hash: str = betterproto.string_field(1)
    # The size of the blob, in bytes.
    size_bytes: int = betterproto.int64_field(2)


@dataclass
class ArtifactPointer(betterproto.Message):
    cas_hash: "Digest" = betterproto.message_field(1, group="pointer")
    path: str = betterproto.string_field(2, group="pointer")
    artifact_name: str = betterproto.string_field(3)


@dataclass
class TrackedTestResult(betterproto.Message):
    # same key from Invocation -- maps this test to a particular repo, branch,
    # and commit
    invoke_id: str = betterproto.string_field(1)
    # test definition id -- unique id to track the test across different
    # Invocations, useful for test history
    test_def_id: str = betterproto.string_field(2)
    # cli reproduction -- how can you re-run this test?
    repro_command: str = betterproto.string_field(3)
    result: "TestResult" = betterproto.message_field(4)


@dataclass
class TestResult(betterproto.Message):
    """
    The serialized record of single test execution This is the api that we
    should build tools around -- if people provide tracked tests
    """

    # name of the test
    test_name: str = betterproto.string_field(1)
    outputs: "TestOutputs" = betterproto.message_field(2)


@dataclass
class TestOutputs(betterproto.Message):
    # Files that are expected from a test
    artifacts: List["ArtifactPointer"] = betterproto.message_field(1)
    # exit code of the test
    exit_code: int = betterproto.int32_field(2)


@dataclass
class Invocation(betterproto.Message):
    """
    Highest level invocation for a set of tests -- must contain one or more
    test results any time we run any test(s), an invocation object is created
    """

    invoke_id: str = betterproto.string_field(1)
    rundate: str = betterproto.string_field(2)
    user: str = betterproto.string_field(3)
    repo: str = betterproto.string_field(4)
    branch: str = betterproto.string_field(5)
    hostname: str = betterproto.string_field(6)
    executed_tests: List["TrackedTestResult"] = betterproto.message_field(8)
