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

Gracefully fail for missing tools. #14

Merged
merged 1 commit into from
Aug 5, 2023
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
42 changes: 36 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,29 @@ runs:

if (`${process.env.RUNNER_OS}` == 'Linux') {
await core.group(`Install deps`, async () => {
await exec.exec('sudo apt-get update');
await exec.exec('sudo apt-get install -y cgroup-tools cpuid');
const sudo = await exec.getExecOutput('which sudo', [], {silent: true, ignoreReturnCode: true})
if (sudo.stdout != "") {
const aptget = await exec.getExecOutput('which apt-get', [], {silent: true, ignoreReturnCode: true})
if (aptget.stdout != "") {
await exec.exec('sudo apt-get update');
await exec.exec('sudo apt-get install -y cgroup-tools cpuid');
} else {
core.info('apt-get not found; not installing deps')
}
} else {
core.info('sudo not found; not installing deps')
}
});
await core.group(`Print cpuinfo`, async () => {
await exec.exec('cat /proc/cpuinfo');
});
await core.group(`Print cpuid`, async () => {
await exec.exec('cpuid');
const cpuid = await exec.getExecOutput('which cpuid', [], {silent: true, ignoreReturnCode: true})
if (cpuid.stdout != "") {
await exec.exec('cpuid');
} else {
core.info('cpuid not found')
}
});
await core.group(`File system`, async () => {
await exec.exec('df -ah');
Expand All @@ -78,13 +93,28 @@ runs:
await exec.exec('mount');
});
await core.group(`Docker daemon conf`, async () => {
core.info(JSON.stringify(JSON.parse(fs.readFileSync('/etc/docker/daemon.json', {encoding: 'utf-8'}).trim()), null, 2));
if ((fs.statSync('/etc/docker', {throwIfNoEntry: false}) != undefined) &&
(fs.statSync('/etc/docker/daemon.json', {throwIfNoEntry: false}) != undefined)) {
core.info(JSON.stringify(JSON.parse(fs.readFileSync('/etc/docker/daemon.json', {encoding: 'utf-8'}).trim()), null, 2));
} else {
core.info('/etc/docker/daemon.json not present')
}
});
await core.group(`Cgroups`, async () => {
await exec.exec('lscgroup');
const lscgroup = await exec.getExecOutput('which lscgroup', [], {silent: true, ignoreReturnCode: true})
if (lscgroup.stdout != "") {
await exec.exec('lscgroup');
} else {
core.info('lscgroup not found')
}
});
await core.group(`containerd version`, async () => {
await exec.exec('containerd --version');
const containerd = await exec.getExecOutput('which containerd', [], {silent: true, ignoreReturnCode: true})
if (containerd.stdout != "") {
await exec.exec('containerd --version');
} else {
core.info('containerd not found')
}
});
}
env:
Expand Down