Skip to content

Commit 91274a0

Browse files
committed
sort flags
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 04841f2 commit 91274a0

File tree

4 files changed

+89
-98
lines changed

4 files changed

+89
-98
lines changed

__tests__/buildx.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,17 @@ jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
2828
describe('getImageID', () => {
2929
it('matches', async () => {
3030
const imageIDFile = await buildx.getImageIDFile();
31-
console.log(`imageIDFile: ${imageIDFile}`);
3231
await fs.writeFileSync(imageIDFile, digest);
3332
const imageID = await buildx.getImageID();
34-
console.log(`imageID: ${imageID}`);
3533
expect(imageID).toEqual(digest);
3634
});
3735
});
3836

3937
describe('getMetadata', () => {
4038
it('matches', async () => {
4139
const metadataFile = await buildx.getMetadataFile();
42-
console.log(`metadataFile: ${metadataFile}`);
4340
await fs.writeFileSync(metadataFile, metadata);
4441
const expected = await buildx.getMetadata();
45-
console.log(`metadata: ${expected}`);
4642
expect(expected).toEqual(metadata);
4743
});
4844
});
@@ -132,7 +128,6 @@ describe('getVersion', () => {
132128
'valid',
133129
async () => {
134130
const version = await buildx.getVersion();
135-
console.log(`version: ${version}`);
136131
expect(semver.valid(version)).not.toBeNull();
137132
},
138133
100000
@@ -179,10 +174,8 @@ describe('getSecret', () => {
179174
secret = await buildx.getSecretString(kvp);
180175
}
181176
expect(true).toBe(!invalid);
182-
console.log(`secret: ${secret}`);
183177
expect(secret).toEqual(`id=${exKey},src=${tmpNameSync}`);
184178
const secretValue = await fs.readFileSync(tmpNameSync, 'utf-8');
185-
console.log(`secretValue: ${secretValue}`);
186179
expect(secretValue).toEqual(exValue);
187180
} catch (err) {
188181
expect(true).toBe(invalid);

__tests__/context.test.ts

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ describe('getArgs', () => {
140140
// prettier-ignore
141141
test.each([
142142
[
143+
0,
143144
'0.4.1',
144145
new Map<string, string>([
145146
['context', '.'],
@@ -156,6 +157,7 @@ describe('getArgs', () => {
156157
]
157158
],
158159
[
160+
1,
159161
'0.4.2',
160162
new Map<string, string>([
161163
['build-args', 'MY_ARG=val1,val2,val3\nARG=val'],
@@ -174,6 +176,7 @@ describe('getArgs', () => {
174176
]
175177
],
176178
[
179+
2,
177180
'0.4.2',
178181
new Map<string, string>([
179182
['tags', 'name/app:7.4, name/app:latest'],
@@ -185,13 +188,14 @@ describe('getArgs', () => {
185188
[
186189
'buildx',
187190
'build',
191+
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
188192
'--tag', 'name/app:7.4',
189193
'--tag', 'name/app:latest',
190-
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
191194
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
192195
]
193196
],
194197
[
198+
3,
195199
'0.4.2',
196200
new Map<string, string>([
197201
['context', '.'],
@@ -212,6 +216,7 @@ describe('getArgs', () => {
212216
]
213217
],
214218
[
219+
4,
215220
'0.4.1',
216221
new Map<string, string>([
217222
['context', '.'],
@@ -229,6 +234,7 @@ describe('getArgs', () => {
229234
]
230235
],
231236
[
237+
5,
232238
'0.4.1',
233239
new Map<string, string>([
234240
['context', '.'],
@@ -245,6 +251,7 @@ describe('getArgs', () => {
245251
]
246252
],
247253
[
254+
6,
248255
'0.4.2',
249256
new Map<string, string>([
250257
['context', '.'],
@@ -263,6 +270,7 @@ describe('getArgs', () => {
263270
]
264271
],
265272
[
273+
7,
266274
'0.4.2',
267275
new Map<string, string>([
268276
['github-token', 'abcdefghijklmno0123456789'],
@@ -281,6 +289,7 @@ describe('getArgs', () => {
281289
]
282290
],
283291
[
292+
8,
284293
'0.4.2',
285294
new Map<string, string>([
286295
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
@@ -297,16 +306,17 @@ describe('getArgs', () => {
297306
[
298307
'buildx',
299308
'build',
300-
'--platform', 'linux/amd64,linux/arm64',
309+
'--file', './test/Dockerfile',
301310
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
311+
'--platform', 'linux/amd64,linux/arm64',
302312
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
303-
'--file', './test/Dockerfile',
304313
'--builder', 'builder-git-context-2',
305314
'--push',
306315
'https://github.com/docker/build-push-action.git#refs/heads/master'
307316
]
308317
],
309318
[
319+
9,
310320
'0.4.2',
311321
new Map<string, string>([
312322
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
@@ -331,19 +341,20 @@ ccc"`],
331341
[
332342
'buildx',
333343
'build',
334-
'--platform', 'linux/amd64,linux/arm64',
344+
'--file', './test/Dockerfile',
335345
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
346+
'--platform', 'linux/amd64,linux/arm64',
336347
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
337348
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
338349
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
339350
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
340-
'--file', './test/Dockerfile',
341351
'--builder', 'builder-git-context-2',
342352
'--push',
343353
'https://github.com/docker/build-push-action.git#refs/heads/master'
344354
]
345355
],
346356
[
357+
10,
347358
'0.4.2',
348359
new Map<string, string>([
349360
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
@@ -368,19 +379,20 @@ ccc`],
368379
[
369380
'buildx',
370381
'build',
371-
'--platform', 'linux/amd64,linux/arm64',
382+
'--file', './test/Dockerfile',
372383
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
384+
'--platform', 'linux/amd64,linux/arm64',
373385
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
374386
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
375387
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
376388
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
377-
'--file', './test/Dockerfile',
378389
'--builder', 'builder-git-context-2',
379390
'--push',
380391
'https://github.com/docker/build-push-action.git#refs/heads/master'
381392
]
382393
],
383394
[
395+
11,
384396
'0.5.1',
385397
new Map<string, string>([
386398
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
@@ -397,16 +409,17 @@ ccc`],
397409
[
398410
'buildx',
399411
'build',
412+
'--file', './test/Dockerfile',
400413
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
401414
'--secret', 'id=MY_SECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
402-
'--file', './test/Dockerfile',
403415
'--builder', 'builder-git-context-2',
404416
'--network', 'host',
405417
'--push',
406418
'https://github.com/docker/build-push-action.git#refs/heads/master'
407419
]
408420
],
409421
[
422+
12,
410423
'0.4.2',
411424
new Map<string, string>([
412425
['context', '.'],
@@ -427,6 +440,7 @@ ccc`],
427440
]
428441
],
429442
[
443+
13,
430444
'0.6.0',
431445
new Map<string, string>([
432446
['context', '.'],
@@ -441,25 +455,23 @@ ccc`],
441455
[
442456
'buildx',
443457
'build',
458+
'--file', './test/Dockerfile',
444459
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
445460
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
446-
'--file', './test/Dockerfile',
447461
'--network', 'host',
448462
'--push',
449463
'.'
450464
]
451465
],
452466
])(
453-
'given %p with %p as inputs, returns %p',
454-
async (buildxVersion: string, inputs: Map<string, any>, expected: Array<string>) => {
467+
'[%d] given %p with %p as inputs, returns %p',
468+
async (num: number, buildxVersion: string, inputs: Map<string, any>, expected: Array<string>) => {
455469
await inputs.forEach((value: string, name: string) => {
456470
setInput(name, value);
457471
});
458472
const defContext = context.defaultContext();
459473
const inp = await context.getInputs(defContext);
460-
console.log(inp);
461474
const res = await context.getArgs(inp, defContext, buildxVersion);
462-
console.log(res);
463475
expect(res).toEqual(expected);
464476
}
465477
);
@@ -469,63 +481,54 @@ describe('getInputList', () => {
469481
it('single line correctly', async () => {
470482
await setInput('foo', 'bar');
471483
const res = await context.getInputList('foo');
472-
console.log(res);
473484
expect(res).toEqual(['bar']);
474485
});
475486

476487
it('multiline correctly', async () => {
477488
setInput('foo', 'bar\nbaz');
478489
const res = await context.getInputList('foo');
479-
console.log(res);
480490
expect(res).toEqual(['bar', 'baz']);
481491
});
482492

483493
it('empty lines correctly', async () => {
484494
setInput('foo', 'bar\n\nbaz');
485495
const res = await context.getInputList('foo');
486-
console.log(res);
487496
expect(res).toEqual(['bar', 'baz']);
488497
});
489498

490499
it('comma correctly', async () => {
491500
setInput('foo', 'bar,baz');
492501
const res = await context.getInputList('foo');
493-
console.log(res);
494502
expect(res).toEqual(['bar', 'baz']);
495503
});
496504

497505
it('empty result correctly', async () => {
498506
setInput('foo', 'bar,baz,');
499507
const res = await context.getInputList('foo');
500-
console.log(res);
501508
expect(res).toEqual(['bar', 'baz']);
502509
});
503510

504511
it('different new lines correctly', async () => {
505512
setInput('foo', 'bar\r\nbaz');
506513
const res = await context.getInputList('foo');
507-
console.log(res);
508514
expect(res).toEqual(['bar', 'baz']);
509515
});
510516

511517
it('different new lines and comma correctly', async () => {
512518
setInput('foo', 'bar\r\nbaz,bat');
513519
const res = await context.getInputList('foo');
514-
console.log(res);
515520
expect(res).toEqual(['bar', 'baz', 'bat']);
516521
});
517522

518523
it('multiline and ignoring comma correctly', async () => {
519524
setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir');
520525
const res = await context.getInputList('cache-from', true);
521-
console.log(res);
522526
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
523527
});
524528

525529
it('different new lines and ignoring comma correctly', async () => {
526530
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
527531
const res = await context.getInputList('cache-from', true);
528-
console.log(res);
529532
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
530533
});
531534

@@ -539,7 +542,6 @@ ccccccccc"
539542
FOO=bar`
540543
);
541544
const res = await context.getInputList('secrets', true);
542-
console.log(res);
543545
expect(res).toEqual([
544546
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
545547
`MYSECRET=aaaaaaaa
@@ -563,7 +565,6 @@ bbbb
563565
ccc"`
564566
);
565567
const res = await context.getInputList('secrets', true);
566-
console.log(res);
567568
expect(res).toEqual([
568569
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
569570
`MYSECRET=aaaaaaaa
@@ -587,7 +588,6 @@ ccccccccc
587588
FOO=bar`
588589
);
589590
const res = await context.getInputList('secrets', true);
590-
console.log(res);
591591
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
592592
});
593593

@@ -598,7 +598,6 @@ FOO=bar`
598598
FOO=bar`
599599
);
600600
const res = await context.getInputList('secrets', true);
601-
console.log(res);
602601
expect(res).toEqual([`GPG_KEY=${pgp}`, 'FOO=bar']);
603602
});
604603

@@ -612,7 +611,6 @@ ccccccccc"
612611
FOO=bar`
613612
);
614613
const res = await context.getInputList('secrets', true);
615-
console.log(res);
616614
expect(res).toEqual([
617615
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
618616
`MYSECRET=aaaaaaaa

0 commit comments

Comments
 (0)