mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-26 01:12:17 +01:00
Skip post phase with warning on error in main
This commit is contained in:
parent
b2e770e214
commit
0cb62a86ec
3 changed files with 51 additions and 24 deletions
34
dist/index.js
generated
vendored
34
dist/index.js
generated
vendored
|
@ -95483,6 +95483,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
requireNix: "warn",
|
requireNix: "warn",
|
||||||
diagnosticsSuffix: "perf"
|
diagnosticsSuffix: "perf"
|
||||||
});
|
});
|
||||||
|
this.errorInMain = false;
|
||||||
this.hostAndPort = inputs_exports.getString("listen");
|
this.hostAndPort = inputs_exports.getString("listen");
|
||||||
this.diffStore = inputs_exports.getBool("diff-store");
|
this.diffStore = inputs_exports.getBool("diff-store");
|
||||||
this.addFact(FACT_DIFF_STORE_ENABLED, this.diffStore);
|
this.addFact(FACT_DIFF_STORE_ENABLED, this.diffStore);
|
||||||
|
@ -95533,17 +95534,21 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
await this.notifyAutoCache();
|
await this.notifyAutoCache();
|
||||||
}
|
}
|
||||||
async post() {
|
async post() {
|
||||||
if (this.noopMode) {
|
if (!this.strictMode && this.errorInMain) {
|
||||||
core.debug(TEXT_NOOP);
|
this.exitWithWarning(`skipping post phase due to error in main phase`);
|
||||||
return;
|
} else {
|
||||||
|
if (this.noopMode) {
|
||||||
|
core.debug(TEXT_NOOP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.nixStoreTrust === "untrusted") {
|
||||||
|
core.debug(TEXT_TRUST_UNTRUSTED);
|
||||||
|
return;
|
||||||
|
} else if (this.nixStoreTrust === "unknown") {
|
||||||
|
core.debug(TEXT_TRUST_UNKNOWN);
|
||||||
|
}
|
||||||
|
await this.tearDownAutoCache();
|
||||||
}
|
}
|
||||||
if (this.nixStoreTrust === "untrusted") {
|
|
||||||
core.debug(TEXT_TRUST_UNTRUSTED);
|
|
||||||
return;
|
|
||||||
} else if (this.nixStoreTrust === "unknown") {
|
|
||||||
core.debug(TEXT_TRUST_UNKNOWN);
|
|
||||||
}
|
|
||||||
await this.tearDownAutoCache();
|
|
||||||
}
|
}
|
||||||
async setUpAutoCache() {
|
async setUpAutoCache() {
|
||||||
const requiredEnv = [
|
const requiredEnv = [
|
||||||
|
@ -95658,6 +95663,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
reject(new Error(`error in notifyPromise: ${msg}`));
|
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||||
} else {
|
} else {
|
||||||
|
this.errorInMain = true;
|
||||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -95670,7 +95676,12 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
} else {
|
} else {
|
||||||
msg = "Daemon unexpectedly exited";
|
msg = "Daemon unexpectedly exited";
|
||||||
}
|
}
|
||||||
reject(new Error(msg));
|
if (this.strictMode) {
|
||||||
|
reject(new Error(msg));
|
||||||
|
} else {
|
||||||
|
this.errorInMain = true;
|
||||||
|
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
daemon.unref();
|
daemon.unref();
|
||||||
|
@ -95700,6 +95711,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
core.setFailed(`Magic Nix Cache failed to start: ${(0,external_node_util_.inspect)(e)}`);
|
core.setFailed(`Magic Nix Cache failed to start: ${(0,external_node_util_.inspect)(e)}`);
|
||||||
} else {
|
} else {
|
||||||
|
this.errorInMain = true;
|
||||||
core.warning(`Error marking the workflow as started:`);
|
core.warning(`Error marking the workflow as started:`);
|
||||||
core.warning((0,external_node_util_.inspect)(e));
|
core.warning((0,external_node_util_.inspect)(e));
|
||||||
core.warning(
|
core.warning(
|
||||||
|
|
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
39
src/index.ts
39
src/index.ts
|
@ -30,6 +30,7 @@ const TEXT_TRUST_UNKNOWN =
|
||||||
"The Nix daemon may not consider the user running this workflow to be trusted. Magic Nix Cache may not start correctly.";
|
"The Nix daemon may not consider the user running this workflow to be trusted. Magic Nix Cache may not start correctly.";
|
||||||
|
|
||||||
class MagicNixCacheAction extends DetSysAction {
|
class MagicNixCacheAction extends DetSysAction {
|
||||||
|
private errorInMain: boolean;
|
||||||
private hostAndPort: string;
|
private hostAndPort: string;
|
||||||
private diffStore: boolean;
|
private diffStore: boolean;
|
||||||
private httpClient: Got;
|
private httpClient: Got;
|
||||||
|
@ -46,6 +47,7 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
diagnosticsSuffix: "perf",
|
diagnosticsSuffix: "perf",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.errorInMain = false;
|
||||||
this.hostAndPort = inputs.getString("listen");
|
this.hostAndPort = inputs.getString("listen");
|
||||||
this.diffStore = inputs.getBool("diff-store");
|
this.diffStore = inputs.getBool("diff-store");
|
||||||
|
|
||||||
|
@ -106,19 +108,23 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async post(): Promise<void> {
|
async post(): Promise<void> {
|
||||||
if (this.noopMode) {
|
if (!this.strictMode && this.errorInMain) {
|
||||||
actionsCore.debug(TEXT_NOOP);
|
this.exitWithWarning(`skipping post phase due to error in main phase`);
|
||||||
return;
|
} else {
|
||||||
}
|
if (this.noopMode) {
|
||||||
|
actionsCore.debug(TEXT_NOOP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.nixStoreTrust === "untrusted") {
|
if (this.nixStoreTrust === "untrusted") {
|
||||||
actionsCore.debug(TEXT_TRUST_UNTRUSTED);
|
actionsCore.debug(TEXT_TRUST_UNTRUSTED);
|
||||||
return;
|
return;
|
||||||
} else if (this.nixStoreTrust === "unknown") {
|
} else if (this.nixStoreTrust === "unknown") {
|
||||||
actionsCore.debug(TEXT_TRUST_UNKNOWN);
|
actionsCore.debug(TEXT_TRUST_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.tearDownAutoCache();
|
await this.tearDownAutoCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setUpAutoCache(): Promise<void> {
|
async setUpAutoCache(): Promise<void> {
|
||||||
|
@ -265,9 +271,11 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
reject(new Error(`error in notifyPromise: ${msg}`));
|
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||||
} else {
|
} else {
|
||||||
|
this.errorInMain = true;
|
||||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
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;
|
||||||
if (signal) {
|
if (signal) {
|
||||||
|
@ -277,7 +285,13 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
} else {
|
} else {
|
||||||
msg = "Daemon unexpectedly exited";
|
msg = "Daemon unexpectedly exited";
|
||||||
}
|
}
|
||||||
reject(new Error(msg));
|
|
||||||
|
if (this.strictMode) {
|
||||||
|
reject(new Error(msg));
|
||||||
|
} else {
|
||||||
|
this.errorInMain = true;
|
||||||
|
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -315,6 +329,7 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
actionsCore.setFailed(`Magic Nix Cache failed to start: ${inspect(e)}`);
|
actionsCore.setFailed(`Magic Nix Cache failed to start: ${inspect(e)}`);
|
||||||
} else {
|
} else {
|
||||||
|
this.errorInMain = true;
|
||||||
actionsCore.warning(`Error marking the workflow as started:`);
|
actionsCore.warning(`Error marking the workflow as started:`);
|
||||||
actionsCore.warning(inspect(e));
|
actionsCore.warning(inspect(e));
|
||||||
actionsCore.warning(
|
actionsCore.warning(
|
||||||
|
|
Loading…
Reference in a new issue