diff --git a/src/types/buildkit/buildkit.ts b/src/types/buildkit/buildkit.ts new file mode 100644 index 00000000..04d0ff52 --- /dev/null +++ b/src/types/buildkit/buildkit.ts @@ -0,0 +1,18 @@ +/** + * Copyright 2024 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/llbsolver/history.go#L672 +export const MEDIATYPE_STATUS_V0 = 'application/vnd.buildkit.status.v0'; diff --git a/src/types/buildkit/client.ts b/src/types/buildkit/client.ts new file mode 100644 index 00000000..0a913426 --- /dev/null +++ b/src/types/buildkit/client.ts @@ -0,0 +1,78 @@ +/** + * Copyright 2024 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {Digest} from '../oci/digest'; +import {ProgressGroup, Range, SourceInfo} from './ops'; + +// https://github.com/moby/buildkit/blob/v0.14.0/client/graph.go#L10-L19 +export interface Vertex { + digest?: Digest; + inputs?: Array; + name?: string; + started?: Date; + completed?: Date; + cached?: boolean; + error?: string; + progressGroup?: ProgressGroup; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/client/graph.go#L21-L30 +export interface VertexStatus { + id: string; + vertex?: Digest; + name?: string; + total?: number; + current: number; + timestamp?: Date; + started?: Date; + completed?: Date; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/client/graph.go#L32-L37 +export interface VertexLog { + vertex?: Digest; + stream?: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + data: any; + timestamp: Date; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/client/graph.go#L39-L48 +export interface VertexWarning { + vertex?: Digest; + level?: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + short?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + detail?: Array; + url?: string; + + sourceInfo?: SourceInfo; + range?: Array; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/client/graph.go#L50-L55 +export interface SolveStatus { + vertexes?: Array; + statuses?: Array; + logs?: Array; + warnings?: Array; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/client/graph.go#L57-L60 +export interface SolveResponse { + exporterResponse: Record; +} diff --git a/src/types/buildkit/control.ts b/src/types/buildkit/control.ts new file mode 100644 index 00000000..3d3f157a --- /dev/null +++ b/src/types/buildkit/control.ts @@ -0,0 +1,108 @@ +/** + * Copyright 2024 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {Descriptor} from '../oci/descriptor'; +import {Digest} from '../oci/digest'; +import {ProgressGroup, Range, SourceInfo} from './ops'; +import {RpcStatus} from './rpc'; + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L1504-L1525 +export interface BuildHistoryRecord { + Ref: string; + Frontend: string; + FrontendAttrs: Record; + Exporters: Array; + error?: RpcStatus; + CreatedAt?: Date; + CompletedAt?: Date; + logs?: Descriptor; + ExporterResponse: Record; + Result?: BuildResultInfo; + Results: Record; + Generation: number; + trace?: Descriptor; + pinned: boolean; + numCachedSteps: number; + numTotalSteps: number; + numCompletedSteps: number; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L1909-L1917 +export interface Exporter { + Type: string; + Attrs: Record; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L1845-L1852 +export interface BuildResultInfo { + ResultDeprecated?: Descriptor; + Attestations?: Array; + Results?: Record; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L751-L759 +export interface StatusResponse { + vertexes?: Array; + statuses?: Array; + logs?: Array; + warnings?: Array; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L822-L834 +export interface Vertex { + digest: Digest; + inputs: Array; + name?: string; + cached?: boolean; + started?: Date; + completed?: Date; + error?: string; + progressGroup?: ProgressGroup; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L911-L923 +export interface VertexStatus { + ID?: string; + vertex: Digest; + name?: string; + current?: number; + total?: number; + timestamp: Date; + started?: Date; + completed?: Date; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L1007-L1015 +export interface VertexLog { + vertex: Digest; + timestamp: Date; + stream?: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + msg?: any; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/api/services/control/control.pb.go#L1071-L1082 +export interface VertexWarning { + vertex: Digest; + level?: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + short?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + detail?: Array; + url?: string; + info?: SourceInfo; + ranges?: Array; +} diff --git a/src/types/buildkit/ops.ts b/src/types/buildkit/ops.ts new file mode 100644 index 00000000..9c8d40fe --- /dev/null +++ b/src/types/buildkit/ops.ts @@ -0,0 +1,82 @@ +/** + * Copyright 2024 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1901-L1909 +export interface Definition { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + def?: Array; + metadata: Record; + Source?: Source; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1313-L1323 +export interface OpMetadata { + ignore_cache?: boolean; + description?: Record; + export_cache?: ExportCache; + caps: Record; + progress_group?: ProgressGroup; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1390-L1393 +export interface Source { + locations?: Record; + infos?: Array; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1439-L1441 +export interface Locations { + locations?: Array; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1545-L1548 +export interface Location { + sourceIndex?: number; + ranges?: Array; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1594-L1597 +export interface Range { + start: Position; + end: Position; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1643-L1646 +export interface Position { + line: number; + character: number; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1480-L1485 +export interface SourceInfo { + filename?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + data?: any; + definition?: Definition; + language?: string; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1691-L1693 +export interface ExportCache { + Value?: boolean; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/solver/pb/ops.pb.go#L1731-L1735 +export interface ProgressGroup { + id?: string; + name?: string; + weak?: boolean; +} diff --git a/src/types/buildkit/rpc.ts b/src/types/buildkit/rpc.ts new file mode 100644 index 00000000..55f48dde --- /dev/null +++ b/src/types/buildkit/rpc.ts @@ -0,0 +1,31 @@ +/** + * Copyright 2024 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// https://github.com/moby/buildkit/blob/v0.14.0/vendor/github.com/gogo/googleapis/google/rpc/status.pb.go#L36-L49 +export interface RpcStatus { + code: number; + message: string; + details: Array; +} + +// https://github.com/moby/buildkit/blob/v0.14.0/vendor/github.com/gogo/protobuf/types/any.pb.go#L108-L143 +// Define properties based on google.protobuf.Any. For simplicity, assuming it +// has at least a type_url and a value. +export interface RpcAny { + type_url: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + value: any; +}