-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
- Loading branch information
Showing
12 changed files
with
571 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 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 {afterEach, beforeEach, describe, expect, jest, test} from '@jest/globals'; | ||
import path from 'path'; | ||
import * as rimraf from 'rimraf'; | ||
|
||
import {History} from '../../src/buildx/history'; | ||
|
||
const fixturesDir = path.join(__dirname, '..', 'fixtures'); | ||
|
||
// prettier-ignore | ||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-jest'); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
afterEach(function () { | ||
rimraf.sync(tmpDir); | ||
}); | ||
|
||
describe('load', () => { | ||
// prettier-ignore | ||
test.each([ | ||
['crazy-max~docker-alpine-s6~II9A63.dockerbuild'], | ||
['docker~login-action~T0XYYW.dockerbuild'], | ||
['moby~buildkit~LWDOW6.dockerbuild'], | ||
])('loading %p', async (filename) => { | ||
const res = await History.load({ | ||
file: path.join(fixturesDir, 'oci-archive', filename) | ||
}); | ||
// console.log(JSON.stringify(res, null, 2)); | ||
expect(res).toBeDefined(); | ||
}); | ||
}); |
Binary file added
BIN
+24.7 KB
__tests__/fixtures/oci-archive/docker~login-action~T0XYYW.dockerbuild
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
export const ANNOTATION_REF_KEY = 'vnd.buildkit.history.reference'; | ||
|
||
export const MEDIATYPE_SOLVE_STATUS_V0 = 'application/vnd.buildkit.solvestatus.v0'; | ||
|
||
export const MEDIATYPE_HISTORY_RECORD_V0 = 'application/vnd.buildkit.historyrecord.v0'; | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/solver/llbsolver/history.go#L672 | ||
export const MEDIATYPE_STATUS_V0 = 'application/vnd.buildkit.status.v0'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/593aad1ea909b978d2c54fef2a138c6d3a9107e6/client/graph.go#L10-L19 | ||
export interface Vertex { | ||
digest?: Digest; | ||
inputs?: Array<Digest>; | ||
name?: string; | ||
started?: Date; | ||
completed?: Date; | ||
cached?: boolean; | ||
error?: string; | ||
progressGroup?: ProgressGroup; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/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/593aad1ea909b978d2c54fef2a138c6d3a9107e6/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/593aad1ea909b978d2c54fef2a138c6d3a9107e6/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<any>; | ||
url?: string; | ||
|
||
sourceInfo?: SourceInfo; | ||
range?: Range[]; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/client/graph.go#L50-L55 | ||
export interface SolveStatus { | ||
vertexes?: Vertex[]; | ||
statuses?: VertexStatus[]; | ||
logs?: VertexLog[]; | ||
warnings?: VertexWarning[]; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/client/graph.go#L57-L60 | ||
export interface SolveResponse { | ||
exporterResponse: Record<string, string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/593aad1ea909b978d2c54fef2a138c6d3a9107e6/api/services/control/control.pb.go#L1504-L1525 | ||
export interface BuildHistoryRecord { | ||
Ref: string; | ||
Frontend: string; | ||
FrontendAttrs: Record<string, string>; | ||
Exporters: Exporter[]; | ||
error?: RpcStatus; | ||
CreatedAt?: Date; | ||
CompletedAt?: Date; | ||
logs?: Descriptor; | ||
ExporterResponse: Record<string, string>; | ||
Result?: BuildResultInfo; | ||
Results: Record<string, BuildResultInfo>; | ||
Generation: number; | ||
trace?: Descriptor; | ||
pinned: boolean; | ||
numCachedSteps: number; | ||
numTotalSteps: number; | ||
numCompletedSteps: number; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/api/services/control/control.pb.go#L1909-L1917 | ||
export interface Exporter { | ||
Type: string; | ||
Attrs: Record<string, string>; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/api/services/control/control.pb.go#L1845-L1852 | ||
export interface BuildResultInfo { | ||
ResultDeprecated?: Descriptor; | ||
Attestations?: Descriptor[]; | ||
Results?: Record<number, Descriptor>; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/api/services/control/control.pb.go#L751-L759 | ||
export interface StatusResponse { | ||
vertexes?: Vertex[]; | ||
statuses?: VertexStatus[]; | ||
logs?: VertexLog[]; | ||
warnings?: VertexWarning[]; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/api/services/control/control.pb.go#L822-L834 | ||
export interface Vertex { | ||
digest: Digest; | ||
inputs: Digest[]; | ||
name?: string; | ||
cached?: boolean; | ||
started?: Date; | ||
completed?: Date; | ||
error?: string; | ||
progressGroup?: ProgressGroup; | ||
} | ||
|
||
// https://github.com/moby/buildkit/blob/593aad1ea909b978d2c54fef2a138c6d3a9107e6/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/593aad1ea909b978d2c54fef2a138c6d3a9107e6/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/593aad1ea909b978d2c54fef2a138c6d3a9107e6/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?: any[]; | ||
url?: string; | ||
info?: SourceInfo; | ||
ranges?: Range[]; | ||
} |
Oops, something went wrong.