mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-26 17:30:34 +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
25
dist/index.js
generated
vendored
25
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");
|
const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
|
||||||
;// CONCATENATED MODULE: external "node:zlib"
|
;// CONCATENATED MODULE: external "node:zlib"
|
||||||
const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("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 __defProp = Object.defineProperty;
|
||||||
var __export = (target, all) => {
|
var __export = (target, all) => {
|
||||||
for (var name in all)
|
for (var name in all)
|
||||||
|
@ -94794,7 +94794,7 @@ var DetSysAction = class {
|
||||||
this.nixStoreTrust = "unknown";
|
this.nixStoreTrust = "unknown";
|
||||||
this.strictMode = getBool("_internal-strict-mode");
|
this.strictMode = getBool("_internal-strict-mode");
|
||||||
this.features = {};
|
this.features = {};
|
||||||
this.featureEventMetadata = /* @__PURE__ */ new Map();
|
this.featureEventMetadata = {};
|
||||||
this.events = [];
|
this.events = [];
|
||||||
this.client = got_dist_source.extend({
|
this.client = got_dist_source.extend({
|
||||||
retry: {
|
retry: {
|
||||||
|
@ -95001,7 +95001,7 @@ var DetSysAction = class {
|
||||||
}
|
}
|
||||||
this.features = checkin.options;
|
this.features = checkin.options;
|
||||||
for (const [key, feature] of Object.entries(this.features)) {
|
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([
|
const impactSymbol = /* @__PURE__ */ new Map([
|
||||||
["none", "\u26AA"],
|
["none", "\u26AA"],
|
||||||
|
@ -95653,9 +95653,13 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
notifyPromise.then((_value) => {
|
notifyPromise.then((_value) => {
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((err) => {
|
}).catch((e) => {
|
||||||
const msg = `error in notifyPromise: ${err}`;
|
const msg = stringifyError(e);
|
||||||
reject(new Error(msg));
|
if (this.strictMode) {
|
||||||
|
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||||
|
} else {
|
||||||
|
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
daemon.on("exit", async (code, signal) => {
|
daemon.on("exit", async (code, signal) => {
|
||||||
let msg;
|
let msg;
|
||||||
|
@ -95733,7 +95737,11 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
process.kill(pid, "SIGTERM");
|
process.kill(pid, "SIGTERM");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (typeof e === "object" && e && "code" in e && e.code !== "ESRCH") {
|
if (typeof e === "object" && e && "code" in e && e.code !== "ESRCH") {
|
||||||
|
if (this.strictMode) {
|
||||||
throw e;
|
throw e;
|
||||||
|
} else {
|
||||||
|
this.exitWithWarning(`couldn't kill daemon: ${stringifyError(e)}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (core.isDebug()) {
|
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() {
|
function main() {
|
||||||
new MagicNixCacheAction().execute();
|
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
28
src/index.ts
28
src/index.ts
|
@ -1,6 +1,6 @@
|
||||||
import { netrcPath, tailLog } from "./helpers.js";
|
import { netrcPath, tailLog } from "./helpers.js";
|
||||||
import * as actionsCore from "@actions/core";
|
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 got, { Got, Response } from "got";
|
||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
import { SpawnOptions, spawn } from "node:child_process";
|
import { SpawnOptions, spawn } from "node:child_process";
|
||||||
|
@ -259,9 +259,14 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
// eslint-disable-next-line github/no-then
|
// eslint-disable-next-line github/no-then
|
||||||
.catch((err) => {
|
.catch((e: unknown) => {
|
||||||
const msg = `error in notifyPromise: ${err}`;
|
const msg = stringifyError(e);
|
||||||
reject(new Error(msg));
|
|
||||||
|
if (this.strictMode) {
|
||||||
|
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||||
|
} else {
|
||||||
|
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
daemon.on("exit", async (code, signal) => {
|
daemon.on("exit", async (code, signal) => {
|
||||||
let msg: string;
|
let msg: string;
|
||||||
|
@ -306,7 +311,7 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
actionsCore.debug(`back from post: ${res.body}`);
|
actionsCore.debug(`back from post: ${res.body}`);
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
actionsCore.info(`Error marking the workflow as started:`);
|
actionsCore.info(`Error marking the workflow as started:`);
|
||||||
actionsCore.info(inspect(e));
|
actionsCore.info(inspect(e));
|
||||||
actionsCore.info(`Magic Nix Cache may not be running for this workflow.`);
|
actionsCore.info(`Magic Nix Cache may not be running for this workflow.`);
|
||||||
|
@ -350,11 +355,16 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
actionsCore.debug(`killing`);
|
actionsCore.debug(`killing`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.kill(pid, "SIGTERM");
|
process.kill(pid, "SIGTERM");
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
if (typeof e === "object" && e && "code" in e && e.code !== "ESRCH") {
|
if (typeof e === "object" && e && "code" in e && e.code !== "ESRCH") {
|
||||||
|
if (this.strictMode) {
|
||||||
throw e;
|
throw e;
|
||||||
|
} else {
|
||||||
|
this.exitWithWarning(`couldn't kill daemon: ${stringifyError(e)}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (actionsCore.isDebug()) {
|
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 {
|
function main(): void {
|
||||||
|
|
Loading…
Reference in a new issue