action: post-run-job: try clean daemon container, warn on failure (#61)

* flake: add typescript LSP tool

* action: post-run-job: try clean daemon container, warn on failure
This commit is contained in:
Cole Mickens 2023-12-19 10:01:56 -06:00 committed by GitHub
parent cd46bde16a
commit 21affdd5d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 3 deletions

22
dist/index.js generated vendored
View File

@ -413,7 +413,27 @@ class NixInstallerAction {
const container_id = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getState("docker_shim_container_id");
if (container_id !== "") {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.startGroup("Cleaning up the Nix daemon's Docker shim");
await _actions_exec__WEBPACK_IMPORTED_MODULE_3__.exec("docker", ["rm", "--force", container_id]);
let cleaned = false;
try {
await _actions_exec__WEBPACK_IMPORTED_MODULE_3__.exec("docker", ["rm", "--force", container_id]);
cleaned = true;
}
catch (_a) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.warning("failed to cleanup nix daemon container");
}
if (!cleaned) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info("trying to pkill the container's shim process");
try {
await _actions_exec__WEBPACK_IMPORTED_MODULE_3__.exec("pkill", [container_id]);
cleaned = true;
}
catch (_b) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.warning("failed to forcibly kill the container's shim process");
}
}
if (!cleaned) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.warning("Giving up on cleaning up the nix daemon container");
}
_actions_core__WEBPACK_IMPORTED_MODULE_0__.endGroup();
}
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -22,6 +22,7 @@
packages = with pkgs; [
nodejs_latest
nixpkgs-fmt
nodePackages_latest.typescript-language-server
];
};
});

View File

@ -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();
}