2022-03-15 16:59:52 -04:00
|
|
|
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
|
2020-10-19 15:17:06 -04:00
|
|
|
import * as fs from 'fs';
|
|
|
|
import * as path from 'path';
|
2020-11-17 15:38:45 -05:00
|
|
|
|
2020-10-21 15:07:52 -04:00
|
|
|
import * as context from '../src/context';
|
2020-10-19 15:17:06 -04:00
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
const pgp = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
|
|
|
|
|
|
lQdGBF6tzaABEACjFbX7PFEG6vDPN2MPyxYW7/3o/sonORj4HXUFjFxxJxktJ3x3
|
|
|
|
N1ayHPJ1lqIeoiY7jVbq0ZdEVGkd3YsKG9ZMdZkzGzY6PQPC/+M8OnzOiOPwUdWc
|
|
|
|
+Tdhh115LvVz0MMKYiab6Sn9cgxj9On3LCQKpjvMDpPo9Ttf6v2GQIw8h2ACvdzQ
|
|
|
|
71LtIELS/I+dLbfZiwpUu2fhQT13EJkEnYMOYwM5jNUd66P9itUc7MrOWjkicrKP
|
|
|
|
oF1dQaCM+tuKuxvD8WLdiwU5x60NoGkJHHUehKQXl2dVzjpqEqHKEBJt9tfJ9lpE
|
|
|
|
YIisgwB8o3pes0fgCehjW2zI95/o9+ayJ6nl4g5+mSvWRXEu66h71nwM0Yuvquk8
|
|
|
|
3me7qhYfDrDdCwcxS5BS1hwakTgUQLD99FZjbx1j8sq96I65O0GRdyU2PR8KIjwu
|
|
|
|
JrkTH4ZlKxK3FQghUhFoA5GkiDb+eClmRMSni5qg+81T4XChmUkEprA3eWCHL+Ma
|
|
|
|
xRNNxLS+r6hH9HG5JBxpV3iaTI9HHpnQKhEeaLXqsUTDZliN9hP7Ywo8bpUB8j2d
|
|
|
|
oWYwDV4dPyMKr6Fb8RDCh2q5gJGbVp8w/NmmBTeL+IP2fFggJkRfyumv3Ul7x66L
|
|
|
|
tBFQ4rYo4JUUrGweSTneG6REIgxH66hIrNl6Vo/D1Z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VnW31nnoDMp49jG4OynjrH
|
|
|
|
cRuoM9sxdr6UDqb22CZ3/e0YN4UaZM3YDWMVaP/QBVgvIFcdByqNWezpd9T4ZUII
|
|
|
|
MZlaV1uRnHg6B/zTzhIdMM80AXz6Uv6kw4S+Lt7HlbrnMT7uKLuvzH7cle0hcIUa
|
|
|
|
PejgXO0uIRolYQ3sz2tMGhx1MfBqH64=
|
|
|
|
=WbwB
|
|
|
|
-----END PGP PRIVATE KEY BLOCK-----`;
|
|
|
|
|
2020-10-19 15:17:06 -04:00
|
|
|
jest.spyOn(context, 'defaultContext').mockImplementation((): string => {
|
2021-04-26 05:02:09 -04:00
|
|
|
return 'https://github.com/docker/build-push-action.git#refs/heads/test-jest';
|
2020-10-19 15:17:06 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
|
|
|
const tmpDir = path.join('/tmp/.docker-build-push-jest').split(path.sep).join(path.posix.sep);
|
|
|
|
if (!fs.existsSync(tmpDir)) {
|
|
|
|
fs.mkdirSync(tmpDir, {recursive: true});
|
|
|
|
}
|
|
|
|
return tmpDir;
|
|
|
|
});
|
|
|
|
|
|
|
|
jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
|
|
|
|
return path.join('/tmp/.docker-build-push-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getArgs', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
process.env = Object.keys(process.env).reduce((object, key) => {
|
|
|
|
if (!key.startsWith('INPUT_')) {
|
|
|
|
object[key] = process.env[key];
|
|
|
|
}
|
|
|
|
return object;
|
|
|
|
}, {});
|
|
|
|
});
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
test.each([
|
2020-10-21 03:51:06 -04:00
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
0,
|
2020-10-21 03:51:06 -04:00
|
|
|
'0.4.1',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '.'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-21 03:51:06 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
|
|
'.'
|
|
|
|
]
|
|
|
|
],
|
2020-10-19 15:17:06 -04:00
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
1,
|
2020-10-19 15:17:06 -04:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
2020-10-20 13:04:54 -04:00
|
|
|
['build-args', 'MY_ARG=val1,val2,val3\nARG=val'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-19 15:17:06 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2020-10-20 13:04:54 -04:00
|
|
|
'--build-arg', 'MY_ARG=val1,val2,val3',
|
|
|
|
'--build-arg', 'ARG=val',
|
2020-10-20 09:18:02 -04:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
2021-04-26 05:02:09 -04:00
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
|
2020-10-19 15:17:06 -04:00
|
|
|
]
|
|
|
|
],
|
2020-12-04 21:40:39 -05:00
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
2,
|
2020-12-04 21:40:39 -05:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
|
|
|
['tags', 'name/app:7.4, name/app:latest'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-12-04 21:40:39 -05:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
2020-12-04 21:40:39 -05:00
|
|
|
'--tag', 'name/app:7.4',
|
|
|
|
'--tag', 'name/app:latest',
|
2021-04-26 05:02:09 -04:00
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
|
2020-12-04 21:40:39 -05:00
|
|
|
]
|
|
|
|
],
|
2020-10-19 15:17:06 -04:00
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
3,
|
2020-10-19 15:17:06 -04:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '.'],
|
2020-10-20 13:04:54 -04:00
|
|
|
['labels', 'org.opencontainers.image.title=buildkit\norg.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['outputs', 'type=local,dest=./release-out'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-19 15:17:06 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2020-10-20 13:04:54 -04:00
|
|
|
'--label', 'org.opencontainers.image.title=buildkit',
|
|
|
|
'--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit',
|
2020-10-19 15:17:06 -04:00
|
|
|
'--output', 'type=local,dest=./release-out',
|
|
|
|
'.'
|
|
|
|
]
|
|
|
|
],
|
2020-10-21 03:51:06 -04:00
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
4,
|
2020-10-21 03:51:06 -04:00
|
|
|
'0.4.1',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '.'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['platforms', 'linux/amd64,linux/arm64'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-21 03:51:06 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
|
|
|
'--platform', 'linux/amd64,linux/arm64',
|
|
|
|
'.'
|
|
|
|
]
|
|
|
|
],
|
2020-10-19 15:17:06 -04:00
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
5,
|
2020-10-19 15:17:06 -04:00
|
|
|
'0.4.1',
|
|
|
|
new Map<string, string>([
|
2021-06-22 11:25:52 -04:00
|
|
|
['context', '.'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-19 15:17:06 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2020-10-21 03:51:06 -04:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
2020-10-19 15:17:06 -04:00
|
|
|
'.'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
6,
|
2020-10-19 15:17:06 -04:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '.'],
|
2020-10-23 12:21:44 -04:00
|
|
|
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-19 15:17:06 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2020-10-20 09:18:02 -04:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
|
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
2020-10-19 15:17:06 -04:00
|
|
|
'.'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
7,
|
2020-10-19 15:17:06 -04:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
2020-10-20 09:18:02 -04:00
|
|
|
['github-token', 'abcdefghijklmno0123456789'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['outputs', '.'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-19 15:17:06 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2020-10-20 09:18:02 -04:00
|
|
|
'--output', '.',
|
|
|
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
2021-04-26 05:02:09 -04:00
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
|
2020-10-19 15:17:06 -04:00
|
|
|
]
|
2020-10-20 20:46:41 -04:00
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
8,
|
2020-10-20 20:46:41 -04:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
2021-04-26 05:02:09 -04:00
|
|
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
2020-10-20 20:46:41 -04:00
|
|
|
['tag', 'localhost:5000/name/app:latest'],
|
|
|
|
['platforms', 'linux/amd64,linux/arm64'],
|
2020-10-23 12:21:44 -04:00
|
|
|
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
|
2020-10-20 20:46:41 -04:00
|
|
|
['file', './test/Dockerfile'],
|
|
|
|
['builder', 'builder-git-context-2'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'true'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-10-20 20:46:41 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--file', './test/Dockerfile',
|
2020-10-21 03:51:06 -04:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--platform', 'linux/amd64,linux/arm64',
|
2020-10-20 20:46:41 -04:00
|
|
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--builder', 'builder-git-context-2',
|
|
|
|
'--push',
|
2021-04-26 05:02:09 -04:00
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
2020-10-20 20:46:41 -04:00
|
|
|
]
|
2020-11-17 15:38:45 -05:00
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
9,
|
2020-11-17 15:38:45 -05:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
2021-04-26 05:02:09 -04:00
|
|
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
2020-11-17 15:38:45 -05:00
|
|
|
['tag', 'localhost:5000/name/app:latest'],
|
|
|
|
['platforms', 'linux/amd64,linux/arm64'],
|
|
|
|
['secrets', `GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789
|
|
|
|
"MYSECRET=aaaaaaaa
|
|
|
|
bbbbbbb
|
|
|
|
ccccccccc"
|
|
|
|
FOO=bar
|
|
|
|
"EMPTYLINE=aaaa
|
|
|
|
|
|
|
|
bbbb
|
|
|
|
ccc"`],
|
|
|
|
['file', './test/Dockerfile'],
|
|
|
|
['builder', 'builder-git-context-2'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'true'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-11-17 15:38:45 -05:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--file', './test/Dockerfile',
|
2020-11-17 15:38:45 -05:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--platform', 'linux/amd64,linux/arm64',
|
2020-11-17 15:38:45 -05:00
|
|
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--builder', 'builder-git-context-2',
|
|
|
|
'--push',
|
2021-04-26 05:02:09 -04:00
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
2020-11-17 15:38:45 -05:00
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
10,
|
2020-11-17 15:38:45 -05:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
2021-04-26 05:02:09 -04:00
|
|
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
2020-11-17 15:38:45 -05:00
|
|
|
['tag', 'localhost:5000/name/app:latest'],
|
|
|
|
['platforms', 'linux/amd64,linux/arm64'],
|
|
|
|
['secrets', `GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789
|
|
|
|
MYSECRET=aaaaaaaa
|
|
|
|
bbbbbbb
|
|
|
|
ccccccccc
|
|
|
|
FOO=bar
|
|
|
|
EMPTYLINE=aaaa
|
|
|
|
|
|
|
|
bbbb
|
|
|
|
ccc`],
|
|
|
|
['file', './test/Dockerfile'],
|
|
|
|
['builder', 'builder-git-context-2'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'true'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2020-11-17 15:38:45 -05:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--file', './test/Dockerfile',
|
2020-11-17 15:38:45 -05:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--platform', 'linux/amd64,linux/arm64',
|
2020-11-17 15:38:45 -05:00
|
|
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--builder', 'builder-git-context-2',
|
|
|
|
'--push',
|
2021-04-26 05:02:09 -04:00
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
2020-11-17 15:38:45 -05:00
|
|
|
]
|
2021-02-15 04:08:19 -05:00
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
11,
|
2021-02-15 04:08:19 -05:00
|
|
|
'0.5.1',
|
|
|
|
new Map<string, string>([
|
2021-04-26 05:02:09 -04:00
|
|
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
2021-02-15 04:08:19 -05:00
|
|
|
['tag', 'localhost:5000/name/app:latest'],
|
|
|
|
['secret-files', `MY_SECRET=${path.join(__dirname, 'fixtures', 'secret.txt').split(path.sep).join(path.posix.sep)}`],
|
|
|
|
['file', './test/Dockerfile'],
|
|
|
|
['builder', 'builder-git-context-2'],
|
2021-04-06 08:49:15 -04:00
|
|
|
['network', 'host'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'true'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2021-02-15 04:08:19 -05:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--file', './test/Dockerfile',
|
2021-02-15 04:08:19 -05:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
|
|
'--secret', 'id=MY_SECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--builder', 'builder-git-context-2',
|
2021-04-06 08:49:15 -04:00
|
|
|
'--network', 'host',
|
2021-02-15 04:08:19 -05:00
|
|
|
'--push',
|
2021-04-26 05:02:09 -04:00
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
2021-02-15 04:08:19 -05:00
|
|
|
]
|
2021-05-22 20:41:02 -04:00
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
12,
|
2021-05-22 20:41:02 -04:00
|
|
|
'0.4.2',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '.'],
|
|
|
|
['labels', 'org.opencontainers.image.title=filter_results_top_n\norg.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"'],
|
2021-06-22 11:25:52 -04:00
|
|
|
['outputs', 'type=local,dest=./release-out'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2021-05-22 20:41:02 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
|
|
|
'--label', 'org.opencontainers.image.title=filter_results_top_n',
|
|
|
|
'--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"',
|
|
|
|
'--output', 'type=local,dest=./release-out',
|
|
|
|
'.'
|
|
|
|
]
|
2021-08-16 17:44:13 -04:00
|
|
|
],
|
|
|
|
[
|
2021-11-15 23:19:44 -05:00
|
|
|
13,
|
2021-08-16 17:44:13 -04:00
|
|
|
'0.6.0',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '.'],
|
|
|
|
['tag', 'localhost:5000/name/app:latest'],
|
|
|
|
['file', './test/Dockerfile'],
|
2022-01-31 05:47:45 -05:00
|
|
|
['add-hosts', 'docker:10.180.0.1,foo:10.0.0.1'],
|
2021-08-16 17:44:13 -04:00
|
|
|
['network', 'host'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'true'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['pull', 'false'],
|
2021-08-16 17:44:13 -04:00
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2022-01-31 05:47:45 -05:00
|
|
|
'--add-host', 'docker:10.180.0.1',
|
|
|
|
'--add-host', 'foo:10.0.0.1',
|
2021-11-15 23:19:44 -05:00
|
|
|
'--file', './test/Dockerfile',
|
2021-08-16 17:44:13 -04:00
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
|
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
|
|
|
'--network', 'host',
|
|
|
|
'--push',
|
|
|
|
'.'
|
|
|
|
]
|
|
|
|
],
|
2021-11-16 01:19:27 -05:00
|
|
|
[
|
|
|
|
14,
|
|
|
|
'0.7.0',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '.'],
|
|
|
|
['file', './test/Dockerfile'],
|
2022-01-31 05:47:45 -05:00
|
|
|
['add-hosts', 'docker:10.180.0.1\nfoo:10.0.0.1'],
|
2021-11-16 01:19:27 -05:00
|
|
|
['cgroup-parent', 'foo'],
|
|
|
|
['shm-size', '2g'],
|
|
|
|
['ulimit', `nofile=1024:1024
|
|
|
|
nproc=3`],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
|
|
|
['pull', 'false'],
|
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
2022-01-30 12:33:31 -05:00
|
|
|
'--add-host', 'docker:10.180.0.1',
|
2022-01-31 05:47:45 -05:00
|
|
|
'--add-host', 'foo:10.0.0.1',
|
2021-11-16 01:19:27 -05:00
|
|
|
'--cgroup-parent', 'foo',
|
|
|
|
'--file', './test/Dockerfile',
|
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
|
|
'--shm-size', '2g',
|
|
|
|
'--ulimit', 'nofile=1024:1024',
|
|
|
|
'--ulimit', 'nproc=3',
|
|
|
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
|
|
|
'.'
|
|
|
|
]
|
|
|
|
],
|
2021-12-27 18:49:32 -05:00
|
|
|
[
|
|
|
|
15,
|
|
|
|
'0.7.0',
|
|
|
|
new Map<string, string>([
|
|
|
|
['context', '{{defaultContext}}:docker'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
|
|
|
['pull', 'false'],
|
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
|
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest:docker'
|
|
|
|
]
|
|
|
|
],
|
2022-08-03 08:38:56 -04:00
|
|
|
[
|
|
|
|
16,
|
|
|
|
'0.8.2',
|
|
|
|
new Map<string, string>([
|
|
|
|
['github-token', 'abcdefghijklmno0123456789'],
|
|
|
|
['context', '{{defaultContext}}:subdir'],
|
|
|
|
['load', 'false'],
|
|
|
|
['no-cache', 'false'],
|
|
|
|
['push', 'false'],
|
|
|
|
['pull', 'false'],
|
|
|
|
]),
|
|
|
|
[
|
|
|
|
'build',
|
|
|
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
|
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
|
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
|
|
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest:subdir'
|
|
|
|
]
|
|
|
|
]
|
2020-10-19 15:17:06 -04:00
|
|
|
])(
|
2021-11-15 23:19:44 -05:00
|
|
|
'[%d] given %p with %p as inputs, returns %p',
|
2022-03-15 16:59:52 -04:00
|
|
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
|
|
|
|
inputs.forEach((value: string, name: string) => {
|
2020-10-19 15:17:06 -04:00
|
|
|
setInput(name, value);
|
|
|
|
});
|
|
|
|
const defContext = context.defaultContext();
|
|
|
|
const inp = await context.getInputs(defContext);
|
|
|
|
const res = await context.getArgs(inp, defContext, buildxVersion);
|
|
|
|
expect(res).toEqual(expected);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2020-08-16 20:32:27 -04:00
|
|
|
|
|
|
|
describe('getInputList', () => {
|
2020-11-17 15:38:45 -05:00
|
|
|
it('single line correctly', async () => {
|
2020-08-16 20:32:27 -04:00
|
|
|
await setInput('foo', 'bar');
|
|
|
|
const res = await context.getInputList('foo');
|
|
|
|
expect(res).toEqual(['bar']);
|
|
|
|
});
|
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('multiline correctly', async () => {
|
2020-08-16 20:32:27 -04:00
|
|
|
setInput('foo', 'bar\nbaz');
|
|
|
|
const res = await context.getInputList('foo');
|
|
|
|
expect(res).toEqual(['bar', 'baz']);
|
|
|
|
});
|
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('empty lines correctly', async () => {
|
2020-09-04 20:52:09 -04:00
|
|
|
setInput('foo', 'bar\n\nbaz');
|
|
|
|
const res = await context.getInputList('foo');
|
|
|
|
expect(res).toEqual(['bar', 'baz']);
|
|
|
|
});
|
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('comma correctly', async () => {
|
2020-08-16 20:32:27 -04:00
|
|
|
setInput('foo', 'bar,baz');
|
|
|
|
const res = await context.getInputList('foo');
|
|
|
|
expect(res).toEqual(['bar', 'baz']);
|
|
|
|
});
|
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('empty result correctly', async () => {
|
2020-09-04 20:52:09 -04:00
|
|
|
setInput('foo', 'bar,baz,');
|
|
|
|
const res = await context.getInputList('foo');
|
|
|
|
expect(res).toEqual(['bar', 'baz']);
|
|
|
|
});
|
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('different new lines correctly', async () => {
|
2020-08-16 20:32:27 -04:00
|
|
|
setInput('foo', 'bar\r\nbaz');
|
|
|
|
const res = await context.getInputList('foo');
|
|
|
|
expect(res).toEqual(['bar', 'baz']);
|
|
|
|
});
|
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('different new lines and comma correctly', async () => {
|
2020-08-16 20:32:27 -04:00
|
|
|
setInput('foo', 'bar\r\nbaz,bat');
|
|
|
|
const res = await context.getInputList('foo');
|
|
|
|
expect(res).toEqual(['bar', 'baz', 'bat']);
|
|
|
|
});
|
2020-08-29 11:15:26 -04:00
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('multiline and ignoring comma correctly', async () => {
|
2020-08-29 11:15:26 -04:00
|
|
|
setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir');
|
|
|
|
const res = await context.getInputList('cache-from', true);
|
|
|
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
|
|
|
});
|
|
|
|
|
2020-11-17 15:38:45 -05:00
|
|
|
it('different new lines and ignoring comma correctly', async () => {
|
2020-08-29 11:15:26 -04:00
|
|
|
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
|
|
|
|
const res = await context.getInputList('cache-from', true);
|
|
|
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
|
|
|
});
|
2020-11-17 15:38:45 -05:00
|
|
|
|
|
|
|
it('multiline values', async () => {
|
|
|
|
setInput(
|
|
|
|
'secrets',
|
|
|
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
|
|
|
"MYSECRET=aaaaaaaa
|
|
|
|
bbbbbbb
|
|
|
|
ccccccccc"
|
|
|
|
FOO=bar`
|
|
|
|
);
|
|
|
|
const res = await context.getInputList('secrets', true);
|
|
|
|
expect(res).toEqual([
|
|
|
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
|
|
|
`MYSECRET=aaaaaaaa
|
|
|
|
bbbbbbb
|
|
|
|
ccccccccc`,
|
|
|
|
'FOO=bar'
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('multiline values with empty lines', async () => {
|
|
|
|
setInput(
|
|
|
|
'secrets',
|
|
|
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
|
|
|
"MYSECRET=aaaaaaaa
|
|
|
|
bbbbbbb
|
|
|
|
ccccccccc"
|
|
|
|
FOO=bar
|
|
|
|
"EMPTYLINE=aaaa
|
|
|
|
|
|
|
|
bbbb
|
|
|
|
ccc"`
|
|
|
|
);
|
|
|
|
const res = await context.getInputList('secrets', true);
|
|
|
|
expect(res).toEqual([
|
|
|
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
|
|
|
`MYSECRET=aaaaaaaa
|
|
|
|
bbbbbbb
|
|
|
|
ccccccccc`,
|
|
|
|
'FOO=bar',
|
|
|
|
`EMPTYLINE=aaaa
|
|
|
|
|
|
|
|
bbbb
|
|
|
|
ccc`
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('multiline values without quotes', async () => {
|
|
|
|
setInput(
|
|
|
|
'secrets',
|
|
|
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
|
|
|
MYSECRET=aaaaaaaa
|
|
|
|
bbbbbbb
|
|
|
|
ccccccccc
|
|
|
|
FOO=bar`
|
|
|
|
);
|
|
|
|
const res = await context.getInputList('secrets', true);
|
2021-07-01 09:29:36 -04:00
|
|
|
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
|
2020-11-17 15:38:45 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('large multiline values', async () => {
|
|
|
|
setInput(
|
|
|
|
'secrets',
|
|
|
|
`"GPG_KEY=${pgp}"
|
|
|
|
FOO=bar`
|
|
|
|
);
|
|
|
|
const res = await context.getInputList('secrets', true);
|
|
|
|
expect(res).toEqual([`GPG_KEY=${pgp}`, 'FOO=bar']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('multiline values escape quotes', async () => {
|
|
|
|
setInput(
|
|
|
|
'secrets',
|
|
|
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
|
|
|
"MYSECRET=aaaaaaaa
|
|
|
|
bbbb""bbb
|
|
|
|
ccccccccc"
|
|
|
|
FOO=bar`
|
|
|
|
);
|
|
|
|
const res = await context.getInputList('secrets', true);
|
|
|
|
expect(res).toEqual([
|
|
|
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
|
|
|
`MYSECRET=aaaaaaaa
|
2022-03-15 16:59:52 -04:00
|
|
|
bbbb"bbb
|
2020-11-17 15:38:45 -05:00
|
|
|
ccccccccc`,
|
|
|
|
'FOO=bar'
|
|
|
|
]);
|
|
|
|
});
|
2020-08-16 20:32:27 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('asyncForEach', () => {
|
|
|
|
it('executes async tasks sequentially', async () => {
|
|
|
|
const testValues = [1, 2, 3, 4, 5];
|
|
|
|
const results: number[] = [];
|
|
|
|
|
|
|
|
await context.asyncForEach(testValues, async value => {
|
|
|
|
results.push(value);
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(results).toEqual(testValues);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-06-22 11:25:52 -04:00
|
|
|
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
2020-08-16 20:32:27 -04:00
|
|
|
function getInputName(name: string): string {
|
|
|
|
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setInput(name: string, value: string): void {
|
|
|
|
process.env[getInputName(name)] = value;
|
|
|
|
}
|