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
12
dist/index.js
generated
vendored
12
dist/index.js
generated
vendored
|
@ -95483,6 +95483,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
requireNix: "warn",
|
||||
diagnosticsSuffix: "perf"
|
||||
});
|
||||
this.errorInMain = false;
|
||||
this.hostAndPort = inputs_exports.getString("listen");
|
||||
this.diffStore = inputs_exports.getBool("diff-store");
|
||||
this.addFact(FACT_DIFF_STORE_ENABLED, this.diffStore);
|
||||
|
@ -95533,6 +95534,9 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
await this.notifyAutoCache();
|
||||
}
|
||||
async post() {
|
||||
if (!this.strictMode && this.errorInMain) {
|
||||
this.exitWithWarning(`skipping post phase due to error in main phase`);
|
||||
} else {
|
||||
if (this.noopMode) {
|
||||
core.debug(TEXT_NOOP);
|
||||
return;
|
||||
|
@ -95545,6 +95549,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
}
|
||||
await this.tearDownAutoCache();
|
||||
}
|
||||
}
|
||||
async setUpAutoCache() {
|
||||
const requiredEnv = [
|
||||
"ACTIONS_CACHE_URL",
|
||||
|
@ -95658,6 +95663,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
if (this.strictMode) {
|
||||
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||
} else {
|
||||
this.errorInMain = true;
|
||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||
}
|
||||
});
|
||||
|
@ -95670,7 +95676,12 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
} else {
|
||||
msg = "Daemon unexpectedly exited";
|
||||
}
|
||||
if (this.strictMode) {
|
||||
reject(new Error(msg));
|
||||
} else {
|
||||
this.errorInMain = true;
|
||||
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
daemon.unref();
|
||||
|
@ -95700,6 +95711,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
if (this.strictMode) {
|
||||
core.setFailed(`Magic Nix Cache failed to start: ${(0,external_node_util_.inspect)(e)}`);
|
||||
} else {
|
||||
this.errorInMain = true;
|
||||
core.warning(`Error marking the workflow as started:`);
|
||||
core.warning((0,external_node_util_.inspect)(e));
|
||||
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
15
src/index.ts
15
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.";
|
||||
|
||||
class MagicNixCacheAction extends DetSysAction {
|
||||
private errorInMain: boolean;
|
||||
private hostAndPort: string;
|
||||
private diffStore: boolean;
|
||||
private httpClient: Got;
|
||||
|
@ -46,6 +47,7 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
diagnosticsSuffix: "perf",
|
||||
});
|
||||
|
||||
this.errorInMain = false;
|
||||
this.hostAndPort = inputs.getString("listen");
|
||||
this.diffStore = inputs.getBool("diff-store");
|
||||
|
||||
|
@ -106,6 +108,9 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
}
|
||||
|
||||
async post(): Promise<void> {
|
||||
if (!this.strictMode && this.errorInMain) {
|
||||
this.exitWithWarning(`skipping post phase due to error in main phase`);
|
||||
} else {
|
||||
if (this.noopMode) {
|
||||
actionsCore.debug(TEXT_NOOP);
|
||||
return;
|
||||
|
@ -120,6 +125,7 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
|
||||
await this.tearDownAutoCache();
|
||||
}
|
||||
}
|
||||
|
||||
async setUpAutoCache(): Promise<void> {
|
||||
const requiredEnv = [
|
||||
|
@ -265,9 +271,11 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
if (this.strictMode) {
|
||||
reject(new Error(`error in notifyPromise: ${msg}`));
|
||||
} else {
|
||||
this.errorInMain = true;
|
||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||
}
|
||||
});
|
||||
|
||||
daemon.on("exit", async (code, signal) => {
|
||||
let msg: string;
|
||||
if (signal) {
|
||||
|
@ -277,7 +285,13 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
} else {
|
||||
msg = "Daemon unexpectedly exited";
|
||||
}
|
||||
|
||||
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) {
|
||||
actionsCore.setFailed(`Magic Nix Cache failed to start: ${inspect(e)}`);
|
||||
} else {
|
||||
this.errorInMain = true;
|
||||
actionsCore.warning(`Error marking the workflow as started:`);
|
||||
actionsCore.warning(inspect(e));
|
||||
actionsCore.warning(
|
||||
|
|
Loading…
Reference in a new issue