mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-26 17:30:34 +01:00
Set specific error in main
This commit is contained in:
parent
58113297de
commit
6a141808e0
3 changed files with 27 additions and 19 deletions
21
dist/index.js
generated
vendored
21
dist/index.js
generated
vendored
|
@ -95534,8 +95534,8 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
await this.notifyAutoCache();
|
await this.notifyAutoCache();
|
||||||
}
|
}
|
||||||
async post() {
|
async post() {
|
||||||
if (!this.strictMode && this.mainErrored) {
|
if (!this.strictMode && this.mainError) {
|
||||||
this.exitWithWarning(`skipping post phase due to error in main phase`);
|
this.exitWithWarning(this.mainError);
|
||||||
} else {
|
} else {
|
||||||
if (this.noopMode) {
|
if (this.noopMode) {
|
||||||
core.debug(TEXT_NOOP);
|
core.debug(TEXT_NOOP);
|
||||||
|
@ -95663,7 +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.setMainErrored();
|
this.setMainError(msg);
|
||||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -95679,7 +95679,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
reject(new Error(msg));
|
reject(new Error(msg));
|
||||||
} else {
|
} else {
|
||||||
this.setMainErrored();
|
this.setMainError(msg);
|
||||||
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -95711,12 +95711,14 @@ 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.setMainErrored();
|
|
||||||
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(
|
||||||
`Magic Nix Cache may not be running for this workflow.`
|
`Magic Nix Cache may not be running for this workflow.`
|
||||||
);
|
);
|
||||||
|
this.setMainError(
|
||||||
|
`Error starting the Magic Nix Cache: ${stringifyError(e)}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95775,13 +95777,14 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
}
|
}
|
||||||
// If the main phase errors, save the state for use in post.
|
// If the main phase errors, save the state for use in post.
|
||||||
// This matters only when strict mode is NOT set.
|
// This matters only when strict mode is NOT set.
|
||||||
setMainErrored() {
|
setMainError(msg) {
|
||||||
core.saveState(STATE_ERROR_IN_MAIN, "true");
|
core.saveState(STATE_ERROR_IN_MAIN, msg);
|
||||||
}
|
}
|
||||||
// In the post phase, if the main phase errored, return `true` so that the
|
// In the post phase, if the main phase errored, return `true` so that the
|
||||||
// phase can be skipped (with a warning).
|
// phase can be skipped (with a warning).
|
||||||
get mainErrored() {
|
get mainError() {
|
||||||
return core.getState(STATE_ERROR_IN_MAIN) === "true";
|
const state = core.getState(STATE_ERROR_IN_MAIN);
|
||||||
|
return state !== "" ? state : void 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function main() {
|
function main() {
|
||||||
|
|
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
23
src/index.ts
23
src/index.ts
|
@ -107,8 +107,10 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async post(): Promise<void> {
|
async post(): Promise<void> {
|
||||||
if (!this.strictMode && this.mainErrored) {
|
// If strict mode is off and there was an error in main, such as the daemon not starting,
|
||||||
this.exitWithWarning(`skipping post phase due to error in main phase`);
|
// then the post phase is skipped with a warning.
|
||||||
|
if (!this.strictMode && this.mainError) {
|
||||||
|
this.exitWithWarning(this.mainError);
|
||||||
} else {
|
} else {
|
||||||
if (this.noopMode) {
|
if (this.noopMode) {
|
||||||
actionsCore.debug(TEXT_NOOP);
|
actionsCore.debug(TEXT_NOOP);
|
||||||
|
@ -270,7 +272,7 @@ 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.setMainErrored();
|
this.setMainError(msg);
|
||||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -288,7 +290,7 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
reject(new Error(msg));
|
reject(new Error(msg));
|
||||||
} else {
|
} else {
|
||||||
this.setMainErrored();
|
this.setMainError(msg);
|
||||||
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -328,12 +330,14 @@ 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.setMainErrored();
|
|
||||||
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(
|
||||||
`Magic Nix Cache may not be running for this workflow.`,
|
`Magic Nix Cache may not be running for this workflow.`,
|
||||||
);
|
);
|
||||||
|
this.setMainError(
|
||||||
|
`Error starting the Magic Nix Cache: ${stringifyError(e)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,14 +406,15 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
|
|
||||||
// If the main phase errors, save the state for use in post.
|
// If the main phase errors, save the state for use in post.
|
||||||
// This matters only when strict mode is NOT set.
|
// This matters only when strict mode is NOT set.
|
||||||
private setMainErrored(): void {
|
private setMainError(msg: string): void {
|
||||||
actionsCore.saveState(STATE_ERROR_IN_MAIN, "true");
|
actionsCore.saveState(STATE_ERROR_IN_MAIN, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the post phase, if the main phase errored, return `true` so that the
|
// In the post phase, if the main phase errored, return `true` so that the
|
||||||
// phase can be skipped (with a warning).
|
// phase can be skipped (with a warning).
|
||||||
private get mainErrored(): boolean {
|
private get mainError(): string | undefined {
|
||||||
return actionsCore.getState(STATE_ERROR_IN_MAIN) === "true";
|
const state = actionsCore.getState(STATE_ERROR_IN_MAIN);
|
||||||
|
return state !== "" ? state : undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue