Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit version spec for caching #100

Merged
merged 1 commit into from Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Expand Up @@ -323,6 +323,7 @@ jobs:
- master
- refs/tags/v0.5.1
- refs/pull/648/head
- 67bd6f4dc82a9cd96f34133dab3f6f7af803bb14
steps:
-
name: Checkout
Expand Down
9 changes: 7 additions & 2 deletions __tests__/buildx.test.ts
Expand Up @@ -93,12 +93,17 @@ describe('inspect', () => {
});

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);
console.log(buildxBin);
expect(fs.existsSync(buildxBin)).toBe(true);
}, 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', () => {
Expand Down
14 changes: 10 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions src/buildx.ts
Expand Up @@ -117,11 +117,16 @@ export async function build(inputBuildRef: string, dockerConfigHome: string): Pr
ref = 'master';
}

const sha = await git.getRemoteSha(repo, ref);
core.debug(`Remote ref ${sha} found`);
let vspec: string;
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;
toolPath = tc.find('buildx', sha);
toolPath = tc.find('buildx', vspec);
if (!toolPath) {
const outFolder = path.join(context.tmpDir(), 'out').split(path.sep).join(path.posix.sep);
toolPath = await exec
Expand All @@ -132,7 +137,7 @@ export async function build(inputBuildRef: string, dockerConfigHome: string): Pr
if (res.stderr.length > 0 && res.exitCode != 0) {
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);
});
}

Expand Down