mirror of
https://github.com/docker/setup-buildx-action.git
synced 2026-09-04 01:08:53 +08:00
Compare commits
10 Commits
v4.3.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78b0615af3 | ||
|
|
5ac4a31b15 | ||
|
|
7b088f724c | ||
|
|
e38e8a1e29 | ||
|
|
1a2e524850 | ||
|
|
c41f88734b | ||
|
|
38f63b05d6 | ||
|
|
120ea02953 | ||
|
|
d055e6c81b | ||
|
|
077263eb4f |
@@ -234,7 +234,7 @@ describe('getCreateArgs', () => {
|
||||
],
|
||||
[
|
||||
10,
|
||||
'v0.10.3',
|
||||
'v0.37.0',
|
||||
new Map<string, string>([
|
||||
['use', 'false'],
|
||||
['driver', 'cloud'],
|
||||
@@ -301,6 +301,25 @@ describe('getCreateArgs', () => {
|
||||
expect(res).toEqual(expected);
|
||||
}
|
||||
);
|
||||
|
||||
test('rejects cloud driver with unsupported official Buildx', async () => {
|
||||
setInput('version', 'v0.36.1');
|
||||
setInput('driver', 'cloud');
|
||||
setInput('use', 'true');
|
||||
setInput('cache-binary', 'true');
|
||||
setInput('cleanup', 'true');
|
||||
setInput('keep-state', 'false');
|
||||
const toolkit = new Toolkit();
|
||||
const versionSpy = vi.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
||||
return 'v0.36.1';
|
||||
});
|
||||
try {
|
||||
const inp = await context.getInputs();
|
||||
await expect(context.getCreateArgs(inp, toolkit)).rejects.toThrow(/requires Buildx v0.37.0 or later/);
|
||||
} finally {
|
||||
versionSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAppendArgs', () => {
|
||||
@@ -361,140 +380,6 @@ describe('getAppendArgs', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('getVersion', () => {
|
||||
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([
|
||||
[
|
||||
0,
|
||||
new Map<string, string>([
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
''
|
||||
],
|
||||
[
|
||||
1,
|
||||
new Map<string, string>([
|
||||
['version', 'latest'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'latest'
|
||||
],
|
||||
[
|
||||
2,
|
||||
new Map<string, string>([
|
||||
['version', 'edge'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'edge'
|
||||
],
|
||||
[
|
||||
3,
|
||||
new Map<string, string>([
|
||||
['version', 'v0.19.2'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'v0.19.2'
|
||||
],
|
||||
[
|
||||
4,
|
||||
new Map<string, string>([
|
||||
['version', 'latest'],
|
||||
['driver', 'cloud'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'cloud:latest'
|
||||
],
|
||||
[
|
||||
5,
|
||||
new Map<string, string>([
|
||||
['version', 'edge'],
|
||||
['driver', 'cloud'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'cloud:edge'
|
||||
],
|
||||
[
|
||||
6,
|
||||
new Map<string, string>([
|
||||
['driver', 'cloud'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'cloud:latest'
|
||||
],
|
||||
[
|
||||
7,
|
||||
new Map<string, string>([
|
||||
['version', 'cloud:v0.11.2-desktop.2'],
|
||||
['driver', 'cloud'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'cloud:v0.11.2-desktop.2'
|
||||
],
|
||||
[
|
||||
8,
|
||||
new Map<string, string>([
|
||||
['version', 'cloud:v0.11.2-desktop.2'],
|
||||
// defaults
|
||||
['use', 'true'],
|
||||
['cache-binary', 'true'],
|
||||
['cleanup', 'true'],
|
||||
['keep-state', 'false']
|
||||
]),
|
||||
'cloud:v0.11.2-desktop.2'
|
||||
],
|
||||
])(
|
||||
'[%d] given %o as inputs, returns version %o',
|
||||
async (num: number, inputs: Map<string, string>, expected: string) => {
|
||||
inputs.forEach((value: string, name: string) => {
|
||||
setInput(name, value);
|
||||
});
|
||||
const inp = await context.getInputs();
|
||||
expect(context.getVersion(inp)).toEqual(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||
function getInputName(name: string): string {
|
||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||
|
||||
210
dist/index.cjs
generated
vendored
210
dist/index.cjs
generated
vendored
File diff suppressed because one or more lines are too long
8
dist/index.cjs.map
generated
vendored
8
dist/index.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
6
dist/licenses.txt
generated
vendored
6
dist/licenses.txt
generated
vendored
@@ -216,7 +216,7 @@ Apache License
|
||||
|
||||
The following npm package may be included in this product:
|
||||
|
||||
- @docker/actions-toolkit@0.95.0
|
||||
- @docker/actions-toolkit@0.96.0
|
||||
|
||||
This package contains the following license:
|
||||
|
||||
@@ -1792,7 +1792,7 @@ SOFTWARE.
|
||||
|
||||
The following npm package may be included in this product:
|
||||
|
||||
- js-yaml@5.3.0
|
||||
- js-yaml@5.4.1
|
||||
|
||||
This package contains the following license:
|
||||
|
||||
@@ -4313,7 +4313,7 @@ The following npm packages may be included in this product:
|
||||
- pump@2.0.1
|
||||
- pumpify@1.5.1
|
||||
- tar-stream@3.1.7
|
||||
- tar-stream@3.2.0
|
||||
- tar-stream@3.2.1
|
||||
|
||||
These packages each contain the following license:
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
"packageManager": "yarn@4.15.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^3.0.1",
|
||||
"@docker/actions-toolkit": "^0.95.0",
|
||||
"js-yaml": "^5.3.0"
|
||||
"@docker/actions-toolkit": "^0.96.0",
|
||||
"js-yaml": "^5.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.3",
|
||||
|
||||
@@ -52,6 +52,9 @@ export async function getBuilderName(name: string, driver: string): Promise<stri
|
||||
|
||||
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||
const args: Array<string> = ['create', '--name', inputs.name, '--driver', inputs.driver];
|
||||
if (inputs.driver === 'cloud' && !inputs.version.startsWith('cloud:') && !inputs.version.startsWith('lab:') && !(await toolkit.buildx.versionSatisfies('>=0.37.0-0'))) {
|
||||
throw new Error(`Docker Build Cloud with official Buildx requires Buildx v0.37.0 or later. Set version to cloud:<version> or lab:<version> to use the legacy Docker Build Cloud release channel.`);
|
||||
}
|
||||
if (await toolkit.buildx.versionSatisfies('>=0.3.0')) {
|
||||
await Util.asyncForEach(inputs.driverOpts, async (driverOpt: string) => {
|
||||
args.push('--driver-opt', driverOpt);
|
||||
@@ -116,17 +119,3 @@ export async function getInspectArgs(inputs: Inputs, toolkit: Toolkit): Promise<
|
||||
function driverSupportsBuildkitdFlags(driver: string): boolean {
|
||||
return driver == '' || driver == 'docker-container' || driver == 'docker' || driver == 'kubernetes';
|
||||
}
|
||||
|
||||
export function getVersion(inputs: Inputs): string {
|
||||
const version = inputs.version;
|
||||
if (inputs.driver === 'cloud') {
|
||||
if (!version || version === 'latest') {
|
||||
return 'cloud:latest';
|
||||
}
|
||||
if (version.startsWith('cloud:') || version.startsWith('lab:')) {
|
||||
return version;
|
||||
}
|
||||
return `cloud:${version}`;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ actionsToolkit.run(
|
||||
async () => {
|
||||
const inputs: context.Inputs = await context.getInputs();
|
||||
stateHelper.setCleanup(inputs.cleanup);
|
||||
const version = context.getVersion(inputs);
|
||||
|
||||
const toolkit = new Toolkit();
|
||||
const standalone = await toolkit.buildx.isStandalone();
|
||||
@@ -44,17 +43,17 @@ actionsToolkit.run(
|
||||
});
|
||||
|
||||
let toolPath;
|
||||
if (Util.isValidRef(version)) {
|
||||
if (Util.isValidRef(inputs.version)) {
|
||||
if (standalone) {
|
||||
throw new Error(`Cannot build from source without the Docker CLI`);
|
||||
}
|
||||
await core.group(`Build buildx from source`, async () => {
|
||||
toolPath = await toolkit.buildxInstall.build(version, !inputs.cacheBinary);
|
||||
toolPath = await toolkit.buildxInstall.build(inputs.version, !inputs.cacheBinary);
|
||||
});
|
||||
} else if (!(await toolkit.buildx.isAvailable()) || version) {
|
||||
} else if (!(await toolkit.buildx.isAvailable()) || inputs.version || (inputs.driver === 'cloud' && !inputs.version && !(await toolkit.buildx.versionSatisfies('>=0.37.0-0')))) {
|
||||
await core.group(`Download buildx from GitHub Releases`, async () => {
|
||||
toolPath = await toolkit.buildxInstall.download({
|
||||
version: version || 'latest',
|
||||
version: inputs.version || 'latest',
|
||||
ghaNoCache: !inputs.cacheBinary
|
||||
});
|
||||
});
|
||||
|
||||
58
yarn.lock
58
yarn.lock
@@ -437,9 +437,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@docker/actions-toolkit@npm:^0.95.0":
|
||||
version: 0.95.0
|
||||
resolution: "@docker/actions-toolkit@npm:0.95.0"
|
||||
"@docker/actions-toolkit@npm:^0.96.0":
|
||||
version: 0.96.0
|
||||
resolution: "@docker/actions-toolkit@npm:0.96.0"
|
||||
dependencies:
|
||||
"@actions/artifact": "npm:^6.2.1"
|
||||
"@actions/cache": "npm:^6.2.0"
|
||||
@@ -457,12 +457,12 @@ __metadata:
|
||||
gunzip-maybe: "npm:^1.4.2"
|
||||
handlebars: "npm:^4.7.9"
|
||||
he: "npm:^1.2.0"
|
||||
js-yaml: "npm:^5.3.0"
|
||||
js-yaml: "npm:^5.4.1"
|
||||
jwt-decode: "npm:^4.0.0"
|
||||
semver: "npm:^7.8.5"
|
||||
tar-stream: "npm:^3.2.0"
|
||||
tar-stream: "npm:^3.2.1"
|
||||
tmp: "npm:^0.2.7"
|
||||
checksum: 10/535f9252dbe129566865d03bc4fe57292e04593a4a09c208a94a0e5ecc4c24853fa82513fa152e176e60cef84d54c99ce4b2937ec9de00a5b70b93df374e4df9
|
||||
checksum: 10/7116f99ccf54bc47864113ff8911e857a0832e7603e3c2cf62e3ed067b4ce0c8b1987acd05766f57b15b182455987a3f49862b97fe5e413f35a8bc4d71500ae3
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -934,20 +934,30 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@humanfs/core@npm:^0.19.1":
|
||||
version: 0.19.1
|
||||
resolution: "@humanfs/core@npm:0.19.1"
|
||||
checksum: 10/270d936be483ab5921702623bc74ce394bf12abbf57d9145a69e8a0d1c87eb1c768bd2d93af16c5705041e257e6d9cc7529311f63a1349f3678abc776fc28523
|
||||
"@humanfs/core@npm:^0.19.2":
|
||||
version: 0.19.2
|
||||
resolution: "@humanfs/core@npm:0.19.2"
|
||||
dependencies:
|
||||
"@humanfs/types": "npm:^0.15.0"
|
||||
checksum: 10/c6c0273721ec8df3d36a57c390a11a168d0a2f513d78bceb25165bded4fcb73609b1a317edc6c8f331cefd4b47285dde0b1e6679e08ef7f062232ec14fe05312
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@humanfs/node@npm:^0.16.6":
|
||||
version: 0.16.7
|
||||
resolution: "@humanfs/node@npm:0.16.7"
|
||||
version: 0.16.8
|
||||
resolution: "@humanfs/node@npm:0.16.8"
|
||||
dependencies:
|
||||
"@humanfs/core": "npm:^0.19.1"
|
||||
"@humanfs/core": "npm:^0.19.2"
|
||||
"@humanfs/types": "npm:^0.15.0"
|
||||
"@humanwhocodes/retry": "npm:^0.4.0"
|
||||
checksum: 10/b3633d3dce898592cac515ba5e6693c78e6be92863541d3eaf2c009b10f52b2fa62ff6e6e06f240f2447ddbe7b5f1890bc34e9308470675c876eee207553a08d
|
||||
checksum: 10/ed01b3c066d9cec7526d139b9e71ca00ee4a30b3b5f5f5c198eb069c3509a3e167e180ba7e1e5a83b9571e906c4908bd20402b47586887452311af7354995e95
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@humanfs/types@npm:^0.15.0":
|
||||
version: 0.15.0
|
||||
resolution: "@humanfs/types@npm:0.15.0"
|
||||
checksum: 10/dea3cc7fd8f8d4d088ed8d0a9921cf12bd8e1cdf40a6133106b03a6e2aebcc9a6f1771b3643b7ec71baae90d08245db34069dfcc861da8d678662741e6c3c986
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -2826,7 +2836,7 @@ __metadata:
|
||||
resolution: "docker-setup-buildx@workspace:."
|
||||
dependencies:
|
||||
"@actions/core": "npm:^3.0.1"
|
||||
"@docker/actions-toolkit": "npm:^0.95.0"
|
||||
"@docker/actions-toolkit": "npm:^0.96.0"
|
||||
"@eslint/js": "npm:^9.39.3"
|
||||
"@types/js-yaml": "npm:^4.0.9"
|
||||
"@types/node": "npm:^24.11.0"
|
||||
@@ -2840,7 +2850,7 @@ __metadata:
|
||||
eslint-plugin-prettier: "npm:^5.5.5"
|
||||
generate-license-file: "npm:^4.1.1"
|
||||
globals: "npm:^17.3.0"
|
||||
js-yaml: "npm:^5.3.0"
|
||||
js-yaml: "npm:^5.4.1"
|
||||
prettier: "npm:^3.8.1"
|
||||
typescript: "npm:^5.9.3"
|
||||
vitest: "npm:^4.0.18"
|
||||
@@ -3997,14 +4007,14 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"js-yaml@npm:^5.3.0":
|
||||
version: 5.3.0
|
||||
resolution: "js-yaml@npm:5.3.0"
|
||||
"js-yaml@npm:^5.4.1":
|
||||
version: 5.4.1
|
||||
resolution: "js-yaml@npm:5.4.1"
|
||||
dependencies:
|
||||
argparse: "npm:^2.0.1"
|
||||
bin:
|
||||
js-yaml: bin/js-yaml.mjs
|
||||
checksum: 10/6c7e8ea8dd5643d9df73f4aa796f3572537284e9b819b74ef919467452bfa4624f8f7477cfc775c91db7e2f32387133b1b6c4e95aef9702be6bb042ae554884a
|
||||
checksum: 10/6fff9ee00bd59aeb7e1484b4281f5e927b117cbfbf3ffa6c0fef0c58519317eb61527e93c4aa70f417709229bc1eeed63cba773913577a64405975a72fba7180
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -5621,15 +5631,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tar-stream@npm:^3.2.0":
|
||||
version: 3.2.0
|
||||
resolution: "tar-stream@npm:3.2.0"
|
||||
"tar-stream@npm:^3.2.1":
|
||||
version: 3.2.1
|
||||
resolution: "tar-stream@npm:3.2.1"
|
||||
dependencies:
|
||||
b4a: "npm:^1.6.4"
|
||||
bare-fs: "npm:^4.5.5"
|
||||
fast-fifo: "npm:^1.2.0"
|
||||
streamx: "npm:^2.15.0"
|
||||
checksum: 10/ce57a81521de73ae7a3b7d55a08da50d6771427c249bfa89a208518e48faf5254c8fa7201a8f5419ab8bde9601a74e6dd512b31a13ec89774aec96178f99a8d3
|
||||
checksum: 10/1a09f857e0789489476d99fb716fa6d209e7d19aa73b7a4b23f40eeba46792d5007ca62fde4fca8f643ed71ace1c526a293c655718a0409275a45a8aa86b562a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user