mirror of
https://github.com/docker/setup-buildx-action.git
synced 2026-09-03 17:43:53 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ac4a31b15 | ||
|
|
7b088f724c | ||
|
|
e38e8a1e29 | ||
|
|
1a2e524850 | ||
|
|
c41f88734b | ||
|
|
38f63b05d6 | ||
|
|
120ea02953 | ||
|
|
d055e6c81b | ||
|
|
077263eb4f |
+20
-135
@@ -234,7 +234,7 @@ describe('getCreateArgs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
10,
|
10,
|
||||||
'v0.10.3',
|
'v0.37.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['driver', 'cloud'],
|
['driver', 'cloud'],
|
||||||
@@ -301,6 +301,25 @@ describe('getCreateArgs', () => {
|
|||||||
expect(res).toEqual(expected);
|
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', () => {
|
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
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||||
function getInputName(name: string): string {
|
function getInputName(name: string): string {
|
||||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
|
|||||||
+107
-103
File diff suppressed because one or more lines are too long
+4
-4
File diff suppressed because one or more lines are too long
+3
-3
@@ -216,7 +216,7 @@ Apache License
|
|||||||
|
|
||||||
The following npm package may be included in this product:
|
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:
|
This package contains the following license:
|
||||||
|
|
||||||
@@ -1792,7 +1792,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
The following npm package may be included in this product:
|
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:
|
This package contains the following license:
|
||||||
|
|
||||||
@@ -4313,7 +4313,7 @@ The following npm packages may be included in this product:
|
|||||||
- pump@2.0.1
|
- pump@2.0.1
|
||||||
- pumpify@1.5.1
|
- pumpify@1.5.1
|
||||||
- tar-stream@3.1.7
|
- tar-stream@3.1.7
|
||||||
- tar-stream@3.2.0
|
- tar-stream@3.2.1
|
||||||
|
|
||||||
These packages each contain the following license:
|
These packages each contain the following license:
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@
|
|||||||
"packageManager": "yarn@4.15.0",
|
"packageManager": "yarn@4.15.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^3.0.1",
|
||||||
"@docker/actions-toolkit": "^0.95.0",
|
"@docker/actions-toolkit": "^0.96.0",
|
||||||
"js-yaml": "^5.3.0"
|
"js-yaml": "^5.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.39.3",
|
"@eslint/js": "^9.39.3",
|
||||||
|
|||||||
+3
-14
@@ -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>> {
|
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
const args: Array<string> = ['create', '--name', inputs.name, '--driver', inputs.driver];
|
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')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.3.0')) {
|
||||||
await Util.asyncForEach(inputs.driverOpts, async (driverOpt: string) => {
|
await Util.asyncForEach(inputs.driverOpts, async (driverOpt: string) => {
|
||||||
args.push('--driver-opt', driverOpt);
|
args.push('--driver-opt', driverOpt);
|
||||||
@@ -116,17 +119,3 @@ export async function getInspectArgs(inputs: Inputs, toolkit: Toolkit): Promise<
|
|||||||
function driverSupportsBuildkitdFlags(driver: string): boolean {
|
function driverSupportsBuildkitdFlags(driver: string): boolean {
|
||||||
return driver == '' || driver == 'docker-container' || driver == 'docker' || driver == 'kubernetes';
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
+4
-5
@@ -22,7 +22,6 @@ actionsToolkit.run(
|
|||||||
async () => {
|
async () => {
|
||||||
const inputs: context.Inputs = await context.getInputs();
|
const inputs: context.Inputs = await context.getInputs();
|
||||||
stateHelper.setCleanup(inputs.cleanup);
|
stateHelper.setCleanup(inputs.cleanup);
|
||||||
const version = context.getVersion(inputs);
|
|
||||||
|
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
const standalone = await toolkit.buildx.isStandalone();
|
const standalone = await toolkit.buildx.isStandalone();
|
||||||
@@ -44,17 +43,17 @@ actionsToolkit.run(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let toolPath;
|
let toolPath;
|
||||||
if (Util.isValidRef(version)) {
|
if (Util.isValidRef(inputs.version)) {
|
||||||
if (standalone) {
|
if (standalone) {
|
||||||
throw new Error(`Cannot build from source without the Docker CLI`);
|
throw new Error(`Cannot build from source without the Docker CLI`);
|
||||||
}
|
}
|
||||||
await core.group(`Build buildx from source`, async () => {
|
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 () => {
|
await core.group(`Download buildx from GitHub Releases`, async () => {
|
||||||
toolPath = await toolkit.buildxInstall.download({
|
toolPath = await toolkit.buildxInstall.download({
|
||||||
version: version || 'latest',
|
version: inputs.version || 'latest',
|
||||||
ghaNoCache: !inputs.cacheBinary
|
ghaNoCache: !inputs.cacheBinary
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -437,9 +437,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@docker/actions-toolkit@npm:^0.95.0":
|
"@docker/actions-toolkit@npm:^0.96.0":
|
||||||
version: 0.95.0
|
version: 0.96.0
|
||||||
resolution: "@docker/actions-toolkit@npm:0.95.0"
|
resolution: "@docker/actions-toolkit@npm:0.96.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/artifact": "npm:^6.2.1"
|
"@actions/artifact": "npm:^6.2.1"
|
||||||
"@actions/cache": "npm:^6.2.0"
|
"@actions/cache": "npm:^6.2.0"
|
||||||
@@ -457,12 +457,12 @@ __metadata:
|
|||||||
gunzip-maybe: "npm:^1.4.2"
|
gunzip-maybe: "npm:^1.4.2"
|
||||||
handlebars: "npm:^4.7.9"
|
handlebars: "npm:^4.7.9"
|
||||||
he: "npm:^1.2.0"
|
he: "npm:^1.2.0"
|
||||||
js-yaml: "npm:^5.3.0"
|
js-yaml: "npm:^5.4.1"
|
||||||
jwt-decode: "npm:^4.0.0"
|
jwt-decode: "npm:^4.0.0"
|
||||||
semver: "npm:^7.8.5"
|
semver: "npm:^7.8.5"
|
||||||
tar-stream: "npm:^3.2.0"
|
tar-stream: "npm:^3.2.1"
|
||||||
tmp: "npm:^0.2.7"
|
tmp: "npm:^0.2.7"
|
||||||
checksum: 10/535f9252dbe129566865d03bc4fe57292e04593a4a09c208a94a0e5ecc4c24853fa82513fa152e176e60cef84d54c99ce4b2937ec9de00a5b70b93df374e4df9
|
checksum: 10/7116f99ccf54bc47864113ff8911e857a0832e7603e3c2cf62e3ed067b4ce0c8b1987acd05766f57b15b182455987a3f49862b97fe5e413f35a8bc4d71500ae3
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -2826,7 +2826,7 @@ __metadata:
|
|||||||
resolution: "docker-setup-buildx@workspace:."
|
resolution: "docker-setup-buildx@workspace:."
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/core": "npm:^3.0.1"
|
"@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"
|
"@eslint/js": "npm:^9.39.3"
|
||||||
"@types/js-yaml": "npm:^4.0.9"
|
"@types/js-yaml": "npm:^4.0.9"
|
||||||
"@types/node": "npm:^24.11.0"
|
"@types/node": "npm:^24.11.0"
|
||||||
@@ -2840,7 +2840,7 @@ __metadata:
|
|||||||
eslint-plugin-prettier: "npm:^5.5.5"
|
eslint-plugin-prettier: "npm:^5.5.5"
|
||||||
generate-license-file: "npm:^4.1.1"
|
generate-license-file: "npm:^4.1.1"
|
||||||
globals: "npm:^17.3.0"
|
globals: "npm:^17.3.0"
|
||||||
js-yaml: "npm:^5.3.0"
|
js-yaml: "npm:^5.4.1"
|
||||||
prettier: "npm:^3.8.1"
|
prettier: "npm:^3.8.1"
|
||||||
typescript: "npm:^5.9.3"
|
typescript: "npm:^5.9.3"
|
||||||
vitest: "npm:^4.0.18"
|
vitest: "npm:^4.0.18"
|
||||||
@@ -3997,14 +3997,14 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"js-yaml@npm:^5.3.0":
|
"js-yaml@npm:^5.4.1":
|
||||||
version: 5.3.0
|
version: 5.4.1
|
||||||
resolution: "js-yaml@npm:5.3.0"
|
resolution: "js-yaml@npm:5.4.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
argparse: "npm:^2.0.1"
|
argparse: "npm:^2.0.1"
|
||||||
bin:
|
bin:
|
||||||
js-yaml: bin/js-yaml.mjs
|
js-yaml: bin/js-yaml.mjs
|
||||||
checksum: 10/6c7e8ea8dd5643d9df73f4aa796f3572537284e9b819b74ef919467452bfa4624f8f7477cfc775c91db7e2f32387133b1b6c4e95aef9702be6bb042ae554884a
|
checksum: 10/6fff9ee00bd59aeb7e1484b4281f5e927b117cbfbf3ffa6c0fef0c58519317eb61527e93c4aa70f417709229bc1eeed63cba773913577a64405975a72fba7180
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -5621,15 +5621,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"tar-stream@npm:^3.2.0":
|
"tar-stream@npm:^3.2.1":
|
||||||
version: 3.2.0
|
version: 3.2.1
|
||||||
resolution: "tar-stream@npm:3.2.0"
|
resolution: "tar-stream@npm:3.2.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
b4a: "npm:^1.6.4"
|
b4a: "npm:^1.6.4"
|
||||||
bare-fs: "npm:^4.5.5"
|
bare-fs: "npm:^4.5.5"
|
||||||
fast-fifo: "npm:^1.2.0"
|
fast-fifo: "npm:^1.2.0"
|
||||||
streamx: "npm:^2.15.0"
|
streamx: "npm:^2.15.0"
|
||||||
checksum: 10/ce57a81521de73ae7a3b7d55a08da50d6771427c249bfa89a208518e48faf5254c8fa7201a8f5419ab8bde9601a74e6dd512b31a13ec89774aec96178f99a8d3
|
checksum: 10/1a09f857e0789489476d99fb716fa6d209e7d19aa73b7a4b23f40eeba46792d5007ca62fde4fca8f643ed71ace1c526a293c655718a0409275a45a8aa86b562a
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user