diff --git a/.eslintrc.json b/.eslintrc.json index 6499d3b..5966041 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -29,6 +29,7 @@ "accessibility": "no-public" } ], + "@typescript-eslint/no-base-to-string": "error", "@typescript-eslint/no-require-imports": "error", "@typescript-eslint/array-type": "error", "@typescript-eslint/await-thenable": "error", diff --git a/dist/index.js b/dist/index.js index a4d56c0..622fc0e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -86333,6 +86333,8 @@ var external_node_util_ = __nccwpck_require__(7261); var external_os_ = __nccwpck_require__(2037); ;// CONCATENATED MODULE: external "node:crypto" const external_node_crypto_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:crypto"); +;// CONCATENATED MODULE: external "node:dns/promises" +const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:dns/promises"); // EXTERNAL MODULE: ./node_modules/.pnpm/@actions+cache@3.2.4/node_modules/@actions/cache/lib/cache.js var cache = __nccwpck_require__(6878); ;// CONCATENATED MODULE: ./node_modules/.pnpm/@sindresorhus+is@6.3.1/node_modules/@sindresorhus/is/dist/index.js @@ -93726,14 +93728,14 @@ const got = source_create(defaults); ;// CONCATENATED MODULE: external "node:child_process" const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process"); ;// CONCATENATED MODULE: external "node:fs/promises" -const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs/promises"); +const external_node_fs_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs/promises"); ;// CONCATENATED MODULE: external "node:path" const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path"); ;// CONCATENATED MODULE: external "node:stream/promises" const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises"); ;// CONCATENATED MODULE: external "node:zlib" const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:zlib"); -;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@5fcb0532d85556ebc2de286e483885976531339d_uqngfub4ls4loys67iy653x57e/node_modules/detsys-ts/dist/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@9d66d2c89c150f796165fdcc20b3be538807c0f4_46ybmzqhaua4eiwu3nj2qm63te/node_modules/detsys-ts/dist/index.js var __defProp = Object.defineProperty; var __export = (target, all) => { for (var name in all) @@ -93819,9 +93821,9 @@ async function readAsyncOsReleaseFile(fileList, options) { ${fileData}`); } break; - } catch (error2) { + } catch (error3) { if (options.debug) { - console.error(error2); + console.error(error3); } } } @@ -93843,9 +93845,9 @@ function readSyncOsreleaseFile(releaseFileList, options) { ${fileData}`); } break; - } catch (error2) { + } catch (error3) { if (options.debug) { - console.error(error2); + console.error(error3); } } } @@ -94037,6 +94039,192 @@ function hashEnvironmentVariables(prefix, variables) { return `${prefix}-${hash.digest("hex")}`; } +// src/errors.ts +function stringifyError(e) { + if (e instanceof Error) { + return e.message; + } else if (typeof e === "string") { + return e; + } else { + return JSON.stringify(e); + } +} + +// src/ids-host.ts + + +var DEFAULT_LOOKUP = "_detsys_ids._tcp.install.determinate.systems."; +var ALLOWED_SUFFIXES = [ + ".install.determinate.systems", + ".install.detsys.dev" +]; +var DEFAULT_IDS_HOST = "https://install.determinate.systems"; +var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP; +var IdsHost = class { + constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) { + this.idsProjectName = idsProjectName; + this.diagnosticsSuffix = diagnosticsSuffix; + this.runtimeDiagnosticsUrl = runtimeDiagnosticsUrl; + } + markCurrentHostBroken() { + this.prioritizedURLs?.shift(); + } + setPrioritizedUrls(urls) { + this.prioritizedURLs = urls; + } + async getRootUrl() { + const idsHost = process.env["IDS_HOST"]; + if (idsHost !== void 0) { + try { + return new URL(idsHost); + } catch (err) { + core.error( + `IDS_HOST environment variable is not a valid URL. Ignoring. ${stringifyError(err)}` + ); + } + } + let url = void 0; + try { + const urls = await this.getUrlsByPreference(); + url = urls[0]; + } catch (err) { + core.error( + `Error collecting IDS URLs by preference: ${stringifyError(err)}` + ); + } + if (url === void 0) { + url = new URL(DEFAULT_IDS_HOST); + } + return new URL(url); + } + async getDiagnosticsUrl() { + if (this.runtimeDiagnosticsUrl === "") { + return void 0; + } + if (this.runtimeDiagnosticsUrl !== "-" && this.runtimeDiagnosticsUrl !== void 0) { + try { + return new URL(this.runtimeDiagnosticsUrl); + } catch (err) { + core.info( + `User-provided diagnostic endpoint ignored: not a valid URL: ${stringifyError(err)}` + ); + } + } + try { + const diagnosticUrl = await this.getRootUrl(); + diagnosticUrl.pathname += this.idsProjectName; + diagnosticUrl.pathname += "/"; + diagnosticUrl.pathname += this.diagnosticsSuffix || "diagnostics"; + return diagnosticUrl; + } catch (err) { + core.info( + `Generated diagnostic endpoint ignored, and diagnostics are disabled: not a valid URL: ${stringifyError(err)}` + ); + return void 0; + } + } + async getUrlsByPreference() { + if (this.prioritizedURLs === void 0) { + this.prioritizedURLs = orderRecordsByPriorityWeight( + await discoverServiceRecords() + ).flatMap((record) => recordToUrl(record) || []); + } + return this.prioritizedURLs; + } +}; +function recordToUrl(record) { + const urlStr = `https://${record.name}:${record.port}`; + try { + return new URL(urlStr); + } catch (err) { + core.debug( + `Record ${JSON.stringify(record)} produced an invalid URL: ${urlStr} (${err})` + ); + return void 0; + } +} +async function discoverServiceRecords() { + return await discoverServicesStub((0,promises_namespaceObject.resolveSrv)(LOOKUP), 1e3); +} +async function discoverServicesStub(lookup, timeout) { + const defaultFallback = new Promise( + (resolve, _reject) => { + setTimeout(resolve, timeout, []); + } + ); + let records; + try { + records = await Promise.race([lookup, defaultFallback]); + } catch (reason) { + core.debug(`Error resolving SRV records: ${stringifyError(reason)}`); + records = []; + } + const acceptableRecords = records.filter((record) => { + for (const suffix of ALLOWED_SUFFIXES) { + if (record.name.endsWith(suffix)) { + return true; + } + } + core.debug( + `Unacceptable domain due to an invalid suffix: ${record.name}` + ); + return false; + }); + if (acceptableRecords.length === 0) { + core.debug(`No records found for ${LOOKUP}`); + } else { + core.debug( + `Resolved ${LOOKUP} to ${JSON.stringify(acceptableRecords)}` + ); + } + return acceptableRecords; +} +function orderRecordsByPriorityWeight(records) { + const byPriorityWeight = /* @__PURE__ */ new Map(); + for (const record of records) { + const existing = byPriorityWeight.get(record.priority); + if (existing) { + existing.push(record); + } else { + byPriorityWeight.set(record.priority, [record]); + } + } + const prioritizedRecords = []; + const keys = Array.from(byPriorityWeight.keys()).sort( + (a, b) => a - b + ); + for (const priority of keys) { + const recordsByPrio = byPriorityWeight.get(priority); + if (recordsByPrio === void 0) { + continue; + } + prioritizedRecords.push(...weightedRandom(recordsByPrio)); + } + return prioritizedRecords; +} +function weightedRandom(records) { + const scratchRecords = records.slice(); + const result = []; + while (scratchRecords.length > 0) { + const weights = []; + { + for (let i = 0; i < scratchRecords.length; i++) { + weights.push( + scratchRecords[i].weight + (i > 0 ? scratchRecords[i - 1].weight : 0) + ); + } + } + const point = Math.random() * weights[weights.length - 1]; + for (let selectedIndex = 0; selectedIndex < weights.length; selectedIndex++) { + if (weights[selectedIndex] > point) { + result.push(scratchRecords.splice(selectedIndex, 1)[0]); + break; + } + } + } + return result; +} + // src/inputs.ts var inputs_exports = {}; __export(inputs_exports, { @@ -94197,21 +94385,6 @@ function noisilyGetInput(suffix, legacyPrefix) { - -// src/errors.ts -function stringifyError(e) { - if (e instanceof Error) { - return e.message; - } else if (typeof e === "string") { - return e; - } else { - return JSON.stringify(e); - } -} - -// src/index.ts -var DEFAULT_IDS_HOST = "https://install.determinate.systems"; -var IDS_HOST = process.env["IDS_HOST"] ?? DEFAULT_IDS_HOST; var EVENT_EXCEPTION = "exception"; var EVENT_ARTIFACT_CACHE_HIT = "artifact_cache_hit"; var EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss"; @@ -94245,6 +94418,13 @@ var DetSysAction = class { } constructor(actionOptions) { this.actionOptions = makeOptionsConfident(actionOptions); + this.idsHost = new IdsHost( + this.actionOptions.idsProjectName, + actionOptions.diagnosticsSuffix, + // Note: we don't use actionsCore.getInput('diagnostic-endpoint') on purpose: + // getInput silently converts absent data to an empty string. + process.env["INPUT_DIAGNOSTIC-ENDPOINT"] + ); this.exceptionAttachments = /* @__PURE__ */ new Map(); this.nixStoreTrust = "unknown"; this.strictMode = getBool("_internal-strict-mode"); @@ -94256,9 +94436,9 @@ var DetSysAction = class { }, hooks: { beforeRetry: [ - (error2, retryCount) => { + (error3, retryCount) => { core.info( - `Retrying after error ${error2.code}, retry #: ${retryCount}` + `Retrying after error ${error3.code}, retry #: ${retryCount}` ); } ] @@ -94335,8 +94515,8 @@ var DetSysAction = class { * Execute the Action as defined. */ execute() { - this.executeAsync().catch((error2) => { - console.log(error2); + this.executeAsync().catch((error3) => { + console.log(error3); process.exitCode = 1; }); } @@ -94347,8 +94527,8 @@ var DetSysAction = class { addFact(key, value) { this.facts[key] = value; } - getDiagnosticsUrl() { - return this.actionOptions.diagnosticsUrl; + async getDiagnosticsUrl() { + return await this.idsHost.getDiagnosticsUrl(); } getUniqueId() { return this.identity.run_differentiator || process.env.RUNNER_TRACKING_ID || (0,external_node_crypto_namespaceObject.randomUUID)(); @@ -94386,7 +94566,7 @@ var DetSysAction = class { */ async fetchExecutable() { const binaryPath = await this.fetchArtifact(); - await (0,promises_namespaceObject.chmod)(binaryPath, promises_namespaceObject.constants.S_IXUSR | promises_namespaceObject.constants.S_IXGRP); + await (0,external_node_fs_promises_namespaceObject.chmod)(binaryPath, external_node_fs_promises_namespaceObject.constants.S_IXUSR | external_node_fs_promises_namespaceObject.constants.S_IXGRP); return binaryPath; } get isMain() { @@ -94461,8 +94641,8 @@ var DetSysAction = class { `Downloading ${this.actionOptions.name} for ${this.architectureFetchSuffix}` ); try { - core.info(`Fetching from ${this.getSourceUrl()}`); - const correlatedUrl = this.getSourceUrl(); + core.info(`Fetching from ${await this.getSourceUrl()}`); + const correlatedUrl = await this.getSourceUrl(); correlatedUrl.searchParams.set("ci", "github"); correlatedUrl.searchParams.set( "correlation", @@ -94473,7 +94653,7 @@ var DetSysAction = class { const v = versionCheckup.headers.etag; this.addFact(FACT_SOURCE_URL_ETAG, v); core.debug( - `Checking the tool cache for ${this.getSourceUrl()} at ${v}` + `Checking the tool cache for ${await this.getSourceUrl()} at ${v}` ); const cached = await this.getCachedVersion(v); if (cached) { @@ -94521,13 +94701,13 @@ var DetSysAction = class { this.recordEvent(`complete_${this.executionPhase}`); await this.submitEvents(); } - getSourceUrl() { + async getSourceUrl() { const p = this.sourceParameters; if (p.url) { this.addFact(FACT_SOURCE_URL, p.url); return new URL(p.url); } - const fetchUrl = new URL(IDS_HOST); + const fetchUrl = await this.idsHost.getRootUrl(); fetchUrl.pathname += this.actionOptions.idsProjectName; if (p.tag) { fetchUrl.pathname += `/tag/${p.tag}`; @@ -94552,7 +94732,7 @@ var DetSysAction = class { const startCwd = process.cwd(); try { const tempDir = this.getTemporaryName(); - await (0,promises_namespaceObject.mkdir)(tempDir); + await (0,external_node_fs_promises_namespaceObject.mkdir)(tempDir); process.chdir(tempDir); process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE; delete process.env.GITHUB_WORKSPACE; @@ -94578,9 +94758,9 @@ var DetSysAction = class { const startCwd = process.cwd(); try { const tempDir = this.getTemporaryName(); - await (0,promises_namespaceObject.mkdir)(tempDir); + await (0,external_node_fs_promises_namespaceObject.mkdir)(tempDir); process.chdir(tempDir); - await (0,promises_namespaceObject.copyFile)(toolPath, `${tempDir}/${this.actionOptions.name}`); + await (0,external_node_fs_promises_namespaceObject.copyFile)(toolPath, `${tempDir}/${this.actionOptions.name}`); process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE; delete process.env.GITHUB_WORKSPACE; await cache.saveCache( @@ -94602,7 +94782,7 @@ var DetSysAction = class { for (const location of pathParts) { const candidateNix = external_node_path_namespaceObject.join(location, "nix"); try { - await promises_namespaceObject.access(candidateNix, promises_namespaceObject.constants.X_OK); + await external_node_fs_promises_namespaceObject.access(candidateNix, external_node_fs_promises_namespaceObject.constants.X_OK); core.debug(`Found Nix at ${candidateNix}`); nixLocation = candidateNix; break; @@ -94683,7 +94863,8 @@ var DetSysAction = class { } } async submitEvents() { - if (this.actionOptions.diagnosticsUrl === void 0) { + const diagnosticsUrl = await this.idsHost.getDiagnosticsUrl(); + if (diagnosticsUrl === void 0) { core.debug( "Diagnostics are disabled. Not sending the following events:" ); @@ -94696,7 +94877,7 @@ var DetSysAction = class { events: this.events }; try { - await this.client.post(this.actionOptions.diagnosticsUrl, { + await this.client.post(diagnosticsUrl, { json: batch, timeout: { request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS @@ -94706,12 +94887,28 @@ var DetSysAction = class { core.debug( `Error submitting diagnostics event: ${stringifyError2(e)}` ); + this.idsHost.markCurrentHostBroken(); + const secondaryDiagnosticsUrl = await this.idsHost.getDiagnosticsUrl(); + if (secondaryDiagnosticsUrl !== void 0) { + try { + await this.client.post(secondaryDiagnosticsUrl, { + json: batch, + timeout: { + request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS + } + }); + } catch (err) { + core.debug( + `Error submitting diagnostics event to secondary host (${secondaryDiagnosticsUrl}): ${stringifyError2(err)}` + ); + } + } } this.events = []; } }; -function stringifyError2(error2) { - return error2 instanceof Error || typeof error2 == "string" ? error2.toString() : JSON.stringify(error2); +function stringifyError2(error3) { + return error3 instanceof Error || typeof error3 == "string" ? error3.toString() : JSON.stringify(error3); } function makeOptionsConfident(actionOptions) { const idsProjectName = actionOptions.idsProjectName ?? actionOptions.name; @@ -94721,72 +94918,12 @@ function makeOptionsConfident(actionOptions) { eventPrefix: actionOptions.eventPrefix || "action:", fetchStyle: actionOptions.fetchStyle, legacySourcePrefix: actionOptions.legacySourcePrefix, - requireNix: actionOptions.requireNix, - diagnosticsUrl: determineDiagnosticsUrl( - idsProjectName, - actionOptions.diagnosticsUrl - ) + requireNix: actionOptions.requireNix }; core.debug("idslib options:"); core.debug(JSON.stringify(finalOpts, void 0, 2)); return finalOpts; } -function determineDiagnosticsUrl(idsProjectName, urlOption) { - if (urlOption === null) { - return void 0; - } - if (urlOption !== void 0) { - return urlOption; - } - { - const providedDiagnosticEndpoint = process.env["INPUT_DIAGNOSTIC-ENDPOINT"]; - if (providedDiagnosticEndpoint === "") { - return void 0; - } - if (providedDiagnosticEndpoint !== void 0) { - try { - return mungeDiagnosticEndpoint(new URL(providedDiagnosticEndpoint)); - } catch (e) { - core.info( - `User-provided diagnostic endpoint ignored: not a valid URL: ${stringifyError2(e)}` - ); - } - } - } - try { - const diagnosticUrl = new URL(IDS_HOST); - diagnosticUrl.pathname += idsProjectName; - diagnosticUrl.pathname += "/diagnostics"; - return diagnosticUrl; - } catch (e) { - core.info( - `Generated diagnostic endpoint ignored: not a valid URL: ${stringifyError2(e)}` - ); - } - return void 0; -} -function mungeDiagnosticEndpoint(inputUrl) { - if (DEFAULT_IDS_HOST === IDS_HOST) { - return inputUrl; - } - try { - const defaultIdsHost = new URL(DEFAULT_IDS_HOST); - const currentIdsHost = new URL(IDS_HOST); - if (inputUrl.origin !== defaultIdsHost.origin) { - return inputUrl; - } - inputUrl.protocol = currentIdsHost.protocol; - inputUrl.host = currentIdsHost.host; - inputUrl.username = currentIdsHost.username; - inputUrl.password = currentIdsHost.password; - return inputUrl; - } catch (e) { - core.info( - `Default or overridden IDS host isn't a valid URL: ${stringifyError2(e)}` - ); - } - return inputUrl; -} /*! * linux-release-info @@ -94810,9 +94947,7 @@ var FlakeCheckerAction = class extends DetSysAction { super({ name: "flake-checker", fetchStyle: "gh-env-style", - diagnosticsUrl: new URL( - "https://install.determinate.systems/flake-checker/telemetry" - ), + diagnosticsSuffix: "telemetry", // We don't need Nix in this Action because we fetch a static binary using curl and run it requireNix: "ignore" }); diff --git a/dist/index.js.map b/dist/index.js.map index 0a12ec3..9805e56 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 { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\nclass FlakeCheckerAction extends DetSysAction {\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 super({\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.flakeLockPath = inputs.getString(\"flake-lock-path\");\n this.nixpkgsKeys = inputs.getString(\"nixpkgs-keys\");\n this.checkOutdated = inputs.getBool(\"check-outdated\");\n this.checkOwner = inputs.getBool(\"check-owner\");\n this.checkSupported = inputs.getBool(\"check-supported\");\n this.ignoreMissingFlakeLock = inputs.getBool(\"ignore-missing-flake-lock\");\n this.failMode = inputs.getBool(\"fail-mode\");\n this.sendStatistics = inputs.getBool(\"send-statistics\");\n }\n\n async main(): Promise {\n await this.checkFlake();\n }\n\n // No post step\n async post(): Promise {}\n\n private async checkFlake(): Promise {\n const binaryPath = await this.fetchExecutable();\n const executionEnv = await this.executionEnvironment();\n\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.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`Non-zero exit code of \\`${exitCode}\\`.`);\n }\n\n return exitCode;\n }\n\n private async executionEnvironment(): Promise {\n const executionEnv: ExecutionEnvironment = {};\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\ntype ExecutionEnvironment = {\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 new FlakeCheckerAction().execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAS,cAAc,cAAc;AAErC,IAAM,0BAA0B;AAEhC,IAAM,qBAAN,cAAiC,aAAa;AAAA,EAU5C,cAAc;AACZ,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,gBAAgB,IAAI;AAAA,QAClB;AAAA,MACF;AAAA;AAAA,MAEA,YAAY;AAAA,IACd,CAAC;AAED,SAAK,gBAAgB,OAAO,UAAU,iBAAiB;AACvD,SAAK,cAAc,OAAO,UAAU,cAAc;AAClD,SAAK,gBAAgB,OAAO,QAAQ,gBAAgB;AACpD,SAAK,aAAa,OAAO,QAAQ,aAAa;AAC9C,SAAK,iBAAiB,OAAO,QAAQ,iBAAiB;AACtD,SAAK,yBAAyB,OAAO,QAAQ,2BAA2B;AACxE,SAAK,WAAW,OAAO,QAAQ,WAAW;AAC1C,SAAK,iBAAiB,OAAO,QAAQ,iBAAiB;AAAA,EACxD;AAAA,EAEA,MAAM,OAAsB;AAC1B,UAAM,KAAK,WAAW;AAAA,EACxB;AAAA;AAAA,EAGA,MAAM,OAAsB;AAAA,EAAC;AAAA,EAE7B,MAAc,aAA8B;AAC1C,UAAM,aAAa,MAAM,KAAK,gBAAgB;AAC9C,UAAM,eAAe,MAAM,KAAK,qBAAqB;AAErD,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,MACA,kBAAkB;AAAA,IACpB,CAAC;AAED,QAAI,aAAa,GAAG;AAClB,WAAK,YAAY,yBAAyB;AAAA,QACxC;AAAA,MACF,CAAC;AACD,MAAY,sBAAU,2BAA2B,QAAQ,KAAK;AAAA,IAChE;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,uBAAsD;AAClE,UAAM,eAAqC,CAAC;AAE5C,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;AACF;AAeA,SAAS,OAAa;AACpB,MAAI,mBAAmB,EAAE,QAAQ;AACnC;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 { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\nclass FlakeCheckerAction extends DetSysAction {\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 super({\n name: \"flake-checker\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"telemetry\",\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.flakeLockPath = inputs.getString(\"flake-lock-path\");\n this.nixpkgsKeys = inputs.getString(\"nixpkgs-keys\");\n this.checkOutdated = inputs.getBool(\"check-outdated\");\n this.checkOwner = inputs.getBool(\"check-owner\");\n this.checkSupported = inputs.getBool(\"check-supported\");\n this.ignoreMissingFlakeLock = inputs.getBool(\"ignore-missing-flake-lock\");\n this.failMode = inputs.getBool(\"fail-mode\");\n this.sendStatistics = inputs.getBool(\"send-statistics\");\n }\n\n async main(): Promise {\n await this.checkFlake();\n }\n\n // No post step\n async post(): Promise {}\n\n private async checkFlake(): Promise {\n const binaryPath = await this.fetchExecutable();\n const executionEnv = await this.executionEnvironment();\n\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.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`Non-zero exit code of \\`${exitCode}\\`.`);\n }\n\n return exitCode;\n }\n\n private async executionEnvironment(): Promise {\n const executionEnv: ExecutionEnvironment = {};\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\ntype ExecutionEnvironment = {\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 new FlakeCheckerAction().execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAS,cAAc,cAAc;AAErC,IAAM,0BAA0B;AAEhC,IAAM,qBAAN,cAAiC,aAAa;AAAA,EAU5C,cAAc;AACZ,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,mBAAmB;AAAA;AAAA,MAEnB,YAAY;AAAA,IACd,CAAC;AAED,SAAK,gBAAgB,OAAO,UAAU,iBAAiB;AACvD,SAAK,cAAc,OAAO,UAAU,cAAc;AAClD,SAAK,gBAAgB,OAAO,QAAQ,gBAAgB;AACpD,SAAK,aAAa,OAAO,QAAQ,aAAa;AAC9C,SAAK,iBAAiB,OAAO,QAAQ,iBAAiB;AACtD,SAAK,yBAAyB,OAAO,QAAQ,2BAA2B;AACxE,SAAK,WAAW,OAAO,QAAQ,WAAW;AAC1C,SAAK,iBAAiB,OAAO,QAAQ,iBAAiB;AAAA,EACxD;AAAA,EAEA,MAAM,OAAsB;AAC1B,UAAM,KAAK,WAAW;AAAA,EACxB;AAAA;AAAA,EAGA,MAAM,OAAsB;AAAA,EAAC;AAAA,EAE7B,MAAc,aAA8B;AAC1C,UAAM,aAAa,MAAM,KAAK,gBAAgB;AAC9C,UAAM,eAAe,MAAM,KAAK,qBAAqB;AAErD,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,MACA,kBAAkB;AAAA,IACpB,CAAC;AAED,QAAI,aAAa,GAAG;AAClB,WAAK,YAAY,yBAAyB;AAAA,QACxC;AAAA,MACF,CAAC;AACD,MAAY,sBAAU,2BAA2B,QAAQ,KAAK;AAAA,IAChE;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,uBAAsD;AAClE,UAAM,eAAqC,CAAC;AAE5C,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;AACF;AAeA,SAAS,OAAa;AACpB,MAAI,mBAAmB,EAAE,QAAQ;AACnC;AAEA,KAAK;","names":[]} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d47f17d..bd5e972 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ dependencies: version: 1.1.1 detsys-ts: specifier: github:DeterminateSystems/detsys-ts - version: github.com/DeterminateSystems/detsys-ts/5fcb0532d85556ebc2de286e483885976531339d + version: github.com/DeterminateSystems/detsys-ts/9d66d2c89c150f796165fdcc20b3be538807c0f4 devDependencies: '@trivago/prettier-plugin-sort-imports': @@ -329,7 +329,7 @@ packages: '@babel/helper-split-export-declaration': 7.24.6 '@babel/parser': 7.24.6 '@babel/types': 7.24.6 - debug: 4.3.4 + debug: 4.3.5 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -579,7 +579,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.5 espree: 9.6.1 globals: 13.24.0 ignore: 5.3.1 @@ -610,7 +610,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 2.0.3 - debug: 4.3.4 + debug: 4.3.5 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -940,7 +940,7 @@ packages: '@typescript-eslint/types': 7.11.0 '@typescript-eslint/typescript-estree': 7.11.0(typescript@5.4.5) '@typescript-eslint/visitor-keys': 7.11.0 - debug: 4.3.4 + debug: 4.3.5 eslint: 8.57.0 typescript: 5.4.5 transitivePeerDependencies: @@ -967,7 +967,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 7.11.0(typescript@5.4.5) '@typescript-eslint/utils': 7.11.0(eslint@8.57.0)(typescript@5.4.5) - debug: 4.3.4 + debug: 4.3.5 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.4.5) typescript: 5.4.5 @@ -991,7 +991,7 @@ packages: dependencies: '@typescript-eslint/types': 7.11.0 '@typescript-eslint/visitor-keys': 7.11.0 - debug: 4.3.4 + debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.4 @@ -1246,7 +1246,7 @@ packages: hasBin: true dependencies: caniuse-lite: 1.0.30001625 - electron-to-chromium: 1.4.784 + electron-to-chromium: 1.4.787 node-releases: 2.0.14 update-browserslist-db: 1.0.16(browserslist@4.23.0) dev: true @@ -1423,8 +1423,8 @@ packages: ms: 2.1.3 dev: true - /debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + /debug@4.3.5: + resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -1504,8 +1504,8 @@ packages: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true - /electron-to-chromium@1.4.784: - resolution: {integrity: sha512-9CZwh+sDrhDAeOEFh8s3PqwduzTyYIeYwZolc1b9ENAUt3ePu7R1sJSCWr/820ISssRxCJUyHI9Wb7j+0Uo1AA==} + /electron-to-chromium@1.4.787: + resolution: {integrity: sha512-d0EFmtLPjctczO3LogReyM2pbBiiZbnsKnGF+cdZhsYzHm/A0GV7W94kqzLD8SN4O3f3iHlgLUChqghgyznvCQ==} dev: true /emoji-regex@8.0.0: @@ -1711,7 +1711,7 @@ packages: eslint: '*' eslint-plugin-import: '*' dependencies: - debug: 4.3.4 + debug: 4.3.5 enhanced-resolve: 5.16.1 eslint: 8.57.0 eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.11.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) @@ -1949,7 +1949,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.5 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -3539,7 +3539,7 @@ packages: bundle-require: 4.1.0(esbuild@0.19.12) cac: 6.7.14 chokidar: 3.6.0 - debug: 4.3.4 + debug: 4.3.5 esbuild: 0.19.12 execa: 5.1.1 globby: 11.1.0 @@ -3801,8 +3801,8 @@ packages: engines: {node: '>=10'} dev: true - github.com/DeterminateSystems/detsys-ts/5fcb0532d85556ebc2de286e483885976531339d: - resolution: {tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/5fcb0532d85556ebc2de286e483885976531339d} + github.com/DeterminateSystems/detsys-ts/9d66d2c89c150f796165fdcc20b3be538807c0f4: + resolution: {tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/9d66d2c89c150f796165fdcc20b3be538807c0f4} name: detsys-ts version: 1.0.0 dependencies: diff --git a/src/index.ts b/src/index.ts index 4e992e4..20dc286 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,9 +18,7 @@ class FlakeCheckerAction extends DetSysAction { super({ name: "flake-checker", fetchStyle: "gh-env-style", - diagnosticsUrl: new URL( - "https://install.determinate.systems/flake-checker/telemetry", - ), + diagnosticsSuffix: "telemetry", // We don't need Nix in this Action because we fetch a static binary using curl and run it requireNix: "ignore", });