Skip to content

Commit abe5d8f

Browse files
authored
Merge pull request #100 from crazy-max/explicit-semver
Explicit version spec for caching
2 parents e673438 + 580d5c7 commit abe5d8f

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ jobs:
323323
- master
324324
- refs/tags/v0.5.1
325325
- refs/pull/648/head
326+
- 67bd6f4dc82a9cd96f34133dab3f6f7af803bb14
326327
steps:
327328
-
328329
name: Checkout

__tests__/buildx.test.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,17 @@ describe('inspect', () => {
9393
});
9494

9595
describe('build', () => {
96-
it.skip('valid', async () => {
97-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
96+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
97+
it.skip('builds refs/pull/648/head', async () => {
9898
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#refs/pull/648/head', tmpDir);
9999
console.log(buildxBin);
100100
expect(fs.existsSync(buildxBin)).toBe(true);
101101
}, 100000);
102+
it.skip('builds 67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', async () => {
103+
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', tmpDir);
104+
console.log(buildxBin);
105+
expect(fs.existsSync(buildxBin)).toBe(true);
106+
}, 100000);
102107
});
103108

104109
describe('install', () => {

dist/index.js

+10-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/buildx.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,16 @@ export async function build(inputBuildRef: string, dockerConfigHome: string): Pr
117117
ref = 'master';
118118
}
119119

120-
const sha = await git.getRemoteSha(repo, ref);
121-
core.debug(`Remote ref ${sha} found`);
120+
let vspec: string;
121+
if (ref.match(/^[0-9a-fA-F]{40}$/)) {
122+
vspec = ref;
123+
} else {
124+
vspec = await git.getRemoteSha(repo, ref);
125+
}
126+
core.debug(`Tool version spec ${vspec}`);
122127

123128
let toolPath: string;
124-
toolPath = tc.find('buildx', sha);
129+
toolPath = tc.find('buildx', vspec);
125130
if (!toolPath) {
126131
const outFolder = path.join(context.tmpDir(), 'out').split(path.sep).join(path.posix.sep);
127132
toolPath = await exec
@@ -132,7 +137,7 @@ export async function build(inputBuildRef: string, dockerConfigHome: string): Pr
132137
if (res.stderr.length > 0 && res.exitCode != 0) {
133138
core.warning(res.stderr.trim());
134139
}
135-
return tc.cacheFile(`${outFolder}/buildx`, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', sha);
140+
return tc.cacheFile(`${outFolder}/buildx`, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', vspec);
136141
});
137142
}
138143

0 commit comments

Comments
 (0)