mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-26 01:12:17 +01:00
Remove error in main logic
This commit is contained in:
parent
e789896996
commit
053b0cc1f9
3 changed files with 1 additions and 46 deletions
20
dist/index.js
generated
vendored
20
dist/index.js
generated
vendored
|
@ -95468,7 +95468,6 @@ var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
var FACT_ENV_VARS_PRESENT = "required_env_vars_present";
|
var FACT_ENV_VARS_PRESENT = "required_env_vars_present";
|
||||||
var FACT_DIFF_STORE_ENABLED = "diff_store";
|
var FACT_DIFF_STORE_ENABLED = "diff_store";
|
||||||
var FACT_NOOP_MODE = "noop_mode";
|
var FACT_NOOP_MODE = "noop_mode";
|
||||||
var STATE_ERROR_IN_MAIN = "ERROR_IN_MAIN";
|
|
||||||
var STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
var STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
var STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
var STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
||||||
var STARTED_HINT = "true";
|
var STARTED_HINT = "true";
|
||||||
|
@ -95534,9 +95533,6 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
await this.notifyAutoCache();
|
await this.notifyAutoCache();
|
||||||
}
|
}
|
||||||
async post() {
|
async post() {
|
||||||
if (!this.strictMode && this.mainError) {
|
|
||||||
this.exitWithWarning(this.mainError);
|
|
||||||
}
|
|
||||||
if (this.noopMode) {
|
if (this.noopMode) {
|
||||||
core.debug(TEXT_NOOP);
|
core.debug(TEXT_NOOP);
|
||||||
return;
|
return;
|
||||||
|
@ -95662,7 +95658,6 @@ 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.setMainError(msg);
|
|
||||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -95678,7 +95673,6 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
reject(new Error(msg));
|
reject(new Error(msg));
|
||||||
} else {
|
} else {
|
||||||
this.setMainError(msg);
|
|
||||||
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -95715,9 +95709,6 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
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)}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95774,17 +95765,6 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
core.warning(`strict mode not enabled; exiting`);
|
core.warning(`strict mode not enabled; exiting`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
// If the main phase errors, save the state for use in post.
|
|
||||||
// This matters only when strict mode is NOT set.
|
|
||||||
setMainError(msg) {
|
|
||||||
core.saveState(STATE_ERROR_IN_MAIN, msg);
|
|
||||||
}
|
|
||||||
// In the post phase, if the main phase errored, return `true` so that the
|
|
||||||
// phase can be skipped (with a warning).
|
|
||||||
get mainError() {
|
|
||||||
const state = core.getState(STATE_ERROR_IN_MAIN);
|
|
||||||
return state !== "" ? state : void 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
25
src/index.ts
25
src/index.ts
|
@ -18,7 +18,6 @@ const FACT_ENV_VARS_PRESENT = "required_env_vars_present";
|
||||||
const FACT_DIFF_STORE_ENABLED = "diff_store";
|
const FACT_DIFF_STORE_ENABLED = "diff_store";
|
||||||
const FACT_NOOP_MODE = "noop_mode";
|
const FACT_NOOP_MODE = "noop_mode";
|
||||||
|
|
||||||
const STATE_ERROR_IN_MAIN = "ERROR_IN_MAIN";
|
|
||||||
const STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
const STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
||||||
const STARTED_HINT = "true";
|
const STARTED_HINT = "true";
|
||||||
|
@ -107,12 +106,6 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async post(): Promise<void> {
|
async post(): Promise<void> {
|
||||||
// If strict mode is off and there was an error in main, such as the daemon not starting,
|
|
||||||
// then the post phase is skipped with a warning.
|
|
||||||
if (!this.strictMode && this.mainError) {
|
|
||||||
this.exitWithWarning(this.mainError);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.noopMode) {
|
if (this.noopMode) {
|
||||||
actionsCore.debug(TEXT_NOOP);
|
actionsCore.debug(TEXT_NOOP);
|
||||||
return;
|
return;
|
||||||
|
@ -272,7 +265,6 @@ 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.setMainError(msg);
|
|
||||||
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
this.exitWithWarning(`failed to start daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -290,7 +282,6 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
if (this.strictMode) {
|
if (this.strictMode) {
|
||||||
reject(new Error(msg));
|
reject(new Error(msg));
|
||||||
} else {
|
} else {
|
||||||
this.setMainError(msg);
|
|
||||||
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
this.exitWithWarning(`Failed to kill daemon: ${msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -335,9 +326,6 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
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)}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,19 +391,6 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
actionsCore.warning(`strict mode not enabled; exiting`);
|
actionsCore.warning(`strict mode not enabled; exiting`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the main phase errors, save the state for use in post.
|
|
||||||
// This matters only when strict mode is NOT set.
|
|
||||||
private setMainError(msg: string): void {
|
|
||||||
actionsCore.saveState(STATE_ERROR_IN_MAIN, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// In the post phase, if the main phase errored, return `true` so that the
|
|
||||||
// phase can be skipped (with a warning).
|
|
||||||
private get mainError(): string | undefined {
|
|
||||||
const state = actionsCore.getState(STATE_ERROR_IN_MAIN);
|
|
||||||
return state !== "" ? state : undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(): void {
|
function main(): void {
|
||||||
|
|
Loading…
Reference in a new issue