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

docker(install): check qemu is installed #493

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions src/docker/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,14 @@ export class Install {
core.info(limaCfg);
});

const qemuArch = await Install.qemuArch();
if (!(await Install.qemuInstalled())) {
await core.group('Installing QEMU', async () => {
await Exec.exec('brew', ['install', 'qemu'], {env: envs});
});
}
const qemuBin = await Install.qemuBin();
await core.group('QEMU version', async () => {
await Exec.exec(`qemu-system-${qemuArch} --version`);
await Exec.exec(qemuBin, ['--version']);
});

// lima might already be started on the runner so env var added in download
Expand Down Expand Up @@ -617,29 +622,42 @@ EOF`,
return await io
.which('lima', true)
.then(res => {
core.debug(`docker.Install.limaAvailable ok: ${res}`);
core.debug(`docker.Install.limaInstalled ok: ${res}`);
return true;
})
.catch(error => {
core.debug(`docker.Install.limaAvailable error: ${error}`);
core.debug(`docker.Install.limaInstalled error: ${error}`);
return false;
});
}

private static async qemuArch(): Promise<string> {
private static async qemuBin(): Promise<string> {
switch (os.arch()) {
case 'x64': {
return 'x86_64';
return `qemu-system-x86_64`;
}
case 'arm64': {
return 'aarch64';
return `qemu-system-aarch64`;
}
default: {
return os.arch();
return `qemu-system-${os.arch()}`;
}
}
}

private static async qemuInstalled(): Promise<boolean> {
return await io
.which(await Install.qemuBin(), true)
.then(res => {
core.debug(`docker.Install.qemuInstalled ok: ${res}`);
return true;
})
.catch(error => {
core.debug(`docker.Install.qemuInstalled error: ${error}`);
return false;
});
}

public static async getRelease(version: string): Promise<GitHubRelease> {
const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json`;
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
Expand Down
Loading