Provide better if statement

This commit is contained in:
Luc Perkins 2024-05-29 15:51:33 -03:00
parent 23e5c435a9
commit 9c4e8b237e
No known key found for this signature in database
GPG Key ID: 16DB1108FB591835
2 changed files with 18 additions and 8 deletions

11
dist/index.js generated vendored
View File

@ -97864,9 +97864,12 @@ var NixInstallerAction = class extends DetSysAction {
get isLinux() { get isLinux() {
return this.runnerOs === "Linux"; return this.runnerOs === "Linux";
} }
get isAct() { get runningInAct() {
return process.env["ACT"] !== "" && !(process.env["NOT_ACT"] === ""); return process.env["ACT"] !== "" && !(process.env["NOT_ACT"] === "");
} }
get runningInNamespaceRunner() {
return process.env["NSC_VM_ID"] !== void 0 && !(process.env["NOT_NAMESPACE"] === "true");
}
async detectAndForceDockerShim() { async detectAndForceDockerShim() {
if (this.isLinux) { if (this.isLinux) {
if (this.forceDockerShim) { if (this.forceDockerShim) {
@ -97877,7 +97880,7 @@ var NixInstallerAction = class extends DetSysAction {
} }
return; return;
} }
if (this.isAct) { if (this.runningInAct) {
core.debug( core.debug(
"Not bothering to detect if the docker shim should be used, as it is typically incompatible with act." "Not bothering to detect if the docker shim should be used, as it is typically incompatible with act."
); );
@ -98158,14 +98161,14 @@ ${stderrBuffer}`
extraConf += "\n"; extraConf += "\n";
} }
executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf; executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf;
if (process.env["ACT"] && !process.env["NOT_ACT"]) { if (this.runningInAct) {
this.addFact(FACT_IN_ACT, true); this.addFact(FACT_IN_ACT, true);
core.info( core.info(
"Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`" "Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`"
); );
executionEnv.NIX_INSTALLER_INIT = "none"; executionEnv.NIX_INSTALLER_INIT = "none";
} }
if (process.env["NSC_VM_ID"] && !process.env["NOT_NAMESPACE"]) { if (this.runningInNamespaceRunner) {
this.addFact(FACT_IN_NAMESPACE_SO, true); this.addFact(FACT_IN_NAMESPACE_SO, true);
core.info( core.info(
"Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace" "Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace"

View File

@ -133,10 +133,17 @@ class NixInstallerAction extends DetSysAction {
return this.runnerOs === "Linux"; return this.runnerOs === "Linux";
} }
private get isAct(): boolean { private get runningInAct(): boolean {
return process.env["ACT"] !== "" && !(process.env["NOT_ACT"] === ""); return process.env["ACT"] !== "" && !(process.env["NOT_ACT"] === "");
} }
private get runningInNamespaceRunner(): boolean {
return (
process.env["NSC_VM_ID"] !== undefined &&
!(process.env["NOT_NAMESPACE"] === "true")
);
}
async detectAndForceDockerShim(): Promise<void> { async detectAndForceDockerShim(): Promise<void> {
// Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker. // Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker.
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/), // This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
@ -151,7 +158,7 @@ class NixInstallerAction extends DetSysAction {
return; return;
} }
if (this.isAct) { if (this.runningInAct) {
actionsCore.debug( actionsCore.debug(
"Not bothering to detect if the docker shim should be used, as it is typically incompatible with act.", "Not bothering to detect if the docker shim should be used, as it is typically incompatible with act.",
); );
@ -486,7 +493,7 @@ class NixInstallerAction extends DetSysAction {
} }
executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf; executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf;
if (process.env["ACT"] && !process.env["NOT_ACT"]) { if (this.runningInAct) {
this.addFact(FACT_IN_ACT, true); this.addFact(FACT_IN_ACT, true);
actionsCore.info( actionsCore.info(
"Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`", "Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`",
@ -494,7 +501,7 @@ class NixInstallerAction extends DetSysAction {
executionEnv.NIX_INSTALLER_INIT = "none"; executionEnv.NIX_INSTALLER_INIT = "none";
} }
if (process.env["NSC_VM_ID"] && !process.env["NOT_NAMESPACE"]) { if (this.runningInNamespaceRunner) {
this.addFact(FACT_IN_NAMESPACE_SO, true); this.addFact(FACT_IN_NAMESPACE_SO, true);
actionsCore.info( actionsCore.info(
"Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace", "Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace",