Skip to content

Commit 473d258

Browse files
authored
Merge pull request #880 from crazy-max/pin-qemu
docker(install): pin QEMU to 10.1.1
2 parents 841fd33 + 8d87ba5 commit 473d258

File tree

3 files changed

+88
-51
lines changed

3 files changed

+88
-51
lines changed

.github/actions/macos-setup-qemu/action.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,22 @@ jobs:
109109
for (const os of ['ubuntu-latest', 'ubuntu-24.04-arm', 'macos-15-intel', 'windows-latest']) {
110110
for (const test of tests) {
111111
if (test === 'docker/install.test.itg.ts') {
112-
// FIXME: docker install tests on macOS are currently broken: https://github.com/docker/actions-toolkit/issues/852
113-
if (!os.startsWith('macos')) {
114-
if (os !== 'windows-latest') {
115-
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: '27.3.1' });
116-
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: 'master' });
117-
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: 'latest' });
118-
}
119-
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'v26.1.4' });
120-
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'latest' });
121-
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'v29.0.0-rc.1', docker_install_channel: 'test' });
122-
if (os === 'ubuntu-latest') {
123-
includes.push({ os: os, test: test, test_name: 'rootless', docker_install_type: 'image', docker_install_version: 'latest' });
124-
includes.push({ os: os, test: test, test_name: 'rootless', docker_install_type: 'archive', docker_install_version: 'latest' });
125-
}
126-
if (os !== 'windows-latest') {
127-
includes.push({ os: os, test: test, test_name: 'tcp', docker_install_type: 'image', docker_install_version: 'latest' });
128-
}
129-
includes.push({ os: os, test: test, test_name: 'tcp', docker_install_type: 'archive', docker_install_version: 'latest' });
112+
if (os !== 'windows-latest') {
113+
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: '27.3.1' });
114+
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: 'master' });
115+
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: 'latest' });
130116
}
117+
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'v26.1.4' });
118+
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'latest' });
119+
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'v29.0.0-rc.1', docker_install_channel: 'test' });
120+
if (os === 'ubuntu-latest') {
121+
includes.push({ os: os, test: test, test_name: 'rootless', docker_install_type: 'image', docker_install_version: 'latest' });
122+
includes.push({ os: os, test: test, test_name: 'rootless', docker_install_type: 'archive', docker_install_version: 'latest' });
123+
}
124+
if (os !== 'windows-latest') {
125+
includes.push({ os: os, test: test, test_name: 'tcp', docker_install_type: 'image', docker_install_version: 'latest' });
126+
}
127+
includes.push({ os: os, test: test, test_name: 'tcp', docker_install_type: 'archive', docker_install_version: 'latest' });
131128
} else {
132129
includes.push({ os: os, test: test });
133130
}

src/docker/install.ts

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,12 @@ export class Install {
269269
await io.mkdirP(limaDir);
270270
const dockerHost = `unix://${limaDir}/docker.sock`;
271271

272-
// avoid brew to auto update and upgrade unrelated packages.
273-
let envs = Object.assign({}, process.env, {
274-
HOMEBREW_NO_AUTO_UPDATE: '1',
275-
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: '1'
276-
}) as {
277-
[key: string]: string;
278-
};
279-
280272
if (!(await Install.limaInstalled())) {
281-
await core.group('Installing lima', async () => {
282-
await Exec.exec('brew', ['install', 'lima'], {env: envs});
283-
});
273+
await this.brewInstall('lima');
284274
}
285275

286276
await core.group('Lima version', async () => {
287-
await Exec.exec('lima', ['--version'], {env: envs});
277+
await Exec.exec('lima', ['--version']);
288278
});
289279

290280
await core.group('Creating lima config', async () => {
@@ -313,9 +303,8 @@ export class Install {
313303
});
314304

315305
if (!(await Install.qemuInstalled())) {
316-
await core.group('Installing QEMU', async () => {
317-
await Exec.exec('brew', ['install', 'qemu'], {env: envs});
318-
});
306+
// FIXME: QEMU 10.1.2 seems to break on GitHub runners. Pin to 10.1.1 in the meantime: https://github.com/docker/actions-toolkit/issues/852
307+
await this.brewInstall('qemu', '4a7a2dd5d44d068b3e89ebed5be7b4ada315d221');
319308
}
320309
const qemuBin = await Install.qemuBin();
321310
await core.group('QEMU version', async () => {
@@ -324,7 +313,7 @@ export class Install {
324313

325314
// lima might already be started on the runner so env var added in download
326315
// method is not expanded to the running process.
327-
envs = Object.assign({}, envs, {
316+
const envs = Object.assign({}, process.env, {
328317
PATH: `${this.toolDir}:${process.env.PATH}`
329318
}) as {
330319
[key: string]: string;
@@ -751,4 +740,72 @@ EOF`,
751740
});
752741
return <Image>JSON.parse(blob);
753742
}
743+
744+
private async brewInstall(packageName: string, revision?: string): Promise<void> {
745+
// avoid brew to auto update and upgrade unrelated packages.
746+
const envs = Object.assign({}, process.env, {
747+
HOMEBREW_NO_AUTO_UPDATE: '1',
748+
HOMEBREW_NO_INSTALL_UPGRADE: '1',
749+
HOMEBREW_NO_INSTALL_CLEANUP: '1'
750+
}) as {
751+
[key: string]: string;
752+
};
753+
754+
await core.group(`Installing ${packageName}`, async () => {
755+
if (!revision) {
756+
await Exec.exec('brew', ['install', packageName]);
757+
} else {
758+
const dockerTap = 'docker-actions-toolkit/tap';
759+
const hasDockerTap = await Exec.getExecOutput('brew', ['tap'], {
760+
ignoreReturnCode: true,
761+
silent: true,
762+
env: envs
763+
}).then(res => {
764+
if (res.stderr.length > 0 && res.exitCode != 0) {
765+
throw new Error(res.stderr);
766+
}
767+
for (const line of res.stdout.trim().split('\n')) {
768+
if (line.includes(dockerTap)) {
769+
return true;
770+
}
771+
}
772+
return false;
773+
});
774+
if (!hasDockerTap) {
775+
await Exec.exec('brew', ['tap-new', dockerTap], {env: envs});
776+
}
777+
const brewRepoTapPath = await Exec.getExecOutput('brew', ['--repo', dockerTap], {
778+
ignoreReturnCode: true,
779+
silent: true,
780+
env: envs
781+
}).then(res => {
782+
if (res.stderr.length > 0 && res.exitCode != 0) {
783+
throw new Error(res.stderr);
784+
}
785+
return res.stdout.trim();
786+
});
787+
const formulaURL = `https://raw.githubusercontent.com/Homebrew/homebrew-core/${revision}/Formula/${packageName.charAt(0)}/${packageName}.rb`;
788+
await tc.downloadTool(formulaURL, path.join(brewRepoTapPath, 'Formula', `${packageName}.rb`));
789+
const hasFormulaInstalled = await Exec.getExecOutput('brew', ['ls', '-1'], {
790+
ignoreReturnCode: true,
791+
silent: true,
792+
env: envs
793+
}).then(res => {
794+
if (res.stderr.length > 0 && res.exitCode != 0) {
795+
throw new Error(res.stderr);
796+
}
797+
for (const line of res.stdout.trim().split('\n')) {
798+
if (line.trim() == packageName) {
799+
return true;
800+
}
801+
}
802+
return false;
803+
});
804+
if (hasFormulaInstalled) {
805+
await Exec.exec('brew', ['uninstall', packageName, '--ignore-dependencies'], {env: envs});
806+
}
807+
await Exec.exec('brew', ['install', `${dockerTap}/${packageName}`], {env: envs});
808+
}
809+
});
810+
}
754811
}

0 commit comments

Comments
 (0)