Skip to content

Commit

Permalink
action: post-run-job: try clean daemon container, warn on failure (#61)
Browse files Browse the repository at this point in the history
* flake: add typescript LSP tool

* action: post-run-job: try clean daemon container, warn on failure
  • Loading branch information
colemickens authored Dec 19, 2023
1 parent cd46bde commit 21affdd
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
22 changes: 21 additions & 1 deletion 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.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
packages = with pkgs; [
nodejs_latest
nixpkgs-fmt
nodePackages_latest.typescript-language-server
];
};
});
Expand Down
27 changes: 26 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,35 @@ class NixInstallerAction {
}
async cleanupDockerShim(): Promise<void> {
const container_id = actions_core.getState("docker_shim_container_id");

if (container_id !== "") {
actions_core.startGroup("Cleaning up the Nix daemon's Docker shim");

await actions_exec.exec("docker", ["rm", "--force", container_id]);
let cleaned = false;
try {
await actions_exec.exec("docker", ["rm", "--force", container_id]);
cleaned = true;
} catch {
actions_core.warning("failed to cleanup nix daemon container");
}

if (!cleaned) {
actions_core.info("trying to pkill the container's shim process");
try {
await actions_exec.exec("pkill", [container_id]);
cleaned = true;
} catch {
actions_core.warning(
"failed to forcibly kill the container's shim process",
);
}
}

if (!cleaned) {
actions_core.warning(
"Giving up on cleaning up the nix daemon container",
);
}

actions_core.endGroup();
}
Expand Down

0 comments on commit 21affdd

Please sign in to comment.