mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-25 17:08:32 +01:00
Rename no-op mode
This commit is contained in:
parent
d4fd993185
commit
4edd92a1a4
4 changed files with 22 additions and 23 deletions
|
@ -8,4 +8,3 @@ end_of_line = lf
|
|||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
|
|
18
dist/index.js
generated
vendored
18
dist/index.js
generated
vendored
|
@ -95466,12 +95466,12 @@ async function flakeHubLogin(netrc) {
|
|||
var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||
var FACT_ENV_VARS_PRESENT = "required_env_vars_present";
|
||||
var FACT_DIFF_STORE_ENABLED = "diff_store";
|
||||
var FACT_NOOP_MODE = "noop_mode";
|
||||
var FACT_ALREADY_RUNNING = "noop_mode";
|
||||
var STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||
var STATE_ERROR_IN_MAIN = "ERROR_IN_MAIN";
|
||||
var STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
||||
var STARTED_HINT = "true";
|
||||
var TEXT_NOOP = "Magic Nix Cache is already running, this workflow job is in noop mode. Is the Magic Nix Cache in the workflow twice?";
|
||||
var TEXT_ALREADY_RUNNING = "Magic Nix Cache is already running, this workflow job is in noop mode. Is the Magic Nix Cache in the workflow twice?";
|
||||
var TEXT_TRUST_UNTRUSTED = "The Nix daemon does not consider the user running this workflow to be trusted. Magic Nix Cache is disabled.";
|
||||
var TEXT_TRUST_UNKNOWN = "The Nix daemon may not consider the user running this workflow to be trusted. Magic Nix Cache may not start correctly.";
|
||||
var MagicNixCacheAction = class extends DetSysAction {
|
||||
|
@ -95510,17 +95510,17 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
core.saveState(STATE_DAEMONDIR, this.daemonDir);
|
||||
}
|
||||
if (process.env[ENV_DAEMON_DIR] === void 0) {
|
||||
this.noopMode = false;
|
||||
this.alreadyRunning = false;
|
||||
core.exportVariable(ENV_DAEMON_DIR, this.daemonDir);
|
||||
} else {
|
||||
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
||||
this.alreadyRunning = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
||||
}
|
||||
this.addFact(FACT_NOOP_MODE, this.noopMode);
|
||||
this.addFact(FACT_ALREADY_RUNNING, this.alreadyRunning);
|
||||
this.stapleFile("daemon.log", external_node_path_namespaceObject.join(this.daemonDir, "daemon.log"));
|
||||
}
|
||||
async main() {
|
||||
if (this.noopMode) {
|
||||
core.warning(TEXT_NOOP);
|
||||
if (this.alreadyRunning) {
|
||||
core.warning(TEXT_ALREADY_RUNNING);
|
||||
return;
|
||||
}
|
||||
if (this.nixStoreTrust === "untrusted") {
|
||||
|
@ -95539,8 +95539,8 @@ var MagicNixCacheAction = class extends DetSysAction {
|
|||
);
|
||||
process.exit(0);
|
||||
}
|
||||
if (this.noopMode) {
|
||||
core.debug(TEXT_NOOP);
|
||||
if (this.alreadyRunning) {
|
||||
core.debug(TEXT_ALREADY_RUNNING);
|
||||
return;
|
||||
}
|
||||
if (this.nixStoreTrust === "untrusted") {
|
||||
|
|
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
24
src/index.ts
24
src/index.ts
|
@ -15,14 +15,14 @@ const ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
|||
|
||||
const FACT_ENV_VARS_PRESENT = "required_env_vars_present";
|
||||
const FACT_DIFF_STORE_ENABLED = "diff_store";
|
||||
const FACT_NOOP_MODE = "noop_mode";
|
||||
const FACT_ALREADY_RUNNING = "noop_mode";
|
||||
|
||||
const STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||
const STATE_ERROR_IN_MAIN = "ERROR_IN_MAIN";
|
||||
const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
||||
const STARTED_HINT = "true";
|
||||
|
||||
const TEXT_NOOP =
|
||||
const TEXT_ALREADY_RUNNING =
|
||||
"Magic Nix Cache is already running, this workflow job is in noop mode. Is the Magic Nix Cache in the workflow twice?";
|
||||
const TEXT_TRUST_UNTRUSTED =
|
||||
"The Nix daemon does not consider the user running this workflow to be trusted. Magic Nix Cache is disabled.";
|
||||
|
@ -36,9 +36,9 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
private daemonDir: string;
|
||||
private daemonStarted: boolean;
|
||||
|
||||
// No-op mode is set to `true` if the MNC is already running, in which case
|
||||
// the workflow will use the existing process rather than starting a new one.
|
||||
private noopMode: boolean;
|
||||
// This is set to `true` if the MNC is already running, in which case the
|
||||
// workflow will use the existing process rather than starting a new one.
|
||||
private alreadyRunning: boolean;
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -81,19 +81,19 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
}
|
||||
|
||||
if (process.env[ENV_DAEMON_DIR] === undefined) {
|
||||
this.noopMode = false;
|
||||
this.alreadyRunning = false;
|
||||
actionsCore.exportVariable(ENV_DAEMON_DIR, this.daemonDir);
|
||||
} else {
|
||||
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
||||
this.alreadyRunning = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
||||
}
|
||||
this.addFact(FACT_NOOP_MODE, this.noopMode);
|
||||
this.addFact(FACT_ALREADY_RUNNING, this.alreadyRunning);
|
||||
|
||||
this.stapleFile("daemon.log", path.join(this.daemonDir, "daemon.log"));
|
||||
}
|
||||
|
||||
async main(): Promise<void> {
|
||||
if (this.noopMode) {
|
||||
actionsCore.warning(TEXT_NOOP);
|
||||
if (this.alreadyRunning) {
|
||||
actionsCore.warning(TEXT_ALREADY_RUNNING);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -118,8 +118,8 @@ class MagicNixCacheAction extends DetSysAction {
|
|||
process.exit(0);
|
||||
}
|
||||
|
||||
if (this.noopMode) {
|
||||
actionsCore.debug(TEXT_NOOP);
|
||||
if (this.alreadyRunning) {
|
||||
actionsCore.debug(TEXT_ALREADY_RUNNING);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue