diff --git a/entity/BUILD.bazel b/entity/BUILD.bazel index 616ea5c2..0a562dbb 100644 --- a/entity/BUILD.bazel +++ b/entity/BUILD.bazel @@ -5,6 +5,7 @@ go_library( srcs = [ "batch.go", "batch_dependent.go", + "build.go", "change_provider.go", "request.go", ], diff --git a/entity/build.go b/entity/build.go new file mode 100644 index 00000000..26d23754 --- /dev/null +++ b/entity/build.go @@ -0,0 +1,34 @@ +package entity + +// BuildStatus defines the possible states of a build. +type BuildStatus string + +const ( + // BuildStateUnknown is the unreachable state. It is set by default when the structure is initialized. It should never be seen in the system. + BuildStateUnknown BuildStatus = "" + // TODO: Add comprehensive list of known build states. +) + +// SpeculationPathInfo represents the base and head commits of a speculation path used in a build. +type SpeculationPathInfo struct { + // Base is a list of batchIDs(in order) that form the base of this speculation path. + Base []string +} + +// Build represents a build scheduled for a batch along a specific speculation path. +// All fields except the Status are immutable after creation. +type Build struct { + // ID represents the build ID. It is the responsibility of a build management system to ensure + // that this is unique. + ID string + // BatchID is the batch for which this build is scheduled. + BatchID string + // SpeculationPath is the speculation path that represents this build. For + // a given batch this path is crafted from the graph that is generated from the + // dependencies of this batch. + SpeculationPath SpeculationPathInfo + // Score represents the build prediction score for this speculation path. + Score float32 + // Status represents the state of the build lifecycle this build is in. + Status BuildStatus +} diff --git a/extension/storage/mysql/schema/build.sql b/extension/storage/mysql/schema/build.sql new file mode 100644 index 00000000..93bc5744 --- /dev/null +++ b/extension/storage/mysql/schema/build.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS build ( + id VARCHAR(255) NOT NULL, + batch_id VARCHAR(255) NOT NULL, + speculation_path JSON NOT NULL, + score FLOAT NOT NULL, + status VARCHAR(64) NOT NULL, + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;