mirror docker/build-push-action@v6

This commit is contained in:
action-mirror
2026-09-13 22:53:17 +08:00
parent bae744bbe6
commit 88c60f4d61
32 changed files with 4405 additions and 3714 deletions
+156 -47
View File
@@ -1,4 +1,4 @@
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import {afterEach, beforeEach, describe, expect, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
@@ -68,6 +68,7 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
});
describe('getArgs', () => {
const originalEnv = process.env;
beforeEach(() => {
process.env = Object.keys(process.env).reduce((object, key) => {
if (!key.startsWith('INPUT_')) {
@@ -76,6 +77,9 @@ describe('getArgs', () => {
return object;
}, {});
});
afterEach(() => {
process.env = originalEnv;
});
// prettier-ignore
test.each([
@@ -93,7 +97,8 @@ describe('getArgs', () => {
'build',
'--iidfile', imageIDFilePath,
'.'
]
],
undefined
],
[
1,
@@ -116,7 +121,8 @@ ccc"`],
'--build-arg', `MULTILINE=aaaa\nbbbb\nccc`,
'--iidfile', imageIDFilePath,
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
undefined
],
[
2,
@@ -134,7 +140,8 @@ ccc"`],
'--tag', 'name/app:7.4',
'--tag', 'name/app:latest',
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
undefined
],
[
3,
@@ -154,7 +161,8 @@ ccc"`],
'--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit',
'--output', 'type=local,dest=./release-out',
'.'
]
],
undefined
],
[
4,
@@ -171,7 +179,8 @@ ccc"`],
'build',
'--platform', 'linux/amd64,linux/arm64',
'.'
]
],
undefined
],
[
5,
@@ -187,7 +196,8 @@ ccc"`],
'build',
'--iidfile', imageIDFilePath,
'.'
]
],
undefined
],
[
6,
@@ -205,7 +215,8 @@ ccc"`],
'--iidfile', imageIDFilePath,
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'.'
]
],
undefined
],
[
7,
@@ -221,9 +232,10 @@ ccc"`],
[
'build',
'--output', '.',
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--secret', `id=GIT_AUTH_TOKEN.github.com,src=${tmpName}`,
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
undefined
],
[
8,
@@ -249,7 +261,8 @@ ccc"`],
'--builder', 'builder-git-context-2',
'--push',
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
undefined
],
[
9,
@@ -286,7 +299,8 @@ ccc"`],
'--builder', 'builder-git-context-2',
'--push',
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
undefined
],
[
10,
@@ -323,7 +337,8 @@ ccc`],
'--builder', 'builder-git-context-2',
'--push',
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
undefined
],
[
11,
@@ -349,7 +364,8 @@ ccc`],
'--network', 'host',
'--push',
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
undefined
],
[
12,
@@ -369,7 +385,8 @@ ccc`],
'--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"',
'--output', 'type=local,dest=./release-out',
'.'
]
],
undefined
],
[
13,
@@ -395,7 +412,8 @@ ccc`],
'--network', 'host',
'--push',
'.'
]
],
undefined
],
[
14,
@@ -425,7 +443,8 @@ nproc=3`],
'--ulimit', 'nproc=3',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
15,
@@ -442,7 +461,8 @@ nproc=3`],
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'https://github.com/docker/build-push-action.git#refs/heads/master:docker'
]
],
undefined
],
[
16,
@@ -458,10 +478,11 @@ nproc=3`],
[
'build',
'--iidfile', imageIDFilePath,
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--secret', `id=GIT_AUTH_TOKEN.github.com,src=${tmpName}`,
'--metadata-file', metadataJson,
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir'
]
],
undefined
],
[
17,
@@ -479,7 +500,8 @@ nproc=3`],
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
18,
@@ -494,10 +516,11 @@ nproc=3`],
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
19,
@@ -513,10 +536,11 @@ nproc=3`],
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
20,
@@ -532,10 +556,11 @@ nproc=3`],
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
21,
@@ -554,7 +579,8 @@ nproc=3`],
'--attest', 'type=provenance,disabled=true',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
22,
@@ -573,7 +599,8 @@ nproc=3`],
'--attest', 'type=provenance,builder-id=foo',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
23,
@@ -592,7 +619,8 @@ nproc=3`],
"--output", 'type=docker',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
24,
@@ -610,7 +638,8 @@ nproc=3`],
'--load',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
25,
@@ -630,7 +659,8 @@ nproc=3`],
'--load',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
26,
@@ -652,7 +682,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
27,
@@ -673,7 +704,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load',
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
28,
@@ -690,10 +722,11 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
[
'build',
'--output', 'type=local,dest=./release-out',
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
29,
@@ -714,10 +747,11 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--annotation', 'manifest:example3=yyy',
'--annotation', 'manifest-descriptor[linux/amd64]:example4=zzz',
'--output', 'type=local,dest=./release-out',
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
30,
@@ -734,10 +768,11 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'build',
'--iidfile', imageIDFilePath,
"--output", `type=image,"name=localhost:5000/name/app:latest,localhost:5000/name/app:foo",push-by-digest=true,name-canonical=true,push=true`,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
31,
@@ -754,11 +789,12 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--attest', `type=sbom,disabled=false`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
32,
@@ -775,10 +811,11 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
33,
@@ -794,14 +831,86 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson,
'.'
]
],
undefined
],
[
34,
'0.13.1',
new Map<string, string>([
['context', '.'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]),
[
'build',
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'.'
],
new Map<string, string>([
['BUILDX_NO_DEFAULT_ATTESTATIONS', '1']
])
],
[
35,
'0.13.1',
new Map<string, string>([
['github-token', 'abcdefghijklmno0123456789'],
['context', '{{defaultContext}}'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=http://10.0.0.5:22827/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--secret', `id=GIT_AUTH_TOKEN.10.0.0.5:22827,src=${tmpName}`,
'--metadata-file', metadataJson,
'http://10.0.0.5:22827/docker/build-push-action.git#refs/heads/master'
],
new Map<string, string>([
['GITHUB_SERVER_URL', 'http://10.0.0.5:22827'],
])
],
[
36,
'0.13.1',
new Map<string, string>([
['github-token', 'abcdefghijklmno0123456789'],
['context', '{{defaultContext}}'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.cds.internal.unity3d.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--secret', `id=GIT_AUTH_TOKEN.github.cds.internal.unity3d.com,src=${tmpName}`,
'--metadata-file', metadataJson,
'https://github.cds.internal.unity3d.com/docker/build-push-action.git#refs/heads/master'
],
new Map<string, string>([
['GITHUB_SERVER_URL', 'https://github.cds.internal.unity3d.com'],
])
],
])(
'[%d] given %p with %p as inputs, returns %p',
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, envs: Map<string, string> | undefined) => {
if (envs) {
envs.forEach((value: string, name: string) => {
process.env[name] = value;
});
}
inputs.forEach((value: string, name: string) => {
setInput(name, value);
});