From a4cfe671b37a3c4d122df23498579ae7f3c8b2d7 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 9 May 2024 19:26:43 -0400 Subject: [PATCH] Don't raise an exception on a non-zero output --- dist/index.js | 3 ++- dist/index.js.map | 2 +- src/index.ts | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 55477d7..2d9af2c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -94385,7 +94385,8 @@ var FlakeCheckerAction = class { ...executionEnv, ...process.env // To get $PATH, etc - } + }, + ignoreReturnCode: true }); if (exitCode !== 0) { this.idslib.recordEvent("execution_failure", { diff --git a/dist/index.js.map b/dist/index.js.map index d5413f4..307856c 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { ActionOptions, IdsToolbox, inputs } from \"detsys-ts\";\n\nclass FlakeCheckerAction {\n idslib: IdsToolbox;\n flakeLockPath: string;\n nixpkgsKeys: string;\n checkOutdated: boolean;\n checkOwner: boolean;\n checkSupported: boolean;\n ignoreMissingFlakeLock: boolean;\n failMode: boolean;\n sendStatistics: boolean;\n\n constructor() {\n const options: ActionOptions = {\n name: \"flake-checker\",\n fetchStyle: \"gh-env-style\",\n diagnosticsUrl: new URL(\n \"https://install.determinate.systems/flake-checker/telemetry\",\n ),\n // We don't need Nix in this Action because we fetch a static binary using curl and run it\n requireNix: \"ignore\",\n };\n\n this.idslib = new IdsToolbox(options);\n\n this.flakeLockPath =\n inputs.getStringOrNull(\"flake-lock-path\") || \"flake.lock\";\n this.nixpkgsKeys = inputs.getStringOrNull(\"nixpkgs-keys\") || \"nixpkgs\";\n\n this.checkOutdated = inputs.getBool(\"check-outdated\");\n this.checkOwner = inputs.getBool(\"check-owner\");\n this.checkSupported = inputs.getBool(\"check-supported\");\n\n this.ignoreMissingFlakeLock = inputs.getBool(\"ignore-missing-flake-lock\");\n\n this.failMode = inputs.getBool(\"fail-mode\");\n this.sendStatistics = inputs.getBool(\"send-statistics\");\n }\n\n private async executionEnvironment(): Promise {\n const executionEnv: ExecuteEnvironment = {};\n\n executionEnv.NIX_FLAKE_CHECKER_FLAKE_LOCK_PATH = this.flakeLockPath;\n executionEnv.NIX_FLAKE_CHECKER_NIXPKGS_KEYS = this.nixpkgsKeys;\n\n if (!this.sendStatistics) {\n executionEnv.NIX_FLAKE_CHECKER_NO_TELEMETRY = \"false\";\n }\n\n if (!this.checkOutdated) {\n executionEnv.NIX_FLAKE_CHECKER_CHECK_OUTDATED = \"false\";\n }\n\n if (!this.checkOwner) {\n executionEnv.NIX_FLAKE_CHECKER_CHECK_OWNER = \"false\";\n }\n\n if (!this.checkSupported) {\n executionEnv.NIX_FLAKE_CHECKER_CHECK_SUPPORTED = \"false\";\n }\n\n if (!this.ignoreMissingFlakeLock) {\n executionEnv.NIX_FLAKE_CHECKER_IGNORE_MISSING_FLAKE_LOCK = \"false\";\n }\n\n if (this.failMode) {\n executionEnv.NIX_FLAKE_CHECKER_FAIL_MODE = \"true\";\n }\n\n return executionEnv;\n }\n\n async check(): Promise {\n const binaryPath = await this.idslib.fetchExecutable();\n\n const executionEnv = await this.executionEnvironment();\n actionsCore.debug(\n `Execution environment: ${JSON.stringify(executionEnv, null, 4)}`,\n );\n\n const exitCode = await actionsExec.exec(binaryPath, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get $PATH, etc\n },\n });\n\n if (exitCode !== 0) {\n this.idslib.recordEvent(\"execution_failure\", {\n exitCode,\n });\n actionsCore.setFailed(`Non-zero exit code of \\`${exitCode}\\`.`);\n }\n\n return exitCode;\n }\n}\n\ntype ExecuteEnvironment = {\n // All env vars are strings, no fanciness here.\n RUST_BACKTRACE?: string;\n NIX_FLAKE_CHECKER_FLAKE_LOCK_PATH?: string;\n NIX_FLAKE_CHECKER_NIXPKGS_KEYS?: string;\n NIX_FLAKE_CHECKER_NO_TELEMETRY?: string;\n NIX_FLAKE_CHECKER_CHECK_OUTDATED?: string;\n NIX_FLAKE_CHECKER_CHECK_OWNER?: string;\n NIX_FLAKE_CHECKER_CHECK_SUPPORTED?: string;\n NIX_FLAKE_CHECKER_IGNORE_MISSING_FLAKE_LOCK?: string;\n NIX_FLAKE_CHECKER_FAIL_MODE?: string;\n};\n\nfunction main(): void {\n const checker = new FlakeCheckerAction();\n\n checker.idslib.onMain(async () => {\n await checker.check();\n });\n\n checker.idslib.execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAwB,YAAY,cAAc;AAElD,IAAM,qBAAN,MAAyB;AAAA,EAWvB,cAAc;AACZ,UAAM,UAAyB;AAAA,MAC7B,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,gBAAgB,IAAI;AAAA,QAClB;AAAA,MACF;AAAA;AAAA,MAEA,YAAY;AAAA,IACd;AAEA,SAAK,SAAS,IAAI,WAAW,OAAO;AAEpC,SAAK,gBACH,OAAO,gBAAgB,iBAAiB,KAAK;AAC/C,SAAK,cAAc,OAAO,gBAAgB,cAAc,KAAK;AAE7D,SAAK,gBAAgB,OAAO,QAAQ,gBAAgB;AACpD,SAAK,aAAa,OAAO,QAAQ,aAAa;AAC9C,SAAK,iBAAiB,OAAO,QAAQ,iBAAiB;AAEtD,SAAK,yBAAyB,OAAO,QAAQ,2BAA2B;AAExE,SAAK,WAAW,OAAO,QAAQ,WAAW;AAC1C,SAAK,iBAAiB,OAAO,QAAQ,iBAAiB;AAAA,EACxD;AAAA,EAEA,MAAc,uBAAoD;AAChE,UAAM,eAAmC,CAAC;AAE1C,iBAAa,oCAAoC,KAAK;AACtD,iBAAa,iCAAiC,KAAK;AAEnD,QAAI,CAAC,KAAK,gBAAgB;AACxB,mBAAa,iCAAiC;AAAA,IAChD;AAEA,QAAI,CAAC,KAAK,eAAe;AACvB,mBAAa,mCAAmC;AAAA,IAClD;AAEA,QAAI,CAAC,KAAK,YAAY;AACpB,mBAAa,gCAAgC;AAAA,IAC/C;AAEA,QAAI,CAAC,KAAK,gBAAgB;AACxB,mBAAa,oCAAoC;AAAA,IACnD;AAEA,QAAI,CAAC,KAAK,wBAAwB;AAChC,mBAAa,8CAA8C;AAAA,IAC7D;AAEA,QAAI,KAAK,UAAU;AACjB,mBAAa,8BAA8B;AAAA,IAC7C;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,QAAyB;AAC7B,UAAM,aAAa,MAAM,KAAK,OAAO,gBAAgB;AAErD,UAAM,eAAe,MAAM,KAAK,qBAAqB;AACrD,IAAY;AAAA,MACV,0BAA0B,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,IACjE;AAEA,UAAM,WAAW,MAAkB,iBAAK,YAAY,CAAC,GAAG;AAAA,MACtD,KAAK;AAAA,QACH,GAAG;AAAA,QACH,GAAG,QAAQ;AAAA;AAAA,MACb;AAAA,IACF,CAAC;AAED,QAAI,aAAa,GAAG;AAClB,WAAK,OAAO,YAAY,qBAAqB;AAAA,QAC3C;AAAA,MACF,CAAC;AACD,MAAY,sBAAU,2BAA2B,QAAQ,KAAK;AAAA,IAChE;AAEA,WAAO;AAAA,EACT;AACF;AAeA,SAAS,OAAa;AACpB,QAAM,UAAU,IAAI,mBAAmB;AAEvC,UAAQ,OAAO,OAAO,YAAY;AAChC,UAAM,QAAQ,MAAM;AAAA,EACtB,CAAC;AAED,UAAQ,OAAO,QAAQ;AACzB;AAEA,KAAK;","names":[]} \ No newline at end of file +{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { ActionOptions, IdsToolbox, inputs } from \"detsys-ts\";\n\nclass FlakeCheckerAction {\n idslib: IdsToolbox;\n flakeLockPath: string;\n nixpkgsKeys: string;\n checkOutdated: boolean;\n checkOwner: boolean;\n checkSupported: boolean;\n ignoreMissingFlakeLock: boolean;\n failMode: boolean;\n sendStatistics: boolean;\n\n constructor() {\n const options: ActionOptions = {\n name: \"flake-checker\",\n fetchStyle: \"gh-env-style\",\n diagnosticsUrl: new URL(\n \"https://install.determinate.systems/flake-checker/telemetry\",\n ),\n // We don't need Nix in this Action because we fetch a static binary using curl and run it\n requireNix: \"ignore\",\n };\n\n this.idslib = new IdsToolbox(options);\n\n this.flakeLockPath =\n inputs.getStringOrNull(\"flake-lock-path\") || \"flake.lock\";\n this.nixpkgsKeys = inputs.getStringOrNull(\"nixpkgs-keys\") || \"nixpkgs\";\n\n this.checkOutdated = inputs.getBool(\"check-outdated\");\n this.checkOwner = inputs.getBool(\"check-owner\");\n this.checkSupported = inputs.getBool(\"check-supported\");\n\n this.ignoreMissingFlakeLock = inputs.getBool(\"ignore-missing-flake-lock\");\n\n this.failMode = inputs.getBool(\"fail-mode\");\n this.sendStatistics = inputs.getBool(\"send-statistics\");\n }\n\n private async executionEnvironment(): Promise {\n const executionEnv: ExecuteEnvironment = {};\n\n executionEnv.NIX_FLAKE_CHECKER_FLAKE_LOCK_PATH = this.flakeLockPath;\n executionEnv.NIX_FLAKE_CHECKER_NIXPKGS_KEYS = this.nixpkgsKeys;\n\n if (!this.sendStatistics) {\n executionEnv.NIX_FLAKE_CHECKER_NO_TELEMETRY = \"false\";\n }\n\n if (!this.checkOutdated) {\n executionEnv.NIX_FLAKE_CHECKER_CHECK_OUTDATED = \"false\";\n }\n\n if (!this.checkOwner) {\n executionEnv.NIX_FLAKE_CHECKER_CHECK_OWNER = \"false\";\n }\n\n if (!this.checkSupported) {\n executionEnv.NIX_FLAKE_CHECKER_CHECK_SUPPORTED = \"false\";\n }\n\n if (!this.ignoreMissingFlakeLock) {\n executionEnv.NIX_FLAKE_CHECKER_IGNORE_MISSING_FLAKE_LOCK = \"false\";\n }\n\n if (this.failMode) {\n executionEnv.NIX_FLAKE_CHECKER_FAIL_MODE = \"true\";\n }\n\n return executionEnv;\n }\n\n async check(): Promise {\n const binaryPath = await this.idslib.fetchExecutable();\n\n const executionEnv = await this.executionEnvironment();\n actionsCore.debug(\n `Execution environment: ${JSON.stringify(executionEnv, null, 4)}`,\n );\n\n const exitCode = await actionsExec.exec(binaryPath, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get $PATH, etc\n },\n ignoreReturnCode: true,\n });\n\n if (exitCode !== 0) {\n this.idslib.recordEvent(\"execution_failure\", {\n exitCode,\n });\n actionsCore.setFailed(`Non-zero exit code of \\`${exitCode}\\`.`);\n }\n\n return exitCode;\n }\n}\n\ntype ExecuteEnvironment = {\n // All env vars are strings, no fanciness here.\n RUST_BACKTRACE?: string;\n NIX_FLAKE_CHECKER_FLAKE_LOCK_PATH?: string;\n NIX_FLAKE_CHECKER_NIXPKGS_KEYS?: string;\n NIX_FLAKE_CHECKER_NO_TELEMETRY?: string;\n NIX_FLAKE_CHECKER_CHECK_OUTDATED?: string;\n NIX_FLAKE_CHECKER_CHECK_OWNER?: string;\n NIX_FLAKE_CHECKER_CHECK_SUPPORTED?: string;\n NIX_FLAKE_CHECKER_IGNORE_MISSING_FLAKE_LOCK?: string;\n NIX_FLAKE_CHECKER_FAIL_MODE?: string;\n};\n\nfunction main(): void {\n const checker = new FlakeCheckerAction();\n\n checker.idslib.onMain(async () => {\n await checker.check();\n });\n\n checker.idslib.execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAwB,YAAY,cAAc;AAElD,IAAM,qBAAN,MAAyB;AAAA,EAWvB,cAAc;AACZ,UAAM,UAAyB;AAAA,MAC7B,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,gBAAgB,IAAI;AAAA,QAClB;AAAA,MACF;AAAA;AAAA,MAEA,YAAY;AAAA,IACd;AAEA,SAAK,SAAS,IAAI,WAAW,OAAO;AAEpC,SAAK,gBACH,OAAO,gBAAgB,iBAAiB,KAAK;AAC/C,SAAK,cAAc,OAAO,gBAAgB,cAAc,KAAK;AAE7D,SAAK,gBAAgB,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AK;AAAA,IAChE;AAEA,WAAO;AAAA,EACT;AACF;AAeA,SAAS,OAAa;AACpB,QAAM,UAAU,IAAI,mBAAmB;AAEvC,UAAQ,OAAO,OAAO,YAAY;AAChC,UAAM,QAAQ,MAAM;AAAA,EACtB,CAAC;AAED,UAAQ,OAAO,QAAQ;AACzB;AAEA,KAAK;","names":[]} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 76fe316..ffff2c7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -86,6 +86,7 @@ class FlakeCheckerAction { ...executionEnv, ...process.env, // To get $PATH, etc }, + ignoreReturnCode: true, }); if (exitCode !== 0) {