mirror of
https://github.com/docker/setup-buildx-action.git
synced 2024-12-23 02:47:43 +01:00
Merge pull request #100 from crazy-max/explicit-semver
Explicit version spec for caching
This commit is contained in:
commit
abe5d8f79a
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -323,6 +323,7 @@ jobs:
|
|||||||
- master
|
- master
|
||||||
- refs/tags/v0.5.1
|
- refs/tags/v0.5.1
|
||||||
- refs/pull/648/head
|
- refs/pull/648/head
|
||||||
|
- 67bd6f4dc82a9cd96f34133dab3f6f7af803bb14
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
|
@ -93,12 +93,17 @@ describe('inspect', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('build', () => {
|
describe('build', () => {
|
||||||
it.skip('valid', async () => {
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
|
||||||
|
it.skip('builds refs/pull/648/head', async () => {
|
||||||
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#refs/pull/648/head', tmpDir);
|
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#refs/pull/648/head', tmpDir);
|
||||||
console.log(buildxBin);
|
console.log(buildxBin);
|
||||||
expect(fs.existsSync(buildxBin)).toBe(true);
|
expect(fs.existsSync(buildxBin)).toBe(true);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
it.skip('builds 67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', async () => {
|
||||||
|
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', tmpDir);
|
||||||
|
console.log(buildxBin);
|
||||||
|
expect(fs.existsSync(buildxBin)).toBe(true);
|
||||||
|
}, 100000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('install', () => {
|
describe('install', () => {
|
||||||
|
14
dist/index.js
generated
vendored
14
dist/index.js
generated
vendored
@ -151,10 +151,16 @@ function build(inputBuildRef, dockerConfigHome) {
|
|||||||
if (ref.length == 0) {
|
if (ref.length == 0) {
|
||||||
ref = 'master';
|
ref = 'master';
|
||||||
}
|
}
|
||||||
const sha = yield git.getRemoteSha(repo, ref);
|
let vspec;
|
||||||
core.debug(`Remote ref ${sha} found`);
|
if (ref.match(/^[0-9a-fA-F]{40}$/)) {
|
||||||
|
vspec = ref;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
vspec = yield git.getRemoteSha(repo, ref);
|
||||||
|
}
|
||||||
|
core.debug(`Tool version spec ${vspec}`);
|
||||||
let toolPath;
|
let toolPath;
|
||||||
toolPath = tc.find('buildx', sha);
|
toolPath = tc.find('buildx', vspec);
|
||||||
if (!toolPath) {
|
if (!toolPath) {
|
||||||
const outFolder = path.join(context.tmpDir(), 'out').split(path.sep).join(path.posix.sep);
|
const outFolder = path.join(context.tmpDir(), 'out').split(path.sep).join(path.posix.sep);
|
||||||
toolPath = yield exec
|
toolPath = yield exec
|
||||||
@ -165,7 +171,7 @@ function build(inputBuildRef, dockerConfigHome) {
|
|||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
core.warning(res.stderr.trim());
|
core.warning(res.stderr.trim());
|
||||||
}
|
}
|
||||||
return tc.cacheFile(`${outFolder}/buildx`, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', sha);
|
return tc.cacheFile(`${outFolder}/buildx`, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', vspec);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return setPlugin(toolPath, dockerConfigHome);
|
return setPlugin(toolPath, dockerConfigHome);
|
||||||
|
@ -117,11 +117,16 @@ export async function build(inputBuildRef: string, dockerConfigHome: string): Pr
|
|||||||
ref = 'master';
|
ref = 'master';
|
||||||
}
|
}
|
||||||
|
|
||||||
const sha = await git.getRemoteSha(repo, ref);
|
let vspec: string;
|
||||||
core.debug(`Remote ref ${sha} found`);
|
if (ref.match(/^[0-9a-fA-F]{40}$/)) {
|
||||||
|
vspec = ref;
|
||||||
|
} else {
|
||||||
|
vspec = await git.getRemoteSha(repo, ref);
|
||||||
|
}
|
||||||
|
core.debug(`Tool version spec ${vspec}`);
|
||||||
|
|
||||||
let toolPath: string;
|
let toolPath: string;
|
||||||
toolPath = tc.find('buildx', sha);
|
toolPath = tc.find('buildx', vspec);
|
||||||
if (!toolPath) {
|
if (!toolPath) {
|
||||||
const outFolder = path.join(context.tmpDir(), 'out').split(path.sep).join(path.posix.sep);
|
const outFolder = path.join(context.tmpDir(), 'out').split(path.sep).join(path.posix.sep);
|
||||||
toolPath = await exec
|
toolPath = await exec
|
||||||
@ -132,7 +137,7 @@ export async function build(inputBuildRef: string, dockerConfigHome: string): Pr
|
|||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
core.warning(res.stderr.trim());
|
core.warning(res.stderr.trim());
|
||||||
}
|
}
|
||||||
return tc.cacheFile(`${outFolder}/buildx`, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', sha);
|
return tc.cacheFile(`${outFolder}/buildx`, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', vspec);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user