fixes related to actions-toolkit 0.23.0 changes

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2024-05-14 14:02:37 +02:00
parent 66ac74c2bc
commit 1bc598cbb8
3 changed files with 20 additions and 16 deletions

View File

@ -39,6 +39,11 @@ jest.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean>
return true;
});
const metadataJson = path.join(tmpDir, 'metadata.json');
jest.spyOn(Bake.prototype, 'getMetadataFilePath').mockImplementation((): string => {
return metadataJson;
});
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
return {
name: 'builder2',
@ -152,7 +157,7 @@ describe('getArgs', () => {
]),
[
'bake',
'--metadata-file', path.join(tmpDir, 'metadata-file')
'--metadata-file', metadataJson
]
],
[
@ -167,7 +172,7 @@ describe('getArgs', () => {
]),
[
'bake',
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
'webapp', 'validate'
]
],
@ -185,7 +190,7 @@ describe('getArgs', () => {
'bake',
'--set', '*.cache-from=type=gha',
'--set', '*.cache-to=type=gha',
'--metadata-file', path.join(tmpDir, 'metadata-file')
'--metadata-file', metadataJson
]
],
[
@ -199,7 +204,7 @@ describe('getArgs', () => {
]),
[
'bake',
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
]
],
@ -215,7 +220,7 @@ describe('getArgs', () => {
]),
[
'bake',
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
]
],
@ -231,7 +236,7 @@ describe('getArgs', () => {
]),
[
'bake',
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
"--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
]
],
@ -247,7 +252,7 @@ describe('getArgs', () => {
]),
[
'bake',
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
"--provenance", 'false'
]
],
@ -263,7 +268,7 @@ describe('getArgs', () => {
]),
[
'bake',
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
"--provenance", 'builder-id=foo'
]
],
@ -282,7 +287,7 @@ describe('getArgs', () => {
'bake',
'--set', '*.platform=linux/amd64,linux/ppc64le,linux/s390x',
'--set', `*.output=type=image,"name=moby/buildkit:v0.11.0,moby/buildkit:latest",push=true`,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'image-all'
]
@ -301,7 +306,7 @@ describe('getArgs', () => {
[
'bake',
'--set', `*.labels.foo=bar=#baz`,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'image-all'
]
@ -321,7 +326,7 @@ describe('getArgs', () => {
'bake',
'https://github.com/docker/build-push-action.git#refs/heads/master',
'--file', './foo.hcl',
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--metadata-file', metadataJson,
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
]
],
@ -336,7 +341,7 @@ describe('getArgs', () => {
return buildxVersion;
});
const inp = await context.getInputs();
const definition = await toolkit.bake.getDefinition(
const definition = await toolkit.buildxBake.getDefinition(
{
files: inp.files,
load: inp.load,

View File

@ -65,7 +65,7 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
args.push('--set', set);
});
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
args.push('--metadata-file', Bake.getMetadataFilePath());
args.push('--metadata-file', toolkit.buildxBake.getMetadataFilePath());
}
if (await toolkit.buildx.versionSatisfies('>=0.10.0')) {
if (inputs.provenance) {

View File

@ -3,7 +3,6 @@ import * as path from 'path';
import * as core from '@actions/core';
import * as actionsToolkit from '@docker/actions-toolkit';
import {Bake} from '@docker/actions-toolkit/lib/buildx/bake';
import {Context} from '@docker/actions-toolkit/lib/context';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {Exec} from '@docker/actions-toolkit/lib/exec';
@ -78,7 +77,7 @@ actionsToolkit.run(
let definition: BakeDefinition | undefined;
await core.group(`Parsing raw definition`, async () => {
definition = await toolkit.bake.getDefinition(
definition = await toolkit.buildxBake.getDefinition(
{
files: inputs.files,
load: inputs.load,
@ -125,7 +124,7 @@ actionsToolkit.run(
}
});
const metadata = Bake.resolveMetadata();
const metadata = toolkit.buildxBake.resolveMetadata();
if (metadata) {
await core.group(`Metadata`, async () => {
const metadatadt = JSON.stringify(metadata, null, 2);