Skip to content

Commit

Permalink
buildx: install release binaries from a fork
Browse files Browse the repository at this point in the history
adds a new API method that uses the github releases API
to find the appropriate version to download.

Signed-off-by: Nick Santos <nick.santos@docker.com>
  • Loading branch information
nicks committed Jul 3, 2023
1 parent ca519e1 commit d299bba
Show file tree
Hide file tree
Showing 4 changed files with 1,285 additions and 1 deletion.
19 changes: 19 additions & 0 deletions __tests__/buildx/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ import * as fs from 'fs';
import * as path from 'path';
import * as rimraf from 'rimraf';
import osm = require('os');
import * as github from '@actions/github';

import {Install} from '../../src/buildx/install';

const release_0_11_0 = require('./release-v0.11.0.json');

// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');

Expand Down Expand Up @@ -105,6 +108,22 @@ describe('build', () => {
}, 100000);
});

describe('installReleaseFromFork', () => {
it('installs v0.11.0 by querying github releases', async () => {
jest.spyOn(github, 'getOctokit').mockImplementation(() => {
const request = () => Promise.resolve({data: release_0_11_0});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return {request} as any;
});
const install = new Install();
const toolPath = await install.installReleaseFromFork('https://github.com/docker/buildx.git#v0.11.0');
expect(fs.existsSync(toolPath)).toBe(true);
const buildxBin = await install.installStandalone(toolPath, tmpDir);
expect(fs.existsSync(buildxBin)).toBe(true);
}, 100000);
});

describe('getRelease', () => {
it('returns latest buildx GitHub release', async () => {
const release = await Install.getRelease('latest');
Expand Down
Loading

0 comments on commit d299bba

Please sign in to comment.