@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe , expect , jest , test } from '@jest/globals' ;
import { beforeEach, describe , expect , jest , test } from '@jest/globals' ;
import * as fs from 'fs' ;
import * as fs from 'fs' ;
import * as path from 'path' ;
import * as path from 'path' ;
@ -68,7 +68,6 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
} ) ;
} ) ;
describe ( 'getArgs' , ( ) = > {
describe ( 'getArgs' , ( ) = > {
const originalEnv = process . env ;
beforeEach ( ( ) = > {
beforeEach ( ( ) = > {
process . env = Object . keys ( process . env ) . reduce ( ( object , key ) = > {
process . env = Object . keys ( process . env ) . reduce ( ( object , key ) = > {
if ( ! key . startsWith ( 'INPUT_' ) ) {
if ( ! key . startsWith ( 'INPUT_' ) ) {
@ -77,9 +76,6 @@ describe('getArgs', () => {
return object ;
return object ;
} , { } ) ;
} , { } ) ;
} ) ;
} ) ;
afterEach ( ( ) = > {
process . env = originalEnv ;
} ) ;
// prettier-ignore
// prettier-ignore
test . each ( [
test . each ( [
@ -97,8 +93,7 @@ describe('getArgs', () => {
'build' ,
'build' ,
'--iidfile' , imageIDFilePath ,
'--iidfile' , imageIDFilePath ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
1 ,
1 ,
@ -121,8 +116,7 @@ ccc"`],
'--build-arg' , ` MULTILINE=aaaa \ nbbbb \ nccc ` ,
'--build-arg' , ` MULTILINE=aaaa \ nbbbb \ nccc ` ,
'--iidfile' , imageIDFilePath ,
'--iidfile' , imageIDFilePath ,
'https://github.com/docker/build-push-action.git#refs/heads/master'
'https://github.com/docker/build-push-action.git#refs/heads/master'
] ,
]
undefined
] ,
] ,
[
[
2 ,
2 ,
@ -140,8 +134,7 @@ ccc"`],
'--tag' , 'name/app:7.4' ,
'--tag' , 'name/app:7.4' ,
'--tag' , 'name/app:latest' ,
'--tag' , 'name/app:latest' ,
'https://github.com/docker/build-push-action.git#refs/heads/master'
'https://github.com/docker/build-push-action.git#refs/heads/master'
] ,
]
undefined
] ,
] ,
[
[
3 ,
3 ,
@ -161,8 +154,7 @@ ccc"`],
'--label' , 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit' ,
'--label' , 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit' ,
'--output' , 'type=local,dest=./release-out' ,
'--output' , 'type=local,dest=./release-out' ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
4 ,
4 ,
@ -179,8 +171,7 @@ ccc"`],
'build' ,
'build' ,
'--platform' , 'linux/amd64,linux/arm64' ,
'--platform' , 'linux/amd64,linux/arm64' ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
5 ,
5 ,
@ -196,8 +187,7 @@ ccc"`],
'build' ,
'build' ,
'--iidfile' , imageIDFilePath ,
'--iidfile' , imageIDFilePath ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
6 ,
6 ,
@ -215,8 +205,7 @@ ccc"`],
'--iidfile' , imageIDFilePath ,
'--iidfile' , imageIDFilePath ,
'--secret' , ` id=GIT_AUTH_TOKEN,src= ${ tmpName } ` ,
'--secret' , ` id=GIT_AUTH_TOKEN,src= ${ tmpName } ` ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
7 ,
7 ,
@ -234,8 +223,7 @@ ccc"`],
'--output' , '.' ,
'--output' , '.' ,
'--secret' , ` id=GIT_AUTH_TOKEN,src= ${ tmpName } ` ,
'--secret' , ` id=GIT_AUTH_TOKEN,src= ${ tmpName } ` ,
'https://github.com/docker/build-push-action.git#refs/heads/master'
'https://github.com/docker/build-push-action.git#refs/heads/master'
] ,
]
undefined
] ,
] ,
[
[
8 ,
8 ,
@ -261,8 +249,7 @@ ccc"`],
'--builder' , 'builder-git-context-2' ,
'--builder' , 'builder-git-context-2' ,
'--push' ,
'--push' ,
'https://github.com/docker/build-push-action.git#refs/heads/master'
'https://github.com/docker/build-push-action.git#refs/heads/master'
] ,
]
undefined
] ,
] ,
[
[
9 ,
9 ,
@ -299,8 +286,7 @@ ccc"`],
'--builder' , 'builder-git-context-2' ,
'--builder' , 'builder-git-context-2' ,
'--push' ,
'--push' ,
'https://github.com/docker/build-push-action.git#refs/heads/master'
'https://github.com/docker/build-push-action.git#refs/heads/master'
] ,
]
undefined
] ,
] ,
[
[
10 ,
10 ,
@ -337,8 +323,7 @@ ccc`],
'--builder' , 'builder-git-context-2' ,
'--builder' , 'builder-git-context-2' ,
'--push' ,
'--push' ,
'https://github.com/docker/build-push-action.git#refs/heads/master'
'https://github.com/docker/build-push-action.git#refs/heads/master'
] ,
]
undefined
] ,
] ,
[
[
11 ,
11 ,
@ -364,8 +349,7 @@ ccc`],
'--network' , 'host' ,
'--network' , 'host' ,
'--push' ,
'--push' ,
'https://github.com/docker/build-push-action.git#refs/heads/master'
'https://github.com/docker/build-push-action.git#refs/heads/master'
] ,
]
undefined
] ,
] ,
[
[
12 ,
12 ,
@ -385,8 +369,7 @@ ccc`],
'--label' , 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"' ,
'--label' , 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"' ,
'--output' , 'type=local,dest=./release-out' ,
'--output' , 'type=local,dest=./release-out' ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
13 ,
13 ,
@ -412,8 +395,7 @@ ccc`],
'--network' , 'host' ,
'--network' , 'host' ,
'--push' ,
'--push' ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
14 ,
14 ,
@ -443,8 +425,7 @@ nproc=3`],
'--ulimit' , 'nproc=3' ,
'--ulimit' , 'nproc=3' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
15 ,
15 ,
@ -461,8 +442,7 @@ nproc=3`],
'--iidfile' , imageIDFilePath ,
'--iidfile' , imageIDFilePath ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'https://github.com/docker/build-push-action.git#refs/heads/master:docker'
'https://github.com/docker/build-push-action.git#refs/heads/master:docker'
] ,
]
undefined
] ,
] ,
[
[
16 ,
16 ,
@ -481,8 +461,7 @@ nproc=3`],
'--secret' , ` id=GIT_AUTH_TOKEN,src= ${ tmpName } ` ,
'--secret' , ` id=GIT_AUTH_TOKEN,src= ${ tmpName } ` ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir'
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir'
] ,
]
undefined
] ,
] ,
[
[
17 ,
17 ,
@ -500,8 +479,7 @@ nproc=3`],
'--iidfile' , imageIDFilePath ,
'--iidfile' , imageIDFilePath ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
18 ,
18 ,
@ -519,8 +497,7 @@ nproc=3`],
'--attest' , ` type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--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 ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
19 ,
19 ,
@ -539,8 +516,7 @@ nproc=3`],
'--attest' , ` type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--attest' , ` type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
20 ,
20 ,
@ -559,8 +535,7 @@ nproc=3`],
'--attest' , ` type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--attest' , ` type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
21 ,
21 ,
@ -579,8 +554,7 @@ nproc=3`],
'--attest' , 'type=provenance,disabled=true' ,
'--attest' , 'type=provenance,disabled=true' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
22 ,
22 ,
@ -599,8 +573,7 @@ nproc=3`],
'--attest' , 'type=provenance,builder-id=foo' ,
'--attest' , 'type=provenance,builder-id=foo' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
23 ,
23 ,
@ -619,8 +592,7 @@ nproc=3`],
"--output" , 'type=docker' ,
"--output" , 'type=docker' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
24 ,
24 ,
@ -638,8 +610,7 @@ nproc=3`],
'--load' ,
'--load' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
25 ,
25 ,
@ -659,8 +630,7 @@ nproc=3`],
'--load' ,
'--load' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
26 ,
26 ,
@ -682,8 +652,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load' ,
'--load' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
27 ,
27 ,
@ -704,8 +673,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load' ,
'--load' ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
28 ,
28 ,
@ -725,8 +693,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest' , ` type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--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 ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
29 ,
29 ,
@ -750,8 +717,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest' , ` type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--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 ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
30 ,
30 ,
@ -771,8 +737,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest' , ` type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--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 ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
31 ,
31 ,
@ -793,8 +758,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest' , ` type=sbom,disabled=false ` ,
'--attest' , ` type=sbom,disabled=false ` ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
32 ,
32 ,
@ -814,8 +778,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest' , ` type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--attest' , ` type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--metadata-file' , metadataJson ,
'--metadata-file' , metadataJson ,
'.'
'.'
] ,
]
undefined
] ,
] ,
[
[
33 ,
33 ,
@ -834,37 +797,11 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest' , ` type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--attest' , ` type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1 ` ,
'--metadata-file' , metadataJson ,
'--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' ]
] )
] ,
] ,
] ) (
] ) (
'[%d] given %p with %p as inputs, returns %p' ,
'[%d] given %p with %p as inputs, returns %p' ,
async ( num : number , buildxVersion : string , inputs : Map < string , string > , expected : Array < string > , envs : Map < string , string > | undefined ) = > {
async ( num : number , buildxVersion : string , inputs : Map < string , string > , expected : Array < string > ) = > {
if ( envs ) {
envs . forEach ( ( value : string , name : string ) = > {
process . env [ name ] = value ;
} ) ;
}
inputs . forEach ( ( value : string , name : string ) = > {
inputs . forEach ( ( value : string , name : string ) = > {
setInput ( name , value ) ;
setInput ( name , value ) ;
} ) ;
} ) ;