Skip to content

Commit

Permalink
Provide better if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
lucperkins committed May 29, 2024
1 parent 23e5c43 commit 9c4e8b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
11 changes: 7 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,17 @@ class NixInstallerAction extends DetSysAction {
return this.runnerOs === "Linux";
}

private get isAct(): boolean {
private get runningInAct(): boolean {
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> {
// 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/),
Expand All @@ -151,7 +158,7 @@ class NixInstallerAction extends DetSysAction {
return;
}

if (this.isAct) {
if (this.runningInAct) {
actionsCore.debug(
"Not bothering to detect if the docker shim should be used, as it is typically incompatible with act.",
);
Expand Down Expand Up @@ -486,15 +493,15 @@ class NixInstallerAction extends DetSysAction {
}
executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf;

if (process.env["ACT"] && !process.env["NOT_ACT"]) {
if (this.runningInAct) {
this.addFact(FACT_IN_ACT, true);
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`",
);
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);
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",
Expand Down

0 comments on commit 9c4e8b2

Please sign in to comment.