Compare commits

...

17 Commits

Author SHA1 Message Date
CrazyMax
c3e31dcc03 Merge pull request #155 from crazy-max/alt-buildx-releases
Some checks failed
publish / publish (push) Has been cancelled
buildx: alternative release repos to download buildx
2023-08-26 12:38:54 +02:00
CrazyMax
0f8ae202d6 buildx: alternative release repos to download buildx
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-26 12:33:51 +02:00
CrazyMax
c674e727ec Merge pull request #154 from crazy-max/docker-install-stop
docker(install): stop docker daemon gracefully on linux
2023-08-26 12:20:53 +02:00
CrazyMax
a72977ca69 docker(install): stop docker daemon gracefully on linux
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-26 12:15:49 +02:00
CrazyMax
a6558f6584 docker(install): enable debug for linux
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-26 12:07:23 +02:00
CrazyMax
6a8f167e10 Merge pull request #153 from crazy-max/docker-install-linux-log
Some checks failed
publish / publish (push) Has been cancelled
docker(install): increase number of retries and log them
2023-08-26 11:30:02 +02:00
CrazyMax
19f5e39cc1 docker(install): increase number of retries and log them
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-26 11:24:43 +02:00
CrazyMax
945af30d0c Merge pull request #152 from crazy-max/docker-install-colima-log
docker(install): SIGN_QEMU_BINARY env as workaround to replace existing signature
2023-08-26 11:17:58 +02:00
CrazyMax
24a56dbe42 docker(install): SIGN_QEMU_BINARY env as workaround to replace existing signature
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-26 11:12:52 +02:00
CrazyMax
4e8d894523 docker(install): print ha.stderr.log on failure
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-26 11:12:52 +02:00
CrazyMax
5b15c952e9 Merge pull request #151 from docker/bot/buildx-lab-releases-json
Update `.github/buildx-lab-releases.json`
2023-08-26 08:39:41 +02:00
crazy-max
9822f1ac09 github: update .github/buildx-lab-releases.json
Signed-off-by: GitHub <noreply@github.com>
2023-08-26 06:39:17 +00:00
CrazyMax
b9121242ac Merge pull request #150 from crazy-max/ci-buildx-lab-releases-json
ci: generate buildx-lab-releases.json
2023-08-26 08:38:48 +02:00
CrazyMax
c759388ee4 ci: generate buildx-lab-releases.json
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-26 08:19:06 +02:00
CrazyMax
2be3d9389c Merge pull request #147 from crazy-max/docker-install-backoff
docker(install): increase number of retries
2023-08-18 11:36:20 +02:00
CrazyMax
541f8784ed docker(install): increase number of retries
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-18 11:32:07 +02:00
CrazyMax
4abccc4c6a test: docker install 24.0.5
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-18 11:32:06 +02:00
9 changed files with 325 additions and 35 deletions

84
.github/buildx-lab-releases.json vendored Normal file
View File

@@ -0,0 +1,84 @@
{
"latest": {
"id": 118213369,
"tag_name": "v0.11.2-desktop.2",
"html_url": "https://github.com/docker/buildx-desktop/releases/tag/v0.11.2-desktop.2",
"assets": [
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-amd64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-amd64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-amd64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-arm64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-arm64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-arm64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-amd64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-amd64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-amd64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v6",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v6.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v6.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v7",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v7.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v7.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-ppc64le",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-ppc64le.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-ppc64le.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-riscv64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-riscv64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-riscv64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-s390x",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-s390x.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-s390x.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-amd64.exe",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-amd64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-amd64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-arm64.exe",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-arm64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-arm64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/checksums.txt"
]
},
"v0.11.2-desktop.2": {
"id": 118213369,
"tag_name": "v0.11.2-desktop.2",
"html_url": "https://github.com/docker/buildx-desktop/releases/tag/v0.11.2-desktop.2",
"assets": [
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-amd64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-amd64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-amd64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-arm64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-arm64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.darwin-arm64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-amd64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-amd64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-amd64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v6",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v6.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v6.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v7",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v7.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm-v7.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-arm64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-ppc64le",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-ppc64le.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-ppc64le.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-riscv64",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-riscv64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-riscv64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-s390x",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-s390x.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.linux-s390x.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-amd64.exe",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-amd64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-amd64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-arm64.exe",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-arm64.provenance.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/buildx-v0.11.2-desktop.2.windows-arm64.sbom.json",
"https://github.com/docker/buildx-desktop/releases/download/v0.11.2-desktop.2/checksums.txt"
]
}
}

View File

@@ -0,0 +1,58 @@
name: buildx-lab-releases-json
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'
push:
branches:
- 'main'
pull_request:
paths-ignore:
- '.github/*-releases.json'
jobs:
generate:
uses: crazy-max/.github/.github/workflows/releases-json.yml@6dc31870ca6c4f8489bf5a408ab38fae60f47eec
with:
repository: docker/buildx-desktop
artifact_name: buildx-lab-releases-json
filename: buildx-lab-releases.json
secrets: inherit
open-pr:
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request'
needs:
- generate
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Download
uses: actions/download-artifact@v3
with:
name: buildx-lab-releases-json
path: .github
-
name: Commit changes
run: |
git add -A .
-
name: Create PR
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
with:
base: main
branch: bot/buildx-lab-releases-json
commit-message: "github: update .github/buildx-lab-releases.json"
signoff: true
delete-branch: true
title: "Update `.github/buildx-lab-releases.json`"
body: |
Update `.github/buildx-lab-releases.json` to keep in sync with [https://github.com/docker/buildx-desktop](https://github.com/docker/buildx-desktop).
draft: false

View File

@@ -88,12 +88,6 @@ describe('download', () => {
}, },
100000 100000
); );
it('returns latest buildx GitHub release', async () => {
const release = await Install.getRelease('latest');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
}); });
describe('build', () => { describe('build', () => {
@@ -116,30 +110,72 @@ describe('build', () => {
}, 100000); }, 100000);
}); });
describe('getDownloadVersion', () => {
it('returns official latest download version', async () => {
const version = await Install.getDownloadVersion('latest');
expect(version.key).toEqual('official');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json');
});
it('returns official v0.10.1 download version', async () => {
const version = await Install.getDownloadVersion('v0.10.1');
expect(version.key).toEqual('official');
expect(version.version).toEqual('v0.10.1');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json');
});
it('returns lab latest download version', async () => {
const version = await Install.getDownloadVersion('lab:latest');
expect(version.key).toEqual('lab');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
});
it('returns lab v0.11.2-desktop.2 download version', async () => {
const version = await Install.getDownloadVersion('lab:v0.11.2-desktop.2');
expect(version.key).toEqual('lab');
expect(version.version).toEqual('v0.11.2-desktop.2');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
});
it('unknown repo', async () => {
await expect(Install.getDownloadVersion('foo:bar')).rejects.toThrow(new Error('Cannot find buildx version for foo:bar'));
});
});
describe('getRelease', () => { describe('getRelease', () => {
it('returns latest buildx GitHub release', async () => { it('returns latest official GitHub release', async () => {
const release = await Install.getRelease('latest'); const version = await Install.getDownloadVersion('latest');
const release = await Install.getRelease(version);
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual(''); expect(release?.tag_name).not.toEqual('');
}); });
it('returns v0.10.1 buildx GitHub release', async () => { it('returns v0.10.1 official GitHub release', async () => {
const release = await Install.getRelease('v0.10.1'); const version = await Install.getDownloadVersion('v0.10.1');
const release = await Install.getRelease(version);
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(release?.id).toEqual(90346950); expect(release?.id).toEqual(90346950);
expect(release?.tag_name).toEqual('v0.10.1'); expect(release?.tag_name).toEqual('v0.10.1');
expect(release?.html_url).toEqual('https://github.com/docker/buildx/releases/tag/v0.10.1'); expect(release?.html_url).toEqual('https://github.com/docker/buildx/releases/tag/v0.10.1');
}); });
it('returns v0.2.2 buildx GitHub release', async () => { it('returns v0.11.2-desktop.2 lab GitHub release', async () => {
const release = await Install.getRelease('v0.2.2'); const version = await Install.getDownloadVersion('lab:v0.11.2-desktop.2');
const release = await Install.getRelease(version);
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(release?.id).toEqual(17671545); expect(release?.id).toEqual(118213369);
expect(release?.tag_name).toEqual('v0.2.2'); expect(release?.tag_name).toEqual('v0.11.2-desktop.2');
expect(release?.html_url).toEqual('https://github.com/docker/buildx/releases/tag/v0.2.2'); expect(release?.html_url).toEqual('https://github.com/docker/buildx-desktop/releases/tag/v0.11.2-desktop.2');
}); });
it('unknown release', async () => { it('unknown release', async () => {
await expect(Install.getRelease('foo')).rejects.toThrow(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json')); const version = await Install.getDownloadVersion('foo');
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json'));
}); });
}); });

View File

@@ -15,7 +15,7 @@
*/ */
import path from 'path'; import path from 'path';
import {jest, describe, expect, test} from '@jest/globals'; import {jest, describe, expect, test, beforeEach, afterEach} from '@jest/globals';
import {Install} from '../../src/docker/install'; import {Install} from '../../src/docker/install';
import {Docker} from '../../src/docker/docker'; import {Docker} from '../../src/docker/docker';
@@ -24,9 +24,19 @@ import {Docker} from '../../src/docker/docker';
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest'); const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest');
describe('install', () => { describe('install', () => {
jest.retryTimes(2, {logErrorsBeforeRetry: true}); const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
process.env = {
...originalEnv,
SIGN_QEMU_BINARY: '1'
};
});
afterEach(() => {
process.env = originalEnv;
});
// prettier-ignore // prettier-ignore
test.each(['v23.0.0'])( test.each(['v24.0.5'])(
'install docker %s', async (version) => { 'install docker %s', async (version) => {
await expect((async () => { await expect((async () => {
const install = new Install({ const install = new Install({
@@ -40,5 +50,5 @@ describe('install', () => {
await Docker.printInfo(); await Docker.printInfo();
await install.tearDown(); await install.tearDown();
})()).resolves.not.toThrow(); })()).resolves.not.toThrow();
}); }, 600000);
}); });

View File

@@ -32,6 +32,7 @@ import {Docker} from '../docker/docker';
import {Git} from '../git'; import {Git} from '../git';
import {Util} from '../util'; import {Util} from '../util';
import {DownloadVersion} from '../types/buildx';
import {GitHubRelease} from '../types/github'; import {GitHubRelease} from '../types/github';
export interface InstallOpts { export interface InstallOpts {
@@ -50,7 +51,10 @@ export class Install {
* @param version semver version or latest * @param version semver version or latest
* @returns path to the buildx binary * @returns path to the buildx binary
*/ */
public async download(version: string): Promise<string> { public async download(v: string): Promise<string> {
const version: DownloadVersion = await Install.getDownloadVersion(v);
core.debug(`Install.download version: ${version.version}`);
const release: GitHubRelease = await Install.getRelease(version); const release: GitHubRelease = await Install.getRelease(version);
core.debug(`Install.download release tag name: ${release.tag_name}`); core.debug(`Install.download release tag name: ${release.tag_name}`);
@@ -62,7 +66,7 @@ export class Install {
throw new Error(`Invalid Buildx version "${vspec}".`); throw new Error(`Invalid Buildx version "${vspec}".`);
} }
const installCache = new InstallCache('buildx-dl-bin', vspec); const installCache = new InstallCache(version.key != 'official' ? `buildx-dl-bin-${version.key}` : 'buildx-dl-bin', vspec);
const cacheFoundPath = await installCache.find(); const cacheFoundPath = await installCache.find();
if (cacheFoundPath) { if (cacheFoundPath) {
@@ -70,7 +74,7 @@ export class Install {
return cacheFoundPath; return cacheFoundPath;
} }
const downloadURL = util.format('https://github.com/docker/buildx/releases/download/v%s/%s', vspec, this.filename(vspec)); const downloadURL = util.format(version.downloadURL, vspec, this.filename(vspec));
core.info(`Downloading ${downloadURL}`); core.info(`Downloading ${downloadURL}`);
const htcDownloadPath = await tc.downloadTool(downloadURL); const htcDownloadPath = await tc.downloadTool(downloadURL);
@@ -253,20 +257,48 @@ export class Install {
return hash; return hash;
} }
public static async getRelease(version: string): Promise<GitHubRelease> { public static async getDownloadVersion(v: string): Promise<DownloadVersion> {
const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json`; let [repoKey, version] = v.split(':');
if (!version) {
version = repoKey;
repoKey = 'official';
}
switch (repoKey) {
case 'official': {
return {
key: repoKey,
version: version,
downloadURL: 'https://github.com/docker/buildx/releases/download/v%s/%s',
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json'
};
}
case 'lab': {
return {
key: repoKey,
version: version,
downloadURL: 'https://github.com/docker/buildx-desktop/releases/download/v%s/%s',
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json'
};
}
default: {
throw new Error(`Cannot find buildx version for ${v}`);
}
}
}
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit'); const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
const resp: httpm.HttpClientResponse = await http.get(url); const resp: httpm.HttpClientResponse = await http.get(version.releasesURL);
const body = await resp.readBody(); const body = await resp.readBody();
const statusCode = resp.message.statusCode || 500; const statusCode = resp.message.statusCode || 500;
if (statusCode >= 400) { if (statusCode >= 400) {
throw new Error(`Failed to get Buildx release ${version} from ${url} with status code ${statusCode}: ${body}`); throw new Error(`Failed to get Buildx releases from ${version.releasesURL} with status code ${statusCode}: ${body}`);
} }
const releases = <Record<string, GitHubRelease>>JSON.parse(body); const releases = <Record<string, GitHubRelease>>JSON.parse(body);
if (!releases[version]) { if (!releases[version.version]) {
throw new Error(`Cannot find Buildx release ${version} in ${url}`); throw new Error(`Cannot find Buildx release ${version.version} in ${version.releasesURL}`);
} }
return releases[version]; return releases[version.version];
} }
} }

View File

@@ -72,6 +72,7 @@ mkdir -p "$RUNDIR"
echo "Starting dockerd" echo "Starting dockerd"
set -x set -x
exec dockerd \\ exec dockerd \\
--debug \\
--host="$DOCKER_HOST" \\ --host="$DOCKER_HOST" \\
--exec-root="$RUNDIR/execroot" \\ --exec-root="$RUNDIR/execroot" \\
--data-root="$RUNDIR/data" \\ --data-root="$RUNDIR/data" \\
@@ -336,3 +337,14 @@ mounts: []
# Default: {} # Default: {}
env: {} env: {}
`; `;
export const qemuEntitlements = `
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.hypervisor</key>
<true/>
</dict>
</plist>
`;

View File

@@ -29,7 +29,7 @@ import * as tc from '@actions/tool-cache';
import {Context} from '../context'; import {Context} from '../context';
import {Exec} from '../exec'; import {Exec} from '../exec';
import {Util} from '../util'; import {Util} from '../util';
import {colimaYamlData, dockerServiceLogsPs1, setupDockerLinuxSh, setupDockerWinPs1} from './assets'; import {colimaYamlData, dockerServiceLogsPs1, qemuEntitlements, setupDockerLinuxSh, setupDockerWinPs1} from './assets';
import {GitHubRelease} from '../types/github'; import {GitHubRelease} from '../types/github';
export interface InstallOpts { export interface InstallOpts {
@@ -147,6 +147,21 @@ export class Install {
core.info(colimaCfg); core.info(colimaCfg);
}); });
const qemuArch = await Install.qemuArch();
await core.group('QEMU version', async () => {
await Exec.exec(`qemu-system-${qemuArch} --version`);
});
// https://github.com/abiosoft/colima/issues/786#issuecomment-1693629650
if (process.env.SIGN_QEMU_BINARY === '1') {
await core.group('Signing QEMU binary with entitlements', async () => {
const qemuEntitlementsFile = path.join(Context.tmpDir(), 'qemu-entitlements.xml');
core.info(`Writing entitlements to ${qemuEntitlementsFile}`);
fs.writeFileSync(qemuEntitlementsFile, qemuEntitlements);
await Exec.exec(`codesign --sign - --entitlements ${qemuEntitlementsFile} --force /usr/local/bin/qemu-system-${qemuArch}`);
});
}
// colima is already started on the runner so env var added in download // colima is already started on the runner so env var added in download
// method is not expanded to the running process. // method is not expanded to the running process.
const envs = Object.assign({}, process.env, { const envs = Object.assign({}, process.env, {
@@ -154,8 +169,17 @@ export class Install {
}) as { }) as {
[key: string]: string; [key: string]: string;
}; };
await core.group('Starting colima', async () => { await core.group('Starting colima', async () => {
await Exec.exec('colima', ['start', '--very-verbose'], {env: envs}); try {
await Exec.exec('colima', ['start', '--very-verbose'], {env: envs});
} catch (e) {
const haStderrLog = path.join(os.homedir(), '.lima', 'colima', 'ha.stderr.log');
if (fs.existsSync(haStderrLog)) {
core.info(`Printing debug logs (${haStderrLog}):\n${fs.readFileSync(haStderrLog, {encoding: 'utf8'})}`);
}
throw e;
}
}); });
await core.group('Create Docker context', async () => { await core.group('Create Docker context', async () => {
@@ -183,6 +207,7 @@ export class Install {
} }
}); });
proc.unref(); proc.unref();
const retries = 20;
await retry( await retry(
async bail => { async bail => {
await Exec.getExecOutput(`docker version`, undefined, { await Exec.getExecOutput(`docker version`, undefined, {
@@ -207,7 +232,11 @@ export class Install {
}); });
}, },
{ {
retries: 5 retries: retries,
minTimeout: 1000,
onRetry: (err, i) => {
core.info(`${err}. Retrying (${i}/${retries})...`);
}
} }
); );
core.info(`Docker daemon started started successfully`); core.info(`Docker daemon started started successfully`);
@@ -282,13 +311,17 @@ export class Install {
core.info(fs.readFileSync(path.join(this.runDir, 'dockerd.log'), {encoding: 'utf8'})); core.info(fs.readFileSync(path.join(this.runDir, 'dockerd.log'), {encoding: 'utf8'}));
}); });
await core.group('Stopping Docker daemon', async () => { await core.group('Stopping Docker daemon', async () => {
await Exec.exec('sudo', ['kill', fs.readFileSync(path.join(this.runDir, 'docker.pid')).toString().trim()]); await Exec.exec('sudo', ['kill', '-s', 'SIGTERM', fs.readFileSync(path.join(this.runDir, 'docker.pid')).toString().trim()]);
await Util.sleep(5);
}); });
await core.group('Removing Docker context', async () => { await core.group('Removing Docker context', async () => {
await Exec.exec('docker', ['context', 'rm', '-f', this.contextName]); await Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
}); });
await core.group(`Cleaning up runDir`, async () => { await core.group(`Cleaning up runDir`, async () => {
await Exec.exec('sudo', ['rm', '-rf', this.runDir]); await Exec.exec('sudo', ['rm', '-rf', this.runDir], {
ignoreReturnCode: true,
failOnStdErr: false
});
}); });
} }
@@ -368,6 +401,20 @@ export class Install {
}); });
} }
private static async qemuArch(): Promise<string> {
switch (os.arch()) {
case 'x64': {
return 'x86_64';
}
case 'arm64': {
return 'aarch64';
}
default: {
return os.arch();
}
}
}
public static async getRelease(version: string): Promise<GitHubRelease> { public static async getRelease(version: string): Promise<GitHubRelease> {
const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json`; const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json`;
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit'); const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');

View File

@@ -19,3 +19,10 @@ export interface Cert {
cert?: string; cert?: string;
key?: string; key?: string;
} }
export interface DownloadVersion {
key: string;
version: string;
downloadURL: string;
releasesURL: string;
}

View File

@@ -133,4 +133,8 @@ export class Util {
} }
return str.substring(0, index); return str.substring(0, index);
} }
public static sleep(seconds: number) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
} }