mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-25 17:08:32 +01:00
Prevent the Action from failing with strict mode disabled
This commit is contained in:
parent
39afc6d4a9
commit
7afbb0a392
3 changed files with 44 additions and 15 deletions
27
dist/index.js
generated
vendored
27
dist/index.js
generated
vendored
|
@ -94091,7 +94091,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
|
|||
const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
|
||||
;// CONCATENATED MODULE: external "node:zlib"
|
||||
const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:zlib");
|
||||
;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@fe64ba33b4bdeec0991bb65ae00420bf68b9954c_ler7zqcm5mrt635umsvjcuxcmy/node_modules/detsys-ts/dist/index.js
|
||||
;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@138ea0123a2a3c61fad2c998729b661405132119_63ifpzamfkw2vbemnszqtdfmnu/node_modules/detsys-ts/dist/index.js
|
||||
var __defProp = Object.defineProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
|
@ -94794,7 +94794,7 @@ var DetSysAction = class {
|
|||
this.nixStoreTrust = "unknown";
|
||||
this.strictMode = getBool("_internal-strict-mode");
|
||||
this.features = {};
|
||||
this.featureEventMetadata = /* @__PURE__ */ new Map();
|
||||
this.featureEventMetadata = {};
|
||||
this.events = [];
|
||||
this.client = got_dist_source.extend({
|
||||
retry: {
|
||||
|
@ -95001,7 +95001,7 @@ var DetSysAction = class {
|
|||
}
|
||||
this.features = checkin.options;
|
||||
for (const [key, feature] of Object.entries(this.features)) {
|
||||
this.featureEventMetadata.set(key, feature.variant);
|
||||
this.featureEventMetadata[key] = feature.variant;
|
||||
}
|
||||
const impactSymbol = /* @__PURE__ */ new Map([
|
||||
["none", "\u26AA"],
|
||||
|
@ -95653,9 +95653,13 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
await new Promise((resolve, reject) => {
|
||||
notifyPromise.then((_value) => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
const msg = `error in notifyPromise: ${err}`;
|
||||
reject(new Error(msg));
|
||||
}).catch((e) => {
|
||||
const msg = stringifyError(e);
|
||||
if (this.strictMode) {
|
||||
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||
} else {
|
||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||
}
|
||||
});
|
||||
daemon.on("exit", async (code, signal) => {
|
||||
let msg;
|
||||
|
@ -95733,7 +95737,11 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
process.kill(pid, "SIGTERM");
|
||||
} catch (e) {
|
||||
if (typeof e === "object" && e && "code" in e && e.code !== "ESRCH") {
|
||||
throw e;
|
||||
if (this.strictMode) {
|
||||
throw e;
|
||||
} else {
|
||||
this.exitWithWarning(`couldn't kill daemon: ${stringifyError(e)}`);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (core.isDebug()) {
|
||||
|
@ -95743,6 +95751,11 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
}
|
||||
}
|
||||
}
|
||||
exitWithWarning(msg) {
|
||||
core.warning(msg);
|
||||
core.warning(`strict mode not enabled; exiting`);
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
function main() {
|
||||
new MagicNixCacheAction().execute();
|
||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
30
src/index.ts
30
src/index.ts
|
@ -1,6 +1,6 @@
|
|||
import { netrcPath, tailLog } from "./helpers.js";
|
||||
import * as actionsCore from "@actions/core";
|
||||
import { DetSysAction, inputs } from "detsys-ts";
|
||||
import { DetSysAction, inputs, stringifyError } from "detsys-ts";
|
||||
import got, { Got, Response } from "got";
|
||||
import * as http from "http";
|
||||
import { SpawnOptions, spawn } from "node:child_process";
|
||||
|
@ -259,9 +259,14 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
resolve();
|
||||
})
|
||||
// eslint-disable-next-line github/no-then
|
||||
.catch((err) => {
|
||||
const msg = `error in notifyPromise: ${err}`;
|
||||
reject(new Error(msg));
|
||||
.catch((e: unknown) => {
|
||||
const msg = stringifyError(e);
|
||||
|
||||
if (this.strictMode) {
|
||||
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||
} else {
|
||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||
}
|
||||
});
|
||||
daemon.on("exit", async (code, signal) => {
|
||||
let msg: string;
|
||||
|
@ -306,7 +311,7 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
}
|
||||
|
||||
actionsCore.debug(`back from post: ${res.body}`);
|
||||
} catch (e) {
|
||||
} catch (e: unknown) {
|
||||
actionsCore.info(`Error marking the workflow as started:`);
|
||||
actionsCore.info(inspect(e));
|
||||
actionsCore.info(`Magic Nix Cache may not be running for this workflow.`);
|
||||
|
@ -350,11 +355,16 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
}
|
||||
|
||||
actionsCore.debug(`killing`);
|
||||
|
||||
try {
|
||||
process.kill(pid, "SIGTERM");
|
||||
} catch (e) {
|
||||
} catch (e: unknown) {
|
||||
if (typeof e === "object" && e && "code" in e && e.code !== "ESRCH") {
|
||||
throw e;
|
||||
if (this.strictMode) {
|
||||
throw e;
|
||||
} else {
|
||||
this.exitWithWarning(`couldn't kill daemon: ${stringifyError(e)}`);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (actionsCore.isDebug()) {
|
||||
|
@ -364,6 +374,12 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private exitWithWarning(msg: string): void {
|
||||
actionsCore.warning(msg);
|
||||
actionsCore.warning(`strict mode not enabled; exiting`);
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
function main(): void {
|
||||
|
|
Loading…
Reference in a new issue