Skip to content

Commit

Permalink
Stop double-printing output to the console
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Dec 4, 2023
1 parent 6f44f1f commit a4821ae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 57 deletions.
24 changes: 8 additions & 16 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

57 changes: 17 additions & 40 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ class NixInstallerAction {
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
// and especially GitHub Enterprise Server.
if (process.env.RUNNER_OS !== "Linux") {
if (!this.force_docker_shim) {
if (this.force_docker_shim) {
actions_core.warning(
"force-docker-shim set to true, which is only supported on Linux.",
"Ignoring force-docker-shim which is set to true, as it is only supported on Linux.",
);
this.force_docker_shim = false;
}
return;
}
Expand All @@ -129,6 +130,7 @@ class NixInstallerAction {
"Linux detected without systemd, testing for Docker with `docker info` as an alternative daemon supervisor.",
);
const exit_code = await actions_exec.exec("docker", ["info"], {
silent: true,
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
Expand Down Expand Up @@ -353,20 +355,6 @@ class NixInstallerAction {
...execution_env,
...process.env, // To get $PATH, etc
},
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
stderr: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
},
});

if (exit_code !== 0) {
Expand Down Expand Up @@ -446,6 +434,7 @@ class NixInstallerAction {
"docker",
["image", "load", "--input", images[arch]],
{
silent: true,
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
Expand Down Expand Up @@ -488,12 +477,15 @@ class NixInstallerAction {
"--mount",
"type=bind,src=/etc,dst=/etc,readonly",
"--rm",
"--restart",
"always",
"--init",
"--name",
`determinate-nix-shim-${this.correlation}`,
"determinate-nix-shim:latest",
],
{
silent: true,
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
Expand Down Expand Up @@ -575,20 +567,6 @@ class NixInstallerAction {
NIX_INSTALLER_NO_CONFIRM: "true",
...process.env, // To get $PATH, etc
},
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
stderr: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
},
},
);

Expand Down Expand Up @@ -622,7 +600,14 @@ class NixInstallerAction {
`echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee ${kvm_rules} > /dev/null`,
],
{
silent: true,
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.debug(trimmed);
}
},
stderr: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
Expand All @@ -645,6 +630,7 @@ class NixInstallerAction {
args: string[],
): Promise<void> => {
const reload_exit_code = await actions_exec.exec(command, args, {
silent: true,
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
Expand Down Expand Up @@ -682,16 +668,7 @@ class NixInstallerAction {

return true;
} catch (error) {
await actions_exec.exec("sudo", ["rm", "-f", kvm_rules], {
listeners: {
stderr: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
},
});
await actions_exec.exec("sudo", ["rm", "-f", kvm_rules]);

return false;
}
Expand Down

0 comments on commit a4821ae

Please sign in to comment.