diff --git a/dist/index.d.ts b/dist/index.d.ts index 460d8e2..c25fb13 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -62,7 +62,7 @@ declare class IdsHost { private prioritizedURLs?; private client?; constructor(idsProjectName: string, diagnosticsSuffix: string | undefined, runtimeDiagnosticsUrl: string | undefined); - getGot(recordFailoverCallback?: (prevUrl: URL, nextUrl: URL) => void): Promise; + getGot(recordFailoverCallback?: (incitingError: unknown, prevUrl: URL, nextUrl: URL) => void): Promise; markCurrentHostBroken(): void; setPrioritizedUrls(urls: URL[]): void; isUrlSubjectToDynamicUrls(url: URL): boolean; @@ -261,7 +261,7 @@ declare abstract class DetSysAction { getUniqueId(): string; getCrossPhaseId(): string; getCorrelationHashes(): AnonymizedCorrelationHashes; - recordEvent(eventName: string, context?: Record): void; + recordEvent(eventName: string, context?: Record): void; /** * Unpacks the closure returned by `fetchArtifact()`, imports the * contents into the Nix store, and returns the path of the executable at @@ -287,6 +287,7 @@ declare abstract class DetSysAction { * 3. Get feature flag data so we can gently roll out new features. */ private requestCheckIn; + private recordPlausibleTimeout; /** * Fetch an artifact, such as a tarball, from the location determined by the * `source-*` inputs. If `source-binary` is specified, this will return a path @@ -300,6 +301,7 @@ declare abstract class DetSysAction { * This is intended only for CI environments testing Actions themselves. */ failOnError(msg: string): void; + private downloadFile; private complete; private getCheckInUrl; private getSourceUrl; diff --git a/dist/index.js b/dist/index.js index 70b95de..7630d8a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -471,7 +471,7 @@ var ALLOWED_SUFFIXES = [ ]; var DEFAULT_IDS_HOST = "https://install.determinate.systems"; var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP; -var DEFAULT_TIMEOUT = 3e4; +var DEFAULT_TIMEOUT = 1e4; var IdsHost = class { constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) { this.idsProjectName = idsProjectName; @@ -486,7 +486,7 @@ var IdsHost = class { request: DEFAULT_TIMEOUT }, retry: { - limit: (await this.getUrlsByPreference()).length, + limit: Math.max((await this.getUrlsByPreference()).length, 3), methods: ["GET", "HEAD"] }, hooks: { @@ -496,7 +496,7 @@ var IdsHost = class { this.markCurrentHostBroken(); const nextUrl = await this.getRootUrl(); if (recordFailoverCallback !== void 0) { - recordFailoverCallback(prevUrl, nextUrl); + recordFailoverCallback(error3, prevUrl, nextUrl); } actionsCore4.info( `Retrying after error ${error3.code}, retry #: ${retryCount}` @@ -849,14 +849,17 @@ function noisilyGetInput(suffix, legacyPrefix) { import * as actionsCache from "@actions/cache"; import * as actionsCore8 from "@actions/core"; import * as actionsExec from "@actions/exec"; +import { TimeoutError } from "got"; import { exec as exec4 } from "node:child_process"; import { randomUUID } from "node:crypto"; -import { createWriteStream, readFileSync as readFileSync2 } from "node:fs"; +import { + createWriteStream, + readFileSync as readFileSync2 +} from "node:fs"; import fs2, { chmod, copyFile, mkdir } from "node:fs/promises"; import * as os3 from "node:os"; import { tmpdir } from "node:os"; import * as path from "node:path"; -import { pipeline } from "node:stream/promises"; import { promisify as promisify3 } from "node:util"; import { gzip as gzip2 } from "node:zlib"; var EVENT_BACKTRACES = "backtrace"; @@ -882,8 +885,8 @@ var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found"; var STATE_NOT_FOUND = "not-found"; var STATE_KEY_CROSS_PHASE_ID = "detsys_cross_phase_id"; var STATE_BACKTRACE_START_TIMESTAMP = "detsys_backtrace_start_timestamp"; -var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4; -var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3; +var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 1e4; +var CHECK_IN_ENDPOINT_TIMEOUT_MS = 1e3; var DetSysAction = class { determineExecutionPhase() { const currentPhase = actionsCore8.getState(STATE_KEY_EXECUTION_PHASE); @@ -1107,12 +1110,15 @@ var DetSysAction = class { } } async getClient() { - return await this.idsHost.getGot((prevUrl, nextUrl) => { - this.recordEvent("ids-failover", { - previousUrl: prevUrl.toString(), - nextUrl: nextUrl.toString() - }); - }); + return await this.idsHost.getGot( + (incitingError, prevUrl, nextUrl) => { + this.recordPlausibleTimeout(incitingError); + this.recordEvent("ids-failover", { + previousUrl: prevUrl.toString(), + nextUrl: nextUrl.toString() + }); + } + ); } async checkIn() { const checkin = await this.requestCheckIn(); @@ -1196,12 +1202,27 @@ var DetSysAction = class { } }).json(); } catch (e) { + this.recordPlausibleTimeout(e); actionsCore8.debug(`Error checking in: ${stringifyError2(e)}`); this.idsHost.markCurrentHostBroken(); } } return void 0; } + recordPlausibleTimeout(e) { + if (e instanceof TimeoutError && "timings" in e && "request" in e) { + const reportContext = { + url: e.request.requestUrl?.toString(), + retry_count: e.request.retryCount + }; + for (const [key, value] of Object.entries(e.timings.phases)) { + if (Number.isFinite(value)) { + reportContext[`timing_phase_${key}`] = value; + } + } + this.recordEvent("timeout", reportContext); + } + } /** * Fetch an artifact, such as a tarball, from the location determined by the * `source-*` inputs. If `source-binary` is specified, this will return a path @@ -1245,13 +1266,9 @@ var DetSysAction = class { `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}` ); const destFile = this.getTemporaryName(); - const fetchStream = (await this.getClient()).stream(versionCheckup.url); - await pipeline( - fetchStream, - createWriteStream(destFile, { - encoding: "binary", - mode: 493 - }) + const fetchStream = await this.downloadFile( + new URL(versionCheckup.url), + destFile ); if (fetchStream.response?.headers.etag) { const v = fetchStream.response.headers.etag; @@ -1262,6 +1279,9 @@ var DetSysAction = class { } } return destFile; + } catch (e) { + this.recordPlausibleTimeout(e); + throw e; } finally { actionsCore8.endGroup(); } @@ -1275,6 +1295,36 @@ var DetSysAction = class { actionsCore8.setFailed(`strict mode failure: ${msg}`); } } + async downloadFile(url, destination) { + const client = await this.getClient(); + return new Promise((resolve, reject) => { + let writeStream; + let failed = false; + const retry = (stream) => { + if (writeStream) { + writeStream.destroy(); + } + writeStream = createWriteStream(destination, { + encoding: "binary", + mode: 493 + }); + writeStream.once("error", (error3) => { + failed = true; + reject(error3); + }); + writeStream.on("finish", () => { + if (!failed) { + resolve(stream); + } + }); + stream.once("retry", (_count, _error, createRetryStream) => { + retry(createRetryStream()); + }); + stream.pipe(writeStream); + }; + retry(client.stream(url)); + }); + } async complete() { this.recordEvent(`complete_${this.executionPhase}`); await this.submitEvents(); @@ -1498,6 +1548,7 @@ var DetSysAction = class { } }); } catch (err) { + this.recordPlausibleTimeout(err); actionsCore8.debug( `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError2(err)}` ); diff --git a/dist/index.js.map b/dist/index.js.map index 75f9c13..e772f82 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/errors.ts","../src/backtrace.ts","../src/correlation.ts","../src/ids-host.ts","../src/inputs.ts","../src/platform.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc\",\n \"test\": \"vitest --watch false\",\n \"test-dev\": \"vitest\",\n \"all\": \"rm -rf dist && pnpm run format && pnpm run lint && pnpm run build\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/DeterminateSystems/detsys-ts.git\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/DeterminateSystems/detsys-ts/issues\"\n },\n \"homepage\": \"https://github.com/DeterminateSystems/detsys-ts#readme\",\n \"dependencies\": {\n \"@actions/cache\": \"^3.2.4\",\n \"@actions/core\": \"^1.10.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.4.2\",\n \"type-fest\": \"^4.23.0\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.14.13\",\n \"@typescript-eslint/eslint-plugin\": \"^7.18.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.2.1\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.2.3\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.5.4\",\n \"vitest\": \"^1.6.0\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle. We've modified the original logic to improve things like typing\n// and fixing ESLint issues. Originally drawn from:\n// https://github.com/samuelcarreira/linux-release-info/blob/84a91aa5442b47900da03020c590507545d3dc74/src/index.ts\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osReleaseFileList(\n options.customFile,\n );\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osReleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n\n/* Helper functions */\n\nasync function readAsyncOsReleaseFile(\n fileList: string[],\n options: LinuxReleaseInfoOptions,\n): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (options.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n\nfunction readSyncOsreleaseFile(\n releaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as actionsCore from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n actionsCore.debug(`Identified release info: ${JSON.stringify(data)}`);\n } catch (e) {\n actionsCore.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","/**\n * Coerce a value of type `unknown` into a string.\n */\nexport function stringifyError(e: unknown): string {\n if (e instanceof Error) {\n return e.message;\n } else if (typeof e === \"string\") {\n return e;\n } else {\n return JSON.stringify(e);\n }\n}\n","/**\n * @packageDocumentation\n * Collects backtraces for executables for diagnostics\n */\nimport { isLinux, isMacOS } from \"./actions-core-platform.js\";\nimport { stringifyError } from \"./errors.js\";\nimport * as actionsCore from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport { readFile, readdir, stat } from \"node:fs/promises\";\nimport { promisify } from \"node:util\";\nimport { gzip } from \"node:zlib\";\n\nexport async function collectBacktraces(\n prefixes: string[],\n startTimestampMs: number,\n): Promise> {\n if (isMacOS) {\n return await collectBacktracesMacOS(prefixes, startTimestampMs);\n }\n if (isLinux) {\n return await collectBacktracesSystemd(prefixes, startTimestampMs);\n }\n\n return new Map();\n}\n\nexport async function collectBacktracesMacOS(\n prefixes: string[],\n startTimestampMs: number,\n): Promise> {\n const backtraces: Map = new Map();\n\n try {\n const { stdout: logJson } = await exec.getExecOutput(\n \"log\",\n [\n \"show\",\n \"--style\",\n \"json\",\n \"--last\",\n // Note we collect the last 1m only, because it should only take a few seconds to write the crash log.\n // Therefore, any crashes before this 1m should be long done by now.\n \"1m\",\n \"--no-info\",\n \"--predicate\",\n \"sender = 'ReportCrash'\",\n ],\n {\n silent: true,\n },\n );\n\n const sussyArray: unknown = JSON.parse(logJson);\n if (!Array.isArray(sussyArray)) {\n throw new Error(`Log json isn't an array: ${logJson}`);\n }\n\n if (sussyArray.length > 0) {\n actionsCore.info(`Collecting crash data...`);\n const delay = async (ms: number): Promise =>\n new Promise((resolve) => setTimeout(resolve, ms));\n await delay(5000);\n }\n } catch (e: unknown) {\n actionsCore.debug(\n \"Failed to check logs for in-progress crash dumps; now proceeding with the assumption that all crash dumps completed.\",\n );\n }\n\n const dirs = [\n [\"system\", \"/Library/Logs/DiagnosticReports/\"],\n [\"user\", `${process.env[\"HOME\"]}/Library/Logs/DiagnosticReports/`],\n ];\n\n for (const [source, dir] of dirs) {\n const fileNames = (await readdir(dir))\n .filter((fileName) => {\n return prefixes.some((prefix) => fileName.startsWith(prefix));\n })\n .filter((fileName) => {\n // macOS creates .diag files periodically, which are called \"microstackshots\".\n // We don't necessarily want those, and they're definitely not crashes.\n // See: https://patents.google.com/patent/US20140237219A1/en\n return !fileName.endsWith(\".diag\");\n });\n\n const doGzip = promisify(gzip);\n for (const fileName of fileNames) {\n try {\n if ((await stat(`${dir}/${fileName}`)).ctimeMs >= startTimestampMs) {\n const logText = await readFile(`${dir}/${fileName}`);\n const buf = await doGzip(logText);\n backtraces.set(\n `backtrace_value_${source}_${fileName}`,\n buf.toString(\"base64\"),\n );\n }\n } catch (innerError: unknown) {\n backtraces.set(\n `backtrace_failure_${source}_${fileName}`,\n stringifyError(innerError),\n );\n }\n }\n }\n\n return backtraces;\n}\n\ntype SystemdCoreDumpInfo = {\n exe: string;\n pid: number;\n};\n\nexport async function collectBacktracesSystemd(\n prefixes: string[],\n startTimestampMs: number,\n): Promise> {\n const sinceSeconds = Math.ceil((Date.now() - startTimestampMs) / 1000);\n const backtraces: Map = new Map();\n\n const coredumps: SystemdCoreDumpInfo[] = [];\n\n try {\n const { stdout: coredumpjson } = await exec.getExecOutput(\n \"coredumpctl\",\n [\"--json=pretty\", \"list\", \"--since\", `${sinceSeconds} seconds ago`],\n {\n silent: true,\n },\n );\n\n const sussyArray: unknown = JSON.parse(coredumpjson);\n if (!Array.isArray(sussyArray)) {\n throw new Error(`Coredump isn't an array: ${coredumpjson}`);\n }\n\n for (const sussyObject of sussyArray) {\n const keys = Object.keys(sussyObject);\n\n if (keys.includes(\"exe\") && keys.includes(\"pid\")) {\n if (\n typeof sussyObject.exe == \"string\" &&\n typeof sussyObject.pid == \"number\"\n ) {\n const execParts = sussyObject.exe.split(\"/\");\n const binaryName = execParts[execParts.length - 1];\n\n if (prefixes.some((prefix) => binaryName.startsWith(prefix))) {\n coredumps.push({\n exe: sussyObject.exe,\n pid: sussyObject.pid,\n });\n }\n } else {\n actionsCore.debug(\n `Mysterious coredump entry missing exe string and/or pid number: ${JSON.stringify(sussyObject)}`,\n );\n }\n } else {\n actionsCore.debug(\n `Mysterious coredump entry missing exe value and/or pid value: ${JSON.stringify(sussyObject)}`,\n );\n }\n }\n } catch (innerError: unknown) {\n actionsCore.debug(\n `Cannot collect backtraces: ${stringifyError(innerError)}`,\n );\n\n return backtraces;\n }\n\n const doGzip = promisify(gzip);\n for (const coredump of coredumps) {\n try {\n const { stdout: logText } = await exec.getExecOutput(\n \"coredumpctl\",\n [\"info\", `${coredump.pid}`],\n {\n silent: true,\n },\n );\n\n const buf = await doGzip(logText);\n backtraces.set(`backtrace_value_${coredump.pid}`, buf.toString(\"base64\"));\n } catch (innerError: unknown) {\n backtraces.set(\n `backtrace_failure_${coredump.pid}`,\n stringifyError(innerError),\n );\n }\n }\n\n return backtraces;\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n/* eslint-disable camelcase */\n/**\n * JSON sent to server.\n */\nexport type AnonymizedCorrelationHashes = {\n correlation_source: string;\n repository?: string;\n run?: string;\n run_differentiator?: string;\n workflow?: string;\n groups: Record;\n};\n\nexport function identify(projectName: string): AnonymizedCorrelationHashes {\n const ident = {\n correlation_source: \"github-actions\",\n\n repository: hashEnvironmentVariables(\"GHR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n ]),\n workflow: hashEnvironmentVariables(\"GHW\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n ]),\n job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\n ]),\n groups: {\n ci: \"github-actions\",\n project: projectName,\n github_organization: hashEnvironmentVariables(\"GHO\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n ]),\n },\n };\n\n actionsCore.debug(\"Correlation data:\");\n actionsCore.debug(JSON.stringify(ident, null, 2));\n\n return ident;\n}\n\nfunction hashEnvironmentVariables(\n prefix: string,\n variables: string[],\n): undefined | string {\n const hash = createHash(\"sha256\");\n\n for (const varName of variables) {\n let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Identifies and discovers backend servers for install.determinate.systems\n */\nimport { stringifyError } from \"./errors.js\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport type { SrvRecord } from \"node:dns\";\nimport { resolveSrv } from \"node:dns/promises\";\n\nconst DEFAULT_LOOKUP = \"_detsys_ids._tcp.install.determinate.systems.\";\nconst ALLOWED_SUFFIXES = [\n \".install.determinate.systems\",\n \".install.detsys.dev\",\n];\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst LOOKUP = process.env[\"IDS_LOOKUP\"] ?? DEFAULT_LOOKUP;\n\nconst DEFAULT_TIMEOUT = 30_000; // 30 seconds in milliseconds\n\n/**\n * Host information for install.determinate.systems.\n */\nexport class IdsHost {\n private idsProjectName: string;\n private diagnosticsSuffix?: string;\n private runtimeDiagnosticsUrl?: string;\n private prioritizedURLs?: URL[];\n private client?: Got;\n\n constructor(\n idsProjectName: string,\n diagnosticsSuffix: string | undefined,\n runtimeDiagnosticsUrl: string | undefined,\n ) {\n this.idsProjectName = idsProjectName;\n this.diagnosticsSuffix = diagnosticsSuffix;\n this.runtimeDiagnosticsUrl = runtimeDiagnosticsUrl;\n this.client = undefined;\n }\n\n async getGot(\n recordFailoverCallback?: (prevUrl: URL, nextUrl: URL) => void,\n ): Promise {\n if (this.client === undefined) {\n this.client = got.extend({\n timeout: {\n request: DEFAULT_TIMEOUT,\n },\n\n retry: {\n limit: (await this.getUrlsByPreference()).length,\n methods: [\"GET\", \"HEAD\"],\n },\n\n hooks: {\n beforeRetry: [\n async (error, retryCount) => {\n const prevUrl = await this.getRootUrl();\n this.markCurrentHostBroken();\n const nextUrl = await this.getRootUrl();\n\n if (recordFailoverCallback !== undefined) {\n recordFailoverCallback(prevUrl, nextUrl);\n }\n\n actionsCore.info(\n `Retrying after error ${error.code}, retry #: ${retryCount}`,\n );\n },\n ],\n\n beforeRequest: [\n async (options) => {\n // The getter always returns a URL, even though the setter accepts a string\n const currentUrl: URL = options.url as URL;\n\n if (this.isUrlSubjectToDynamicUrls(currentUrl)) {\n const newUrl: URL = new URL(currentUrl);\n\n const url: URL = await this.getRootUrl();\n newUrl.host = url.host;\n\n options.url = newUrl;\n actionsCore.debug(`Transmuted ${currentUrl} into ${newUrl}`);\n } else {\n actionsCore.debug(`No transmutations on ${currentUrl}`);\n }\n },\n ],\n },\n });\n }\n\n return this.client;\n }\n\n markCurrentHostBroken(): void {\n this.prioritizedURLs?.shift();\n }\n\n setPrioritizedUrls(urls: URL[]): void {\n this.prioritizedURLs = urls;\n }\n\n isUrlSubjectToDynamicUrls(url: URL): boolean {\n if (url.origin === DEFAULT_IDS_HOST) {\n return true;\n }\n\n for (const suffix of ALLOWED_SUFFIXES) {\n if (url.host.endsWith(suffix)) {\n return true;\n }\n }\n\n return false;\n }\n\n async getDynamicRootUrl(): Promise {\n const idsHost = process.env[\"IDS_HOST\"];\n if (idsHost !== undefined) {\n try {\n return new URL(idsHost);\n } catch (err: unknown) {\n actionsCore.error(\n `IDS_HOST environment variable is not a valid URL. Ignoring. ${stringifyError(err)}`,\n );\n }\n }\n\n let url: URL | undefined = undefined;\n try {\n const urls = await this.getUrlsByPreference();\n url = urls[0];\n } catch (err: unknown) {\n actionsCore.error(\n `Error collecting IDS URLs by preference: ${stringifyError(err)}`,\n );\n }\n\n if (url === undefined) {\n return undefined;\n } else {\n // This is a load-bearing `new URL(url)` so that callers can't mutate\n // getRootUrl's return value.\n return new URL(url);\n }\n }\n\n async getRootUrl(): Promise {\n const url = await this.getDynamicRootUrl();\n\n if (url === undefined) {\n return new URL(DEFAULT_IDS_HOST);\n }\n\n return url;\n }\n\n async getDiagnosticsUrl(): Promise {\n if (this.runtimeDiagnosticsUrl === \"\") {\n // User specifically set the diagnostics URL to an empty string\n // so disable diagnostics\n return undefined;\n }\n\n if (\n this.runtimeDiagnosticsUrl !== \"-\" &&\n this.runtimeDiagnosticsUrl !== undefined\n ) {\n try {\n // Caller specified a specific diagnostics URL\n return new URL(this.runtimeDiagnosticsUrl);\n } catch (err: unknown) {\n actionsCore.info(\n `User-provided diagnostic endpoint ignored: not a valid URL: ${stringifyError(err)}`,\n );\n }\n }\n\n try {\n const diagnosticUrl = await this.getRootUrl();\n diagnosticUrl.pathname += this.idsProjectName;\n diagnosticUrl.pathname += \"/\";\n diagnosticUrl.pathname += this.diagnosticsSuffix || \"diagnostics\";\n return diagnosticUrl;\n } catch (err: unknown) {\n actionsCore.info(\n `Generated diagnostic endpoint ignored, and diagnostics are disabled: not a valid URL: ${stringifyError(err)}`,\n );\n return undefined;\n }\n }\n\n private async getUrlsByPreference(): Promise {\n if (this.prioritizedURLs === undefined) {\n this.prioritizedURLs = orderRecordsByPriorityWeight(\n await discoverServiceRecords(),\n ).flatMap((record) => recordToUrl(record) || []);\n }\n\n return this.prioritizedURLs;\n }\n}\n\nexport function recordToUrl(record: SrvRecord): URL | undefined {\n const urlStr = `https://${record.name}:${record.port}`;\n try {\n return new URL(urlStr);\n } catch (err: unknown) {\n actionsCore.debug(\n `Record ${JSON.stringify(record)} produced an invalid URL: ${urlStr} (${err})`,\n );\n return undefined;\n }\n}\n\nasync function discoverServiceRecords(): Promise {\n return await discoverServicesStub(resolveSrv(LOOKUP), 1_000);\n}\n\nexport async function discoverServicesStub(\n lookup: Promise,\n timeout: number,\n): Promise {\n const defaultFallback: Promise = new Promise(\n (resolve, _reject) => {\n setTimeout(resolve, timeout, []);\n },\n );\n\n let records: SrvRecord[];\n\n try {\n records = await Promise.race([lookup, defaultFallback]);\n } catch (reason: unknown) {\n actionsCore.debug(`Error resolving SRV records: ${stringifyError(reason)}`);\n records = [];\n }\n\n const acceptableRecords = records.filter((record: SrvRecord): boolean => {\n for (const suffix of ALLOWED_SUFFIXES) {\n if (record.name.endsWith(suffix)) {\n return true;\n }\n }\n\n actionsCore.debug(\n `Unacceptable domain due to an invalid suffix: ${record.name}`,\n );\n\n return false;\n });\n\n if (acceptableRecords.length === 0) {\n actionsCore.debug(`No records found for ${LOOKUP}`);\n } else {\n actionsCore.debug(\n `Resolved ${LOOKUP} to ${JSON.stringify(acceptableRecords)}`,\n );\n }\n\n return acceptableRecords;\n}\n\nexport function orderRecordsByPriorityWeight(\n records: SrvRecord[],\n): SrvRecord[] {\n const byPriorityWeight: Map = new Map();\n for (const record of records) {\n const existing = byPriorityWeight.get(record.priority);\n if (existing) {\n existing.push(record);\n } else {\n byPriorityWeight.set(record.priority, [record]);\n }\n }\n\n const prioritizedRecords: SrvRecord[] = [];\n const keys: number[] = Array.from(byPriorityWeight.keys()).sort(\n (a, b) => a - b,\n );\n\n for (const priority of keys) {\n const recordsByPrio = byPriorityWeight.get(priority);\n if (recordsByPrio === undefined) {\n continue;\n }\n\n prioritizedRecords.push(...weightedRandom(recordsByPrio));\n }\n\n return prioritizedRecords;\n}\n\nexport function weightedRandom(records: SrvRecord[]): SrvRecord[] {\n // Duplicate records so we don't accidentally change our caller's data\n const scratchRecords: SrvRecord[] = records.slice();\n const result: SrvRecord[] = [];\n\n while (scratchRecords.length > 0) {\n const weights: number[] = [];\n\n {\n for (let i = 0; i < scratchRecords.length; i++) {\n weights.push(\n scratchRecords[i].weight + (i > 0 ? scratchRecords[i - 1].weight : 0),\n );\n }\n }\n\n const point = Math.random() * weights[weights.length - 1];\n\n for (\n let selectedIndex = 0;\n selectedIndex < weights.length;\n selectedIndex++\n ) {\n if (weights[selectedIndex] > point) {\n // Remove our selected record and add it to the result\n result.push(scratchRecords.splice(selectedIndex, 1)[0]);\n break;\n }\n }\n }\n\n return result;\n}\n","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * The character used to separate values in the input string.\n */\nexport type Separator = \"space\" | \"comma\";\n\n/**\n * Convert a comma-separated string input into an array of strings. If `comma` is selected,\n * all whitespace is removed from the string before converting to an array.\n */\nconst getArrayOfStrings = (name: string, separator: Separator): string[] => {\n const original = getString(name);\n return handleString(original, separator);\n};\n\n/**\n * Convert a string input into an array of strings or `null` if no value is set.\n */\nconst getArrayOfStringsOrNull = (\n name: string,\n separator: Separator,\n): string[] | null => {\n const original = getStringOrNull(name);\n if (original === null) {\n return null;\n } else {\n return handleString(original, separator);\n }\n};\n\n// Split out this function for use in testing\nexport const handleString = (input: string, separator: Separator): string[] => {\n const sepChar = separator === \"comma\" ? \",\" : /\\s+/;\n const trimmed = input.trim(); // Remove whitespace at the beginning and end\n if (trimmed === \"\") {\n return [];\n }\n\n return trimmed.split(sepChar).map((s: string) => s.trim());\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getArrayOfStrings,\n getArrayOfStringsOrNull,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\n */\nexport function getArchOs(): string {\n const envArch = process.env.RUNNER_ARCH;\n const envOs = process.env.RUNNER_OS;\n\n if (envArch && envOs) {\n return `${envArch}-${envOs}`;\n } else {\n actionsCore.error(\n `Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${envArch}-${envOs})`,\n );\n throw new Error(\"RUNNER_ARCH and/or RUNNER_OS is not defined\");\n }\n}\n\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\n */\nexport function getNixPlatform(archOs: string): string {\n const archOsMap: Map = new Map([\n [\"X64-macOS\", \"x86_64-darwin\"],\n [\"ARM64-macOS\", \"aarch64-darwin\"],\n [\"X64-Linux\", \"x86_64-linux\"],\n [\"ARM64-Linux\", \"aarch64-linux\"],\n ]);\n\n const mappedTo = archOsMap.get(archOs);\n if (mappedTo) {\n return mappedTo;\n } else {\n actionsCore.error(\n `ArchOs (${archOs}) doesn't map to a supported Nix platform.`,\n );\n throw new Error(\n `Cannot convert ArchOs (${archOs}) to a supported Nix platform.`,\n );\n }\n}\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * as actionsCore from \"@actions/core\";\n\nexport type SourceDef = {\n path?: string;\n url?: string;\n tag?: string;\n pr?: string;\n branch?: string;\n revision?: string;\n};\n\nexport function constructSourceParameters(legacyPrefix?: string): SourceDef {\n return {\n path: noisilyGetInput(\"path\", legacyPrefix),\n url: noisilyGetInput(\"url\", legacyPrefix),\n tag: noisilyGetInput(\"tag\", legacyPrefix),\n pr: noisilyGetInput(\"pr\", legacyPrefix),\n branch: noisilyGetInput(\"branch\", legacyPrefix),\n revision: noisilyGetInput(\"revision\", legacyPrefix),\n };\n}\n\nfunction noisilyGetInput(\n suffix: string,\n legacyPrefix: string | undefined,\n): string | undefined {\n const preferredInput = getStringOrUndefined(`source-${suffix}`);\n\n if (!legacyPrefix) {\n return preferredInput;\n }\n\n // Remaining is for handling cases where the legacy prefix\n // should be examined.\n const legacyInput = getStringOrUndefined(`${legacyPrefix}-${suffix}`);\n\n if (preferredInput && legacyInput) {\n actionsCore.warning(\n `The supported option source-${suffix} and the legacy option ${legacyPrefix}-${suffix} are both set. Preferring source-${suffix}. Please stop setting ${legacyPrefix}-${suffix}.`,\n );\n return preferredInput;\n } else if (legacyInput) {\n actionsCore.warning(\n `The legacy option ${legacyPrefix}-${suffix} is set. Please migrate to source-${suffix}.`,\n );\n return legacyInput;\n } else {\n return preferredInput;\n }\n}\n","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport { collectBacktraces } from \"./backtrace.js\";\nimport { CheckIn, Feature } from \"./check-in.js\";\nimport * as correlation from \"./correlation.js\";\nimport { IdsHost } from \"./ids-host.js\";\nimport { getBool, getStringOrNull } from \"./inputs.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { Got } from \"got\";\nimport { exec } from \"node:child_process\";\nimport { UUID, randomUUID } from \"node:crypto\";\nimport { PathLike, createWriteStream, readFileSync } from \"node:fs\";\nimport fs, { chmod, copyFile, mkdir } from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport { tmpdir } from \"node:os\";\nimport * as path from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { promisify } from \"node:util\";\nimport { gzip } from \"node:zlib\";\n\nconst EVENT_BACKTRACES = \"backtrace\";\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\nconst EVENT_ARTIFACT_CACHE_PERSIST = \"artifact_cache_persist\";\nconst EVENT_PREFLIGHT_REQUIRE_NIX_DENIED = \"preflight-require-nix-denied\";\n\nconst FACT_ARTIFACT_FETCHED_FROM_CACHE = \"artifact_fetched_from_cache\";\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\nconst FACT_OS = \"$os\";\nconst FACT_OS_VERSION = \"$os_version\";\nconst FACT_SOURCE_URL = \"source_url\";\nconst FACT_SOURCE_URL_ETAG = \"source_url_etag\";\n\nconst FACT_NIX_LOCATION = \"nix_location\";\nconst FACT_NIX_STORE_TRUST = \"nix_store_trusted\";\nconst FACT_NIX_STORE_VERSION = \"nix_store_version\";\nconst FACT_NIX_STORE_CHECK_METHOD = \"nix_store_check_method\";\nconst FACT_NIX_STORE_CHECK_ERROR = \"nix_store_check_error\";\n\nconst STATE_KEY_EXECUTION_PHASE = \"detsys_action_execution_phase\";\nconst STATE_KEY_NIX_NOT_FOUND = \"detsys_action_nix_not_found\";\nconst STATE_NOT_FOUND = \"not-found\";\nconst STATE_KEY_CROSS_PHASE_ID = \"detsys_cross_phase_id\";\nconst STATE_BACKTRACE_START_TIMESTAMP = \"detsys_backtrace_start_timestamp\";\n\nconst DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 30_000; // 30 seconds in milliseconds\nconst CHECK_IN_ENDPOINT_TIMEOUT_MS = 5_000; // 5 seconds in milliseconds\n\n/**\n * An enum for describing different \"fetch suffixes\" for i.d.s.\n *\n * - `nix-style` means that system names like `x86_64-linux` and `aarch64-darwin` are used\n * - `gh-env-style` means that names like `X64-Linux` and `ARM64-macOS` are used\n * - `universal` means that the suffix is the static `universal` (for non-system-specific things)\n */\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\n\n/**\n * GitHub Actions has two possible execution phases: `main` and `post`.\n */\nexport type ExecutionPhase = \"main\" | \"post\";\n\n/**\n * How to handle whether Nix is currently installed on the runner.\n *\n * - `fail` means that the workflow fails if Nix isn't installed\n * - `warn` means that a warning is logged if Nix isn't installed\n * - `ignore` means that Nix will not be checked\n */\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\n\n/**\n * Whether the Nix store on the runner is trusted.\n *\n * - `trusted` means yes\n * - `untrusted` means no\n * - `unknown` means that the status couldn't be determined\n *\n * This is determined via the output of `nix store info --json`.\n */\nexport type NixStoreTrust = \"trusted\" | \"untrusted\" | \"unknown\";\n\nexport type ActionOptions = {\n // Name of the project generally, and the name of the binary on disk.\n name: string;\n\n // Defaults to `name`, Corresponds to the ProjectHost entry on i.d.s.\n idsProjectName?: string;\n\n // Defaults to `action:`\n eventPrefix?: string;\n\n // The \"architecture\" URL component expected by I.D.S. for the ProjectHost.\n fetchStyle: FetchSuffixStyle;\n\n // IdsToolbox assumes the GitHub Action exposes source overrides, like branch/pr/etc. to be named `source-*`.\n // This prefix adds a fallback name, prefixed by `${legacySourcePrefix}-`.\n // Users who configure legacySourcePrefix will get warnings asking them to change to `source-*`.\n legacySourcePrefix?: string;\n\n // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\n\n // The URL suffix to send diagnostics events to.\n //\n // The final URL is constructed via IDS_HOST/idsProjectName/diagnosticsSuffix.\n //\n // Default: `diagnostics`.\n diagnosticsSuffix?: string;\n\n // Collect backtraces from segfaults and other failures from binaries that start with these names.\n //\n // Default: `[ \"nix\", \"determinate-nixd\", ActionOptions.name ]`.\n binaryNamePrefixes?: string[];\n};\n\n/**\n * A confident version of Options, where defaults have been resolved into final values.\n */\nexport type ConfidentActionOptions = {\n name: string;\n idsProjectName: string;\n eventPrefix: string;\n fetchStyle: FetchSuffixStyle;\n legacySourcePrefix?: string;\n requireNix: NixRequirementHandling;\n providedDiagnosticsUrl?: URL;\n binaryNamePrefixes: string[];\n};\n\n/**\n * An event to send to the diagnostic endpoint of i.d.s.\n */\nexport type DiagnosticEvent = {\n // Note: putting a Map in here won't serialize to json properly.\n // It'll just be {} on serialization.\n event_name: string;\n context: Record;\n correlation: correlation.AnonymizedCorrelationHashes;\n facts: Record;\n features: { [k: string]: string | boolean };\n timestamp: Date;\n uuid: UUID;\n};\n\nexport abstract class DetSysAction {\n nixStoreTrust: NixStoreTrust;\n strictMode: boolean;\n\n private actionOptions: ConfidentActionOptions;\n private exceptionAttachments: Map;\n private archOs: string;\n private executionPhase: ExecutionPhase;\n private nixSystem: string;\n private architectureFetchSuffix: string;\n private sourceParameters: SourceDef;\n private facts: Record;\n private events: DiagnosticEvent[];\n private identity: correlation.AnonymizedCorrelationHashes;\n private idsHost: IdsHost;\n private features: { [k: string]: Feature };\n private featureEventMetadata: { [k: string]: string | boolean };\n\n private determineExecutionPhase(): ExecutionPhase {\n const currentPhase = actionsCore.getState(STATE_KEY_EXECUTION_PHASE);\n if (currentPhase === \"\") {\n actionsCore.saveState(STATE_KEY_EXECUTION_PHASE, \"post\");\n return \"main\";\n } else {\n return \"post\";\n }\n }\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.idsHost = new IdsHost(\n this.actionOptions.idsProjectName,\n actionOptions.diagnosticsSuffix,\n // Note: we don't use actionsCore.getInput('diagnostic-endpoint') on purpose:\n // getInput silently converts absent data to an empty string.\n process.env[\"INPUT_DIAGNOSTIC-ENDPOINT\"],\n );\n this.exceptionAttachments = new Map();\n this.nixStoreTrust = \"unknown\";\n this.strictMode = getBool(\"_internal-strict-mode\");\n\n this.features = {};\n this.featureEventMetadata = {};\n this.events = [];\n\n this.getCrossPhaseId();\n this.collectBacktraceSetup();\n\n // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\n project: this.actionOptions.name,\n ids_project: this.actionOptions.idsProjectName,\n };\n\n const params = [\n [\"github_action_ref\", \"GITHUB_ACTION_REF\"],\n [\"github_action_repository\", \"GITHUB_ACTION_REPOSITORY\"],\n [\"github_event_name\", \"GITHUB_EVENT_NAME\"],\n [\"$os\", \"RUNNER_OS\"],\n [\"arch\", \"RUNNER_ARCH\"],\n ];\n for (const [target, env] of params) {\n const value = process.env[env];\n if (value) {\n this.facts[target] = value;\n }\n }\n\n this.identity = correlation.identify(this.actionOptions.name);\n this.archOs = platform.getArchOs();\n this.nixSystem = platform.getNixPlatform(this.archOs);\n\n this.facts.arch_os = this.archOs;\n this.facts.nix_system = this.nixSystem;\n\n {\n ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(FACT_OS, details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(FACT_OS_VERSION, details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e: unknown) => {\n actionsCore.debug(\n `Failure getting platform details: ${stringifyError(e)}`,\n );\n });\n }\n\n this.executionPhase = this.determineExecutionPhase();\n this.facts.execution_phase = this.executionPhase;\n\n if (this.actionOptions.fetchStyle === \"gh-env-style\") {\n this.architectureFetchSuffix = this.archOs;\n } else if (this.actionOptions.fetchStyle === \"nix-style\") {\n this.architectureFetchSuffix = this.nixSystem;\n } else if (this.actionOptions.fetchStyle === \"universal\") {\n this.architectureFetchSuffix = \"universal\";\n } else {\n throw new Error(\n `fetchStyle ${this.actionOptions.fetchStyle} is not a valid style`,\n );\n }\n\n this.sourceParameters = constructSourceParameters(\n this.actionOptions.legacySourcePrefix,\n );\n\n this.recordEvent(`begin_${this.executionPhase}`);\n }\n\n /**\n * Attach a file to the diagnostics data in error conditions.\n *\n * The file at `location` doesn't need to exist when stapleFile is called.\n *\n * If the file doesn't exist or is unreadable when trying to staple the attachments, the JS error will be stored in a context value at `staple_failure_{name}`.\n * If the file is readable, the file's contents will be stored in a context value at `staple_value_{name}`.\n */\n stapleFile(name: string, location: string): void {\n this.exceptionAttachments.set(name, location);\n }\n\n /**\n * The main execution phase.\n */\n abstract main(): Promise;\n\n /**\n * The post execution phase.\n */\n abstract post(): Promise;\n\n /**\n * Execute the Action as defined.\n */\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n getTemporaryName(): string {\n const tmpDir = process.env[\"RUNNER_TEMP\"] || tmpdir();\n return path.join(tmpDir, `${this.actionOptions.name}-${randomUUID()}`);\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n async getDiagnosticsUrl(): Promise {\n return await this.idsHost.getDiagnosticsUrl();\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n // This ID will be saved in the action's state, to be persisted across phase steps\n getCrossPhaseId(): string {\n let crossPhaseId = actionsCore.getState(STATE_KEY_CROSS_PHASE_ID);\n\n if (crossPhaseId === \"\") {\n crossPhaseId = randomUUID();\n actionsCore.saveState(STATE_KEY_CROSS_PHASE_ID, crossPhaseId);\n }\n\n return crossPhaseId;\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\n }\n\n recordEvent(eventName: string, context: Record = {}): void {\n const prefixedName =\n eventName === \"$feature_flag_called\"\n ? eventName\n : `${this.actionOptions.eventPrefix}${eventName}`;\n this.events.push({\n event_name: prefixedName,\n context,\n correlation: this.identity,\n facts: this.facts,\n features: this.featureEventMetadata,\n timestamp: new Date(),\n uuid: randomUUID(),\n });\n }\n\n /**\n * Unpacks the closure returned by `fetchArtifact()`, imports the\n * contents into the Nix store, and returns the path of the executable at\n * `/nix/store/STORE_PATH/bin/${bin}`.\n */\n async unpackClosure(bin: string): Promise {\n const artifact = await this.fetchArtifact();\n const { stdout } = await promisify(exec)(\n `cat \"${artifact}\" | xz -d | nix-store --import`,\n );\n const paths = stdout.split(os.EOL);\n const lastPath = paths.at(-2);\n return `${lastPath}/bin/${bin}`;\n }\n\n /**\n * Fetches the executable at the URL determined by the `source-*` inputs and\n * other facts, `chmod`s it, and returns the path to the executable on disk.\n */\n async fetchExecutable(): Promise {\n const binaryPath = await this.fetchArtifact();\n await chmod(binaryPath, fs.constants.S_IXUSR | fs.constants.S_IXGRP);\n return binaryPath;\n }\n\n private get isMain(): boolean {\n return this.executionPhase === \"main\";\n }\n\n private get isPost(): boolean {\n return this.executionPhase === \"post\";\n }\n\n private async executeAsync(): Promise {\n try {\n await this.checkIn();\n\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(EVENT_PREFLIGHT_REQUIRE_NIX_DENIED);\n return;\n } else {\n await this.preflightNixStoreInfo();\n this.addFact(FACT_NIX_STORE_TRUST, this.nixStoreTrust);\n }\n\n if (this.isMain) {\n await this.main();\n } else if (this.isPost) {\n await this.post();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (e: unknown) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable = stringifyError(e);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.isPost) {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n const doGzip = promisify(gzip);\n\n const exceptionContext: Map = new Map();\n for (const [attachmentLabel, filePath] of this.exceptionAttachments) {\n try {\n const logText = readFileSync(filePath);\n const buf = await doGzip(logText);\n exceptionContext.set(\n `staple_value_${attachmentLabel}`,\n buf.toString(\"base64\"),\n );\n } catch (innerError: unknown) {\n exceptionContext.set(\n `staple_failure_${attachmentLabel}`,\n stringifyError(innerError),\n );\n }\n }\n\n this.recordEvent(EVENT_EXCEPTION, Object.fromEntries(exceptionContext));\n } finally {\n if (this.isPost) {\n await this.collectBacktraces();\n }\n\n await this.complete();\n }\n }\n\n async getClient(): Promise {\n return await this.idsHost.getGot((prevUrl: URL, nextUrl: URL) => {\n this.recordEvent(\"ids-failover\", {\n previousUrl: prevUrl.toString(),\n nextUrl: nextUrl.toString(),\n });\n });\n }\n\n private async checkIn(): Promise {\n const checkin = await this.requestCheckIn();\n if (checkin === undefined) {\n return;\n }\n\n this.features = checkin.options;\n for (const [key, feature] of Object.entries(this.features)) {\n this.featureEventMetadata[key] = feature.variant;\n }\n\n const impactSymbol: Map = new Map([\n [\"none\", \"⚪\"],\n [\"maintenance\", \"🛠️\"],\n [\"minor\", \"🟡\"],\n [\"major\", \"🟠\"],\n [\"critical\", \"🔴\"],\n ]);\n const defaultImpactSymbol = \"🔵\";\n\n if (checkin.status !== null) {\n const summaries: string[] = [];\n\n for (const incident of checkin.status.incidents) {\n summaries.push(\n `${impactSymbol.get(incident.impact) || defaultImpactSymbol} ${incident.status.replace(\"_\", \" \")}: ${incident.name} (${incident.shortlink})`,\n );\n }\n\n for (const maintenance of checkin.status.scheduled_maintenances) {\n summaries.push(\n `${impactSymbol.get(maintenance.impact) || defaultImpactSymbol} ${maintenance.status.replace(\"_\", \" \")}: ${maintenance.name} (${maintenance.shortlink})`,\n );\n }\n\n if (summaries.length > 0) {\n actionsCore.info(\n // Bright red, Bold, Underline\n `${\"\\u001b[0;31m\"}${\"\\u001b[1m\"}${\"\\u001b[4m\"}${checkin.status.page.name} Status`,\n );\n for (const notice of summaries) {\n actionsCore.info(notice);\n }\n actionsCore.info(`See: ${checkin.status.page.url}`);\n actionsCore.info(``);\n }\n }\n }\n\n getFeature(name: string): Feature | undefined {\n if (!this.features.hasOwnProperty(name)) {\n return undefined;\n }\n\n const result = this.features[name];\n if (result === undefined) {\n return undefined;\n }\n\n this.recordEvent(\"$feature_flag_called\", {\n $feature_flag: name,\n $feature_flag_response: result.variant,\n });\n\n return result;\n }\n\n /**\n * Check in to install.determinate.systems, to accomplish three things:\n *\n * 1. Preflight the server selected from IdsHost, to increase the chances of success.\n * 2. Fetch any incidents and maintenance events to let users know in case things are weird.\n * 3. Get feature flag data so we can gently roll out new features.\n */\n private async requestCheckIn(): Promise {\n for (\n let attemptsRemaining = 5;\n attemptsRemaining > 0;\n attemptsRemaining--\n ) {\n const checkInUrl = await this.getCheckInUrl();\n if (checkInUrl === undefined) {\n return undefined;\n }\n\n try {\n actionsCore.debug(`Preflighting via ${checkInUrl}`);\n\n checkInUrl.searchParams.set(\"ci\", \"github\");\n checkInUrl.searchParams.set(\n \"correlation\",\n JSON.stringify(this.identity),\n );\n\n return (await this.getClient())\n .get(checkInUrl, {\n timeout: {\n request: CHECK_IN_ENDPOINT_TIMEOUT_MS,\n },\n })\n .json();\n } catch (e: unknown) {\n actionsCore.debug(`Error checking in: ${stringifyError(e)}`);\n this.idsHost.markCurrentHostBroken();\n }\n }\n\n return undefined;\n }\n\n /**\n * Fetch an artifact, such as a tarball, from the location determined by the\n * `source-*` inputs. If `source-binary` is specified, this will return a path\n * to a binary on disk; otherwise, the artifact will be downloaded from the\n * URL determined by the other `source-*` inputs (`source-url`, `source-pr`,\n * etc.).\n */\n private async fetchArtifact(): Promise {\n const sourceBinary = getStringOrNull(\"source-binary\");\n\n // If source-binary is set, use that. Otherwise fall back to the source-* parameters.\n if (sourceBinary !== null && sourceBinary !== \"\") {\n actionsCore.debug(`Using the provided source binary at ${sourceBinary}`);\n return sourceBinary;\n }\n\n actionsCore.startGroup(\n `Downloading ${this.actionOptions.name} for ${this.architectureFetchSuffix}`,\n );\n\n try {\n actionsCore.info(`Fetching from ${await this.getSourceUrl()}`);\n\n const correlatedUrl = await this.getSourceUrl();\n correlatedUrl.searchParams.set(\"ci\", \"github\");\n correlatedUrl.searchParams.set(\n \"correlation\",\n JSON.stringify(this.identity),\n );\n\n const versionCheckup = await (await this.getClient()).head(correlatedUrl);\n if (versionCheckup.headers.etag) {\n const v = versionCheckup.headers.etag;\n this.addFact(FACT_SOURCE_URL_ETAG, v);\n\n actionsCore.debug(\n `Checking the tool cache for ${await this.getSourceUrl()} at ${v}`,\n );\n const cached = await this.getCachedVersion(v);\n if (cached) {\n this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = true;\n actionsCore.debug(`Tool cache hit.`);\n return cached;\n }\n }\n\n this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = false;\n\n actionsCore.debug(\n `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`,\n );\n\n const destFile = this.getTemporaryName();\n const fetchStream = (await this.getClient()).stream(versionCheckup.url);\n\n await pipeline(\n fetchStream,\n createWriteStream(destFile, {\n encoding: \"binary\",\n mode: 0o755,\n }),\n );\n\n if (fetchStream.response?.headers.etag) {\n const v = fetchStream.response.headers.etag;\n\n try {\n await this.saveCachedVersion(v, destFile);\n } catch (e: unknown) {\n actionsCore.debug(`Error caching the artifact: ${stringifyError(e)}`);\n }\n }\n\n return destFile;\n } finally {\n actionsCore.endGroup();\n }\n }\n\n /**\n * A helper function for failing on error only if strict mode is enabled.\n * This is intended only for CI environments testing Actions themselves.\n */\n failOnError(msg: string): void {\n if (this.strictMode) {\n actionsCore.setFailed(`strict mode failure: ${msg}`);\n }\n }\n\n private async complete(): Promise {\n this.recordEvent(`complete_${this.executionPhase}`);\n await this.submitEvents();\n }\n\n private async getCheckInUrl(): Promise {\n const checkInUrl = await this.idsHost.getDynamicRootUrl();\n\n if (checkInUrl === undefined) {\n return undefined;\n }\n\n checkInUrl.pathname += \"check-in\";\n return checkInUrl;\n }\n\n private async getSourceUrl(): Promise {\n const p = this.sourceParameters;\n\n if (p.url) {\n this.addFact(FACT_SOURCE_URL, p.url);\n return new URL(p.url);\n }\n\n const fetchUrl = await this.idsHost.getRootUrl();\n fetchUrl.pathname += this.actionOptions.idsProjectName;\n\n if (p.tag) {\n fetchUrl.pathname += `/tag/${p.tag}`;\n } else if (p.pr) {\n fetchUrl.pathname += `/pr/${p.pr}`;\n } else if (p.branch) {\n fetchUrl.pathname += `/branch/${p.branch}`;\n } else if (p.revision) {\n fetchUrl.pathname += `/rev/${p.revision}`;\n } else {\n fetchUrl.pathname += `/stable`;\n }\n\n fetchUrl.pathname += `/${this.architectureFetchSuffix}`;\n\n this.addFact(FACT_SOURCE_URL, fetchUrl.toString());\n\n return fetchUrl;\n }\n\n private cacheKey(version: string): string {\n const cleanedVersion = version.replace(/[^a-zA-Z0-9-+.]/g, \"\");\n return `determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${cleanedVersion}`;\n }\n\n private async getCachedVersion(version: string): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n if (\n await actionsCache.restoreCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n [],\n undefined,\n true,\n )\n ) {\n this.recordEvent(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_ARTIFACT_CACHE_MISS);\n return undefined;\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private async saveCachedVersion(\n version: string,\n toolPath: string,\n ): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n await copyFile(toolPath, `${tempDir}/${this.actionOptions.name}`);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n await actionsCache.saveCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n undefined,\n true,\n );\n this.recordEvent(EVENT_ARTIFACT_CACHE_PERSIST);\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private collectBacktraceSetup(): void {\n if (process.env.DETSYS_BACKTRACE_COLLECTOR === \"\") {\n actionsCore.exportVariable(\n \"DETSYS_BACKTRACE_COLLECTOR\",\n this.getCrossPhaseId(),\n );\n\n actionsCore.saveState(STATE_BACKTRACE_START_TIMESTAMP, Date.now());\n }\n }\n\n private async collectBacktraces(): Promise {\n try {\n if (process.env.DETSYS_BACKTRACE_COLLECTOR !== this.getCrossPhaseId()) {\n return;\n }\n\n const backtraces = await collectBacktraces(\n this.actionOptions.binaryNamePrefixes,\n parseInt(actionsCore.getState(STATE_BACKTRACE_START_TIMESTAMP)),\n );\n actionsCore.debug(`Backtraces identified: ${backtraces.size}`);\n if (backtraces.size > 0) {\n this.recordEvent(EVENT_BACKTRACES, Object.fromEntries(backtraces));\n }\n } catch (innerError: unknown) {\n actionsCore.debug(\n `Error collecting backtraces: ${stringifyError(innerError)}`,\n );\n }\n }\n\n private async preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n break;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(FACT_NIX_LOCATION, nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(STATE_KEY_NIX_NOT_FOUND);\n if (currentNotFoundState === STATE_NOT_FOUND) {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(STATE_KEY_NIX_NOT_FOUND, STATE_NOT_FOUND);\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n [\n \"This action can only be used when Nix is installed.\",\n \"Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n ].join(\" \"),\n );\n break;\n case \"warn\":\n actionsCore.warning(\n [\n \"This action is in no-op mode because Nix is not installed.\",\n \"Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n ].join(\" \"),\n );\n break;\n }\n\n return false;\n }\n\n private async preflightNixStoreInfo(): Promise {\n let output = \"\";\n\n const options: actionsExec.ExecOptions = {};\n options.silent = true;\n options.listeners = {\n stdout: (data) => {\n output += data.toString();\n },\n };\n\n try {\n output = \"\";\n await actionsExec.exec(\"nix\", [\"store\", \"info\", \"--json\"], options);\n this.addFact(FACT_NIX_STORE_CHECK_METHOD, \"info\");\n } catch {\n try {\n // reset output\n output = \"\";\n await actionsExec.exec(\"nix\", [\"store\", \"ping\", \"--json\"], options);\n this.addFact(FACT_NIX_STORE_CHECK_METHOD, \"ping\");\n } catch {\n this.addFact(FACT_NIX_STORE_CHECK_METHOD, \"none\");\n return;\n }\n }\n\n try {\n const parsed = JSON.parse(output);\n if (parsed.trusted === 1) {\n this.nixStoreTrust = \"trusted\";\n } else if (parsed.trusted === 0) {\n this.nixStoreTrust = \"untrusted\";\n } else if (parsed.trusted !== undefined) {\n this.addFact(\n FACT_NIX_STORE_CHECK_ERROR,\n `Mysterious trusted value: ${JSON.stringify(parsed.trusted)}`,\n );\n }\n\n this.addFact(FACT_NIX_STORE_VERSION, JSON.stringify(parsed.version));\n } catch (e: unknown) {\n this.addFact(FACT_NIX_STORE_CHECK_ERROR, stringifyError(e));\n }\n }\n\n private async submitEvents(): Promise {\n const diagnosticsUrl = await this.idsHost.getDiagnosticsUrl();\n if (diagnosticsUrl === undefined) {\n actionsCore.debug(\n \"Diagnostics are disabled. Not sending the following events:\",\n );\n actionsCore.debug(JSON.stringify(this.events, undefined, 2));\n return;\n }\n\n const batch = {\n type: \"eventlog\",\n sent_at: new Date(),\n events: this.events,\n };\n\n try {\n await (\n await this.getClient()\n ).post(diagnosticsUrl, {\n json: batch,\n timeout: {\n request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS,\n },\n });\n } catch (err: unknown) {\n actionsCore.debug(\n `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError(err)}`,\n );\n }\n this.events = [];\n }\n}\n\nfunction stringifyError(error: unknown): string {\n return error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n}\n\nfunction makeOptionsConfident(\n actionOptions: ActionOptions,\n): ConfidentActionOptions {\n const idsProjectName = actionOptions.idsProjectName ?? actionOptions.name;\n\n const finalOpts: ConfidentActionOptions = {\n name: actionOptions.name,\n idsProjectName,\n eventPrefix: actionOptions.eventPrefix || \"action:\",\n fetchStyle: actionOptions.fetchStyle,\n legacySourcePrefix: actionOptions.legacySourcePrefix,\n requireNix: actionOptions.requireNix,\n binaryNamePrefixes: actionOptions.binaryNamePrefixes ?? [\n \"nix\",\n \"determinate-nixd\",\n actionOptions.name,\n ],\n };\n\n actionsCore.debug(\"idslib options:\");\n actionsCore.debug(JSON.stringify(finalOpts, undefined, 2));\n\n return finalOpts;\n}\n\n// Public exports from other files\nexport {\n CheckIn,\n Feature,\n Incident,\n Maintenance,\n Page,\n StatusSummary,\n} from \"./check-in.js\";\nexport { AnonymizedCorrelationHashes } from \"./correlation.js\";\nexport { stringifyError } from \"./errors.js\";\nexport { IdsHost } from \"./ids-host.js\";\nexport { SourceDef } from \"./sourcedef.js\";\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACYb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AACT;AAQO,SAAS,YAAY,aAA8C;AACxE,QAAM,UAAU,EAAE,GAAG,iCAAiC,GAAG,YAAY;AAErE,QAAM,0BAAoC;AAAA,IACxC,QAAQ;AAAA,EACV;AAEA,MAAO,QAAK,MAAM,SAAS;AACzB,QAAI,QAAQ,SAAS,QAAQ;AAC3B,aAAO,UAAU;AAAA,IACnB,OAAO;AACL,aAAO,QAAQ,QAAQ,UAAU,CAAC;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,QAAQ,SAAS,QAAQ;AAC3B,WAAO,sBAAsB,yBAAyB,OAAO;AAAA,EAC/D,OAAO;AACL,WAAO,QAAQ;AAAA,MACb,uBAAuB,yBAAyB,OAAO;AAAA,IACzD;AAAA,EACF;AACF;AASA,SAAS,eAAe,YAAoB,cAA8B;AACxE,QAAM,QAAkB,aAAa,MAAM,IAAI;AAE/C,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAW,KAAK,MAAM,GAAG;AAE/B,QAAI,SAAS,WAAW,GAAG;AACzB,eAAS,CAAC,IAAI,SAAS,CAAC,EAAE,QAAQ,YAAY,EAAE;AAEhD,aAAO,eAAe,YAAY,SAAS,CAAC,EAAE,YAAY,GAAG;AAAA,QAC3D,OAAO,SAAS,CAAC;AAAA,QACjB,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,cAAc;AAAA,MAChB,CAA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BAAM,KAAK,UAAU,KAAK,QAAQ,QAAW,CAAC,CAAC;AAC3D;AAAA,IACF;AAEA,UAAM,QAAQ;AAAA,MACZ,MAAM;AAAA,MACN,SAAS,oBAAI,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IACf;AAEA,QAAI;AACF,aACE,MAAM,KAAK,UAAU,GACrB,KAAK,gBAAgB;AAAA,QACrB,MAAM;AAAA,QACN,SAAS;AAAA,UACP,SAAS;AAAA,QACX;AAAA,MACF,CAAC;AAAA,IACH,SAAS,KAAc;AACrB,MAAY;AAAA,QACV,yCAAyC,cAAc,KAAKA,gBAAe,GAAG,CAAC;AAAA,MACjF;AAAA,IACF;AACA,SAAK,SAAS,CAAC;AAAA,EACjB;AACF;AAEA,SAASA,gBAAeC,QAAwB;AAC9C,SAAOA,kBAAiB,SAAS,OAAOA,UAAS,WAC7CA,OAAM,SAAS,IACf,KAAK,UAAUA,MAAK;AAC1B;AAEA,SAAS,qBACP,eACwB;AACxB,QAAM,iBAAiB,cAAc,kBAAkB,cAAc;AAErE,QAAM,YAAoC;AAAA,IACxC,MAAM,cAAc;AAAA,IACpB;AAAA,IACA,aAAa,cAAc,eAAe;AAAA,IAC1C,YAAY,cAAc;AAAA,IAC1B,oBAAoB,cAAc;AAAA,IAClC,YAAY,cAAc;AAAA,IAC1B,oBAAoB,cAAc,sBAAsB;AAAA,MACtD;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IAChB;AAAA,EACF;AAEA,EAAY,mBAAM,iBAAiB;AACnC,EAAY,mBAAM,KAAK,UAAU,WAAW,QAAW,CAAC,CAAC;AAEzD,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","exec","readFile","promisify","actionsCore","actionsCore","error","actionsCore","actionsCore","actionsCore","actionsCore","exec","readFileSync","fs","os","promisify","gzip","stringifyError","error","promisify","exec","fs","gzip","readFileSync","version"]} \ No newline at end of file +{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/errors.ts","../src/backtrace.ts","../src/correlation.ts","../src/ids-host.ts","../src/inputs.ts","../src/platform.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc\",\n \"test\": \"vitest --watch false\",\n \"test-dev\": \"vitest\",\n \"all\": \"rm -rf dist && pnpm run format && pnpm run lint && pnpm run build\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/DeterminateSystems/detsys-ts.git\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/DeterminateSystems/detsys-ts/issues\"\n },\n \"homepage\": \"https://github.com/DeterminateSystems/detsys-ts#readme\",\n \"dependencies\": {\n \"@actions/cache\": \"^3.2.4\",\n \"@actions/core\": \"^1.10.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.4.2\",\n \"type-fest\": \"^4.23.0\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.14.13\",\n \"@typescript-eslint/eslint-plugin\": \"^7.18.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.2.1\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.2.3\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.5.4\",\n \"vitest\": \"^1.6.0\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle. We've modified the original logic to improve things like typing\n// and fixing ESLint issues. Originally drawn from:\n// https://github.com/samuelcarreira/linux-release-info/blob/84a91aa5442b47900da03020c590507545d3dc74/src/index.ts\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osReleaseFileList(\n options.customFile,\n );\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osReleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n\n/* Helper functions */\n\nasync function readAsyncOsReleaseFile(\n fileList: string[],\n options: LinuxReleaseInfoOptions,\n): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (options.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n\nfunction readSyncOsreleaseFile(\n releaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as actionsCore from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n actionsCore.debug(`Identified release info: ${JSON.stringify(data)}`);\n } catch (e) {\n actionsCore.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","/**\n * Coerce a value of type `unknown` into a string.\n */\nexport function stringifyError(e: unknown): string {\n if (e instanceof Error) {\n return e.message;\n } else if (typeof e === \"string\") {\n return e;\n } else {\n return JSON.stringify(e);\n }\n}\n","/**\n * @packageDocumentation\n * Collects backtraces for executables for diagnostics\n */\nimport { isLinux, isMacOS } from \"./actions-core-platform.js\";\nimport { stringifyError } from \"./errors.js\";\nimport * as actionsCore from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport { readFile, readdir, stat } from \"node:fs/promises\";\nimport { promisify } from \"node:util\";\nimport { gzip } from \"node:zlib\";\n\nexport async function collectBacktraces(\n prefixes: string[],\n startTimestampMs: number,\n): Promise> {\n if (isMacOS) {\n return await collectBacktracesMacOS(prefixes, startTimestampMs);\n }\n if (isLinux) {\n return await collectBacktracesSystemd(prefixes, startTimestampMs);\n }\n\n return new Map();\n}\n\nexport async function collectBacktracesMacOS(\n prefixes: string[],\n startTimestampMs: number,\n): Promise> {\n const backtraces: Map = new Map();\n\n try {\n const { stdout: logJson } = await exec.getExecOutput(\n \"log\",\n [\n \"show\",\n \"--style\",\n \"json\",\n \"--last\",\n // Note we collect the last 1m only, because it should only take a few seconds to write the crash log.\n // Therefore, any crashes before this 1m should be long done by now.\n \"1m\",\n \"--no-info\",\n \"--predicate\",\n \"sender = 'ReportCrash'\",\n ],\n {\n silent: true,\n },\n );\n\n const sussyArray: unknown = JSON.parse(logJson);\n if (!Array.isArray(sussyArray)) {\n throw new Error(`Log json isn't an array: ${logJson}`);\n }\n\n if (sussyArray.length > 0) {\n actionsCore.info(`Collecting crash data...`);\n const delay = async (ms: number): Promise =>\n new Promise((resolve) => setTimeout(resolve, ms));\n await delay(5000);\n }\n } catch (e: unknown) {\n actionsCore.debug(\n \"Failed to check logs for in-progress crash dumps; now proceeding with the assumption that all crash dumps completed.\",\n );\n }\n\n const dirs = [\n [\"system\", \"/Library/Logs/DiagnosticReports/\"],\n [\"user\", `${process.env[\"HOME\"]}/Library/Logs/DiagnosticReports/`],\n ];\n\n for (const [source, dir] of dirs) {\n const fileNames = (await readdir(dir))\n .filter((fileName) => {\n return prefixes.some((prefix) => fileName.startsWith(prefix));\n })\n .filter((fileName) => {\n // macOS creates .diag files periodically, which are called \"microstackshots\".\n // We don't necessarily want those, and they're definitely not crashes.\n // See: https://patents.google.com/patent/US20140237219A1/en\n return !fileName.endsWith(\".diag\");\n });\n\n const doGzip = promisify(gzip);\n for (const fileName of fileNames) {\n try {\n if ((await stat(`${dir}/${fileName}`)).ctimeMs >= startTimestampMs) {\n const logText = await readFile(`${dir}/${fileName}`);\n const buf = await doGzip(logText);\n backtraces.set(\n `backtrace_value_${source}_${fileName}`,\n buf.toString(\"base64\"),\n );\n }\n } catch (innerError: unknown) {\n backtraces.set(\n `backtrace_failure_${source}_${fileName}`,\n stringifyError(innerError),\n );\n }\n }\n }\n\n return backtraces;\n}\n\ntype SystemdCoreDumpInfo = {\n exe: string;\n pid: number;\n};\n\nexport async function collectBacktracesSystemd(\n prefixes: string[],\n startTimestampMs: number,\n): Promise> {\n const sinceSeconds = Math.ceil((Date.now() - startTimestampMs) / 1000);\n const backtraces: Map = new Map();\n\n const coredumps: SystemdCoreDumpInfo[] = [];\n\n try {\n const { stdout: coredumpjson } = await exec.getExecOutput(\n \"coredumpctl\",\n [\"--json=pretty\", \"list\", \"--since\", `${sinceSeconds} seconds ago`],\n {\n silent: true,\n },\n );\n\n const sussyArray: unknown = JSON.parse(coredumpjson);\n if (!Array.isArray(sussyArray)) {\n throw new Error(`Coredump isn't an array: ${coredumpjson}`);\n }\n\n for (const sussyObject of sussyArray) {\n const keys = Object.keys(sussyObject);\n\n if (keys.includes(\"exe\") && keys.includes(\"pid\")) {\n if (\n typeof sussyObject.exe == \"string\" &&\n typeof sussyObject.pid == \"number\"\n ) {\n const execParts = sussyObject.exe.split(\"/\");\n const binaryName = execParts[execParts.length - 1];\n\n if (prefixes.some((prefix) => binaryName.startsWith(prefix))) {\n coredumps.push({\n exe: sussyObject.exe,\n pid: sussyObject.pid,\n });\n }\n } else {\n actionsCore.debug(\n `Mysterious coredump entry missing exe string and/or pid number: ${JSON.stringify(sussyObject)}`,\n );\n }\n } else {\n actionsCore.debug(\n `Mysterious coredump entry missing exe value and/or pid value: ${JSON.stringify(sussyObject)}`,\n );\n }\n }\n } catch (innerError: unknown) {\n actionsCore.debug(\n `Cannot collect backtraces: ${stringifyError(innerError)}`,\n );\n\n return backtraces;\n }\n\n const doGzip = promisify(gzip);\n for (const coredump of coredumps) {\n try {\n const { stdout: logText } = await exec.getExecOutput(\n \"coredumpctl\",\n [\"info\", `${coredump.pid}`],\n {\n silent: true,\n },\n );\n\n const buf = await doGzip(logText);\n backtraces.set(`backtrace_value_${coredump.pid}`, buf.toString(\"base64\"));\n } catch (innerError: unknown) {\n backtraces.set(\n `backtrace_failure_${coredump.pid}`,\n stringifyError(innerError),\n );\n }\n }\n\n return backtraces;\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n/* eslint-disable camelcase */\n/**\n * JSON sent to server.\n */\nexport type AnonymizedCorrelationHashes = {\n correlation_source: string;\n repository?: string;\n run?: string;\n run_differentiator?: string;\n workflow?: string;\n groups: Record;\n};\n\nexport function identify(projectName: string): AnonymizedCorrelationHashes {\n const ident = {\n correlation_source: \"github-actions\",\n\n repository: hashEnvironmentVariables(\"GHR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n ]),\n workflow: hashEnvironmentVariables(\"GHW\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n ]),\n job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\n ]),\n groups: {\n ci: \"github-actions\",\n project: projectName,\n github_organization: hashEnvironmentVariables(\"GHO\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n ]),\n },\n };\n\n actionsCore.debug(\"Correlation data:\");\n actionsCore.debug(JSON.stringify(ident, null, 2));\n\n return ident;\n}\n\nfunction hashEnvironmentVariables(\n prefix: string,\n variables: string[],\n): undefined | string {\n const hash = createHash(\"sha256\");\n\n for (const varName of variables) {\n let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Identifies and discovers backend servers for install.determinate.systems\n */\nimport { stringifyError } from \"./errors.js\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport type { SrvRecord } from \"node:dns\";\nimport { resolveSrv } from \"node:dns/promises\";\n\nconst DEFAULT_LOOKUP = \"_detsys_ids._tcp.install.determinate.systems.\";\nconst ALLOWED_SUFFIXES = [\n \".install.determinate.systems\",\n \".install.detsys.dev\",\n];\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst LOOKUP = process.env[\"IDS_LOOKUP\"] ?? DEFAULT_LOOKUP;\n\nconst DEFAULT_TIMEOUT = 10_000; // 10 seconds in ms\n\n/**\n * Host information for install.determinate.systems.\n */\nexport class IdsHost {\n private idsProjectName: string;\n private diagnosticsSuffix?: string;\n private runtimeDiagnosticsUrl?: string;\n private prioritizedURLs?: URL[];\n private client?: Got;\n\n constructor(\n idsProjectName: string,\n diagnosticsSuffix: string | undefined,\n runtimeDiagnosticsUrl: string | undefined,\n ) {\n this.idsProjectName = idsProjectName;\n this.diagnosticsSuffix = diagnosticsSuffix;\n this.runtimeDiagnosticsUrl = runtimeDiagnosticsUrl;\n this.client = undefined;\n }\n\n async getGot(\n recordFailoverCallback?: (\n incitingError: unknown,\n prevUrl: URL,\n nextUrl: URL,\n ) => void,\n ): Promise {\n if (this.client === undefined) {\n this.client = got.extend({\n timeout: {\n request: DEFAULT_TIMEOUT,\n },\n\n retry: {\n limit: Math.max((await this.getUrlsByPreference()).length, 3),\n methods: [\"GET\", \"HEAD\"],\n },\n\n hooks: {\n beforeRetry: [\n async (error, retryCount) => {\n const prevUrl = await this.getRootUrl();\n this.markCurrentHostBroken();\n const nextUrl = await this.getRootUrl();\n\n if (recordFailoverCallback !== undefined) {\n recordFailoverCallback(error, prevUrl, nextUrl);\n }\n\n actionsCore.info(\n `Retrying after error ${error.code}, retry #: ${retryCount}`,\n );\n },\n ],\n\n beforeRequest: [\n async (options) => {\n // The getter always returns a URL, even though the setter accepts a string\n const currentUrl: URL = options.url as URL;\n\n if (this.isUrlSubjectToDynamicUrls(currentUrl)) {\n const newUrl: URL = new URL(currentUrl);\n\n const url: URL = await this.getRootUrl();\n newUrl.host = url.host;\n\n options.url = newUrl;\n actionsCore.debug(`Transmuted ${currentUrl} into ${newUrl}`);\n } else {\n actionsCore.debug(`No transmutations on ${currentUrl}`);\n }\n },\n ],\n },\n });\n }\n\n return this.client;\n }\n\n markCurrentHostBroken(): void {\n this.prioritizedURLs?.shift();\n }\n\n setPrioritizedUrls(urls: URL[]): void {\n this.prioritizedURLs = urls;\n }\n\n isUrlSubjectToDynamicUrls(url: URL): boolean {\n if (url.origin === DEFAULT_IDS_HOST) {\n return true;\n }\n\n for (const suffix of ALLOWED_SUFFIXES) {\n if (url.host.endsWith(suffix)) {\n return true;\n }\n }\n\n return false;\n }\n\n async getDynamicRootUrl(): Promise {\n const idsHost = process.env[\"IDS_HOST\"];\n if (idsHost !== undefined) {\n try {\n return new URL(idsHost);\n } catch (err: unknown) {\n actionsCore.error(\n `IDS_HOST environment variable is not a valid URL. Ignoring. ${stringifyError(err)}`,\n );\n }\n }\n\n let url: URL | undefined = undefined;\n try {\n const urls = await this.getUrlsByPreference();\n url = urls[0];\n } catch (err: unknown) {\n actionsCore.error(\n `Error collecting IDS URLs by preference: ${stringifyError(err)}`,\n );\n }\n\n if (url === undefined) {\n return undefined;\n } else {\n // This is a load-bearing `new URL(url)` so that callers can't mutate\n // getRootUrl's return value.\n return new URL(url);\n }\n }\n\n async getRootUrl(): Promise {\n const url = await this.getDynamicRootUrl();\n\n if (url === undefined) {\n return new URL(DEFAULT_IDS_HOST);\n }\n\n return url;\n }\n\n async getDiagnosticsUrl(): Promise {\n if (this.runtimeDiagnosticsUrl === \"\") {\n // User specifically set the diagnostics URL to an empty string\n // so disable diagnostics\n return undefined;\n }\n\n if (\n this.runtimeDiagnosticsUrl !== \"-\" &&\n this.runtimeDiagnosticsUrl !== undefined\n ) {\n try {\n // Caller specified a specific diagnostics URL\n return new URL(this.runtimeDiagnosticsUrl);\n } catch (err: unknown) {\n actionsCore.info(\n `User-provided diagnostic endpoint ignored: not a valid URL: ${stringifyError(err)}`,\n );\n }\n }\n\n try {\n const diagnosticUrl = await this.getRootUrl();\n diagnosticUrl.pathname += this.idsProjectName;\n diagnosticUrl.pathname += \"/\";\n diagnosticUrl.pathname += this.diagnosticsSuffix || \"diagnostics\";\n return diagnosticUrl;\n } catch (err: unknown) {\n actionsCore.info(\n `Generated diagnostic endpoint ignored, and diagnostics are disabled: not a valid URL: ${stringifyError(err)}`,\n );\n return undefined;\n }\n }\n\n private async getUrlsByPreference(): Promise {\n if (this.prioritizedURLs === undefined) {\n this.prioritizedURLs = orderRecordsByPriorityWeight(\n await discoverServiceRecords(),\n ).flatMap((record) => recordToUrl(record) || []);\n }\n\n return this.prioritizedURLs;\n }\n}\n\nexport function recordToUrl(record: SrvRecord): URL | undefined {\n const urlStr = `https://${record.name}:${record.port}`;\n try {\n return new URL(urlStr);\n } catch (err: unknown) {\n actionsCore.debug(\n `Record ${JSON.stringify(record)} produced an invalid URL: ${urlStr} (${err})`,\n );\n return undefined;\n }\n}\n\nasync function discoverServiceRecords(): Promise {\n return await discoverServicesStub(resolveSrv(LOOKUP), 1_000);\n}\n\nexport async function discoverServicesStub(\n lookup: Promise,\n timeout: number,\n): Promise {\n const defaultFallback: Promise = new Promise(\n (resolve, _reject) => {\n setTimeout(resolve, timeout, []);\n },\n );\n\n let records: SrvRecord[];\n\n try {\n records = await Promise.race([lookup, defaultFallback]);\n } catch (reason: unknown) {\n actionsCore.debug(`Error resolving SRV records: ${stringifyError(reason)}`);\n records = [];\n }\n\n const acceptableRecords = records.filter((record: SrvRecord): boolean => {\n for (const suffix of ALLOWED_SUFFIXES) {\n if (record.name.endsWith(suffix)) {\n return true;\n }\n }\n\n actionsCore.debug(\n `Unacceptable domain due to an invalid suffix: ${record.name}`,\n );\n\n return false;\n });\n\n if (acceptableRecords.length === 0) {\n actionsCore.debug(`No records found for ${LOOKUP}`);\n } else {\n actionsCore.debug(\n `Resolved ${LOOKUP} to ${JSON.stringify(acceptableRecords)}`,\n );\n }\n\n return acceptableRecords;\n}\n\nexport function orderRecordsByPriorityWeight(\n records: SrvRecord[],\n): SrvRecord[] {\n const byPriorityWeight: Map = new Map();\n for (const record of records) {\n const existing = byPriorityWeight.get(record.priority);\n if (existing) {\n existing.push(record);\n } else {\n byPriorityWeight.set(record.priority, [record]);\n }\n }\n\n const prioritizedRecords: SrvRecord[] = [];\n const keys: number[] = Array.from(byPriorityWeight.keys()).sort(\n (a, b) => a - b,\n );\n\n for (const priority of keys) {\n const recordsByPrio = byPriorityWeight.get(priority);\n if (recordsByPrio === undefined) {\n continue;\n }\n\n prioritizedRecords.push(...weightedRandom(recordsByPrio));\n }\n\n return prioritizedRecords;\n}\n\nexport function weightedRandom(records: SrvRecord[]): SrvRecord[] {\n // Duplicate records so we don't accidentally change our caller's data\n const scratchRecords: SrvRecord[] = records.slice();\n const result: SrvRecord[] = [];\n\n while (scratchRecords.length > 0) {\n const weights: number[] = [];\n\n {\n for (let i = 0; i < scratchRecords.length; i++) {\n weights.push(\n scratchRecords[i].weight + (i > 0 ? scratchRecords[i - 1].weight : 0),\n );\n }\n }\n\n const point = Math.random() * weights[weights.length - 1];\n\n for (\n let selectedIndex = 0;\n selectedIndex < weights.length;\n selectedIndex++\n ) {\n if (weights[selectedIndex] > point) {\n // Remove our selected record and add it to the result\n result.push(scratchRecords.splice(selectedIndex, 1)[0]);\n break;\n }\n }\n }\n\n return result;\n}\n","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * The character used to separate values in the input string.\n */\nexport type Separator = \"space\" | \"comma\";\n\n/**\n * Convert a comma-separated string input into an array of strings. If `comma` is selected,\n * all whitespace is removed from the string before converting to an array.\n */\nconst getArrayOfStrings = (name: string, separator: Separator): string[] => {\n const original = getString(name);\n return handleString(original, separator);\n};\n\n/**\n * Convert a string input into an array of strings or `null` if no value is set.\n */\nconst getArrayOfStringsOrNull = (\n name: string,\n separator: Separator,\n): string[] | null => {\n const original = getStringOrNull(name);\n if (original === null) {\n return null;\n } else {\n return handleString(original, separator);\n }\n};\n\n// Split out this function for use in testing\nexport const handleString = (input: string, separator: Separator): string[] => {\n const sepChar = separator === \"comma\" ? \",\" : /\\s+/;\n const trimmed = input.trim(); // Remove whitespace at the beginning and end\n if (trimmed === \"\") {\n return [];\n }\n\n return trimmed.split(sepChar).map((s: string) => s.trim());\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getArrayOfStrings,\n getArrayOfStringsOrNull,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\n */\nexport function getArchOs(): string {\n const envArch = process.env.RUNNER_ARCH;\n const envOs = process.env.RUNNER_OS;\n\n if (envArch && envOs) {\n return `${envArch}-${envOs}`;\n } else {\n actionsCore.error(\n `Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${envArch}-${envOs})`,\n );\n throw new Error(\"RUNNER_ARCH and/or RUNNER_OS is not defined\");\n }\n}\n\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\n */\nexport function getNixPlatform(archOs: string): string {\n const archOsMap: Map = new Map([\n [\"X64-macOS\", \"x86_64-darwin\"],\n [\"ARM64-macOS\", \"aarch64-darwin\"],\n [\"X64-Linux\", \"x86_64-linux\"],\n [\"ARM64-Linux\", \"aarch64-linux\"],\n ]);\n\n const mappedTo = archOsMap.get(archOs);\n if (mappedTo) {\n return mappedTo;\n } else {\n actionsCore.error(\n `ArchOs (${archOs}) doesn't map to a supported Nix platform.`,\n );\n throw new Error(\n `Cannot convert ArchOs (${archOs}) to a supported Nix platform.`,\n );\n }\n}\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * as actionsCore from \"@actions/core\";\n\nexport type SourceDef = {\n path?: string;\n url?: string;\n tag?: string;\n pr?: string;\n branch?: string;\n revision?: string;\n};\n\nexport function constructSourceParameters(legacyPrefix?: string): SourceDef {\n return {\n path: noisilyGetInput(\"path\", legacyPrefix),\n url: noisilyGetInput(\"url\", legacyPrefix),\n tag: noisilyGetInput(\"tag\", legacyPrefix),\n pr: noisilyGetInput(\"pr\", legacyPrefix),\n branch: noisilyGetInput(\"branch\", legacyPrefix),\n revision: noisilyGetInput(\"revision\", legacyPrefix),\n };\n}\n\nfunction noisilyGetInput(\n suffix: string,\n legacyPrefix: string | undefined,\n): string | undefined {\n const preferredInput = getStringOrUndefined(`source-${suffix}`);\n\n if (!legacyPrefix) {\n return preferredInput;\n }\n\n // Remaining is for handling cases where the legacy prefix\n // should be examined.\n const legacyInput = getStringOrUndefined(`${legacyPrefix}-${suffix}`);\n\n if (preferredInput && legacyInput) {\n actionsCore.warning(\n `The supported option source-${suffix} and the legacy option ${legacyPrefix}-${suffix} are both set. Preferring source-${suffix}. Please stop setting ${legacyPrefix}-${suffix}.`,\n );\n return preferredInput;\n } else if (legacyInput) {\n actionsCore.warning(\n `The legacy option ${legacyPrefix}-${suffix} is set. Please migrate to source-${suffix}.`,\n );\n return legacyInput;\n } else {\n return preferredInput;\n }\n}\n","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport { collectBacktraces } from \"./backtrace.js\";\nimport { CheckIn, Feature } from \"./check-in.js\";\nimport * as correlation from \"./correlation.js\";\nimport { IdsHost } from \"./ids-host.js\";\nimport { getBool, getStringOrNull } from \"./inputs.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { Got, Request, TimeoutError } from \"got\";\nimport { exec } from \"node:child_process\";\nimport { UUID, randomUUID } from \"node:crypto\";\nimport {\n PathLike,\n WriteStream,\n createWriteStream,\n readFileSync,\n} from \"node:fs\";\nimport fs, { chmod, copyFile, mkdir } from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport { tmpdir } from \"node:os\";\nimport * as path from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { gzip } from \"node:zlib\";\n\nconst EVENT_BACKTRACES = \"backtrace\";\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\nconst EVENT_ARTIFACT_CACHE_PERSIST = \"artifact_cache_persist\";\nconst EVENT_PREFLIGHT_REQUIRE_NIX_DENIED = \"preflight-require-nix-denied\";\n\nconst FACT_ARTIFACT_FETCHED_FROM_CACHE = \"artifact_fetched_from_cache\";\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\nconst FACT_OS = \"$os\";\nconst FACT_OS_VERSION = \"$os_version\";\nconst FACT_SOURCE_URL = \"source_url\";\nconst FACT_SOURCE_URL_ETAG = \"source_url_etag\";\n\nconst FACT_NIX_LOCATION = \"nix_location\";\nconst FACT_NIX_STORE_TRUST = \"nix_store_trusted\";\nconst FACT_NIX_STORE_VERSION = \"nix_store_version\";\nconst FACT_NIX_STORE_CHECK_METHOD = \"nix_store_check_method\";\nconst FACT_NIX_STORE_CHECK_ERROR = \"nix_store_check_error\";\n\nconst STATE_KEY_EXECUTION_PHASE = \"detsys_action_execution_phase\";\nconst STATE_KEY_NIX_NOT_FOUND = \"detsys_action_nix_not_found\";\nconst STATE_NOT_FOUND = \"not-found\";\nconst STATE_KEY_CROSS_PHASE_ID = \"detsys_cross_phase_id\";\nconst STATE_BACKTRACE_START_TIMESTAMP = \"detsys_backtrace_start_timestamp\";\n\nconst DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 10_000; // 10 seconds in ms\nconst CHECK_IN_ENDPOINT_TIMEOUT_MS = 1_000; // 1 second in ms\n\n/**\n * An enum for describing different \"fetch suffixes\" for i.d.s.\n *\n * - `nix-style` means that system names like `x86_64-linux` and `aarch64-darwin` are used\n * - `gh-env-style` means that names like `X64-Linux` and `ARM64-macOS` are used\n * - `universal` means that the suffix is the static `universal` (for non-system-specific things)\n */\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\n\n/**\n * GitHub Actions has two possible execution phases: `main` and `post`.\n */\nexport type ExecutionPhase = \"main\" | \"post\";\n\n/**\n * How to handle whether Nix is currently installed on the runner.\n *\n * - `fail` means that the workflow fails if Nix isn't installed\n * - `warn` means that a warning is logged if Nix isn't installed\n * - `ignore` means that Nix will not be checked\n */\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\n\n/**\n * Whether the Nix store on the runner is trusted.\n *\n * - `trusted` means yes\n * - `untrusted` means no\n * - `unknown` means that the status couldn't be determined\n *\n * This is determined via the output of `nix store info --json`.\n */\nexport type NixStoreTrust = \"trusted\" | \"untrusted\" | \"unknown\";\n\nexport type ActionOptions = {\n // Name of the project generally, and the name of the binary on disk.\n name: string;\n\n // Defaults to `name`, Corresponds to the ProjectHost entry on i.d.s.\n idsProjectName?: string;\n\n // Defaults to `action:`\n eventPrefix?: string;\n\n // The \"architecture\" URL component expected by I.D.S. for the ProjectHost.\n fetchStyle: FetchSuffixStyle;\n\n // IdsToolbox assumes the GitHub Action exposes source overrides, like branch/pr/etc. to be named `source-*`.\n // This prefix adds a fallback name, prefixed by `${legacySourcePrefix}-`.\n // Users who configure legacySourcePrefix will get warnings asking them to change to `source-*`.\n legacySourcePrefix?: string;\n\n // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\n\n // The URL suffix to send diagnostics events to.\n //\n // The final URL is constructed via IDS_HOST/idsProjectName/diagnosticsSuffix.\n //\n // Default: `diagnostics`.\n diagnosticsSuffix?: string;\n\n // Collect backtraces from segfaults and other failures from binaries that start with these names.\n //\n // Default: `[ \"nix\", \"determinate-nixd\", ActionOptions.name ]`.\n binaryNamePrefixes?: string[];\n};\n\n/**\n * A confident version of Options, where defaults have been resolved into final values.\n */\nexport type ConfidentActionOptions = {\n name: string;\n idsProjectName: string;\n eventPrefix: string;\n fetchStyle: FetchSuffixStyle;\n legacySourcePrefix?: string;\n requireNix: NixRequirementHandling;\n providedDiagnosticsUrl?: URL;\n binaryNamePrefixes: string[];\n};\n\n/**\n * An event to send to the diagnostic endpoint of i.d.s.\n */\nexport type DiagnosticEvent = {\n // Note: putting a Map in here won't serialize to json properly.\n // It'll just be {} on serialization.\n event_name: string;\n context: Record;\n correlation: correlation.AnonymizedCorrelationHashes;\n facts: Record;\n features: { [k: string]: string | boolean };\n timestamp: Date;\n uuid: UUID;\n};\n\nexport abstract class DetSysAction {\n nixStoreTrust: NixStoreTrust;\n strictMode: boolean;\n\n private actionOptions: ConfidentActionOptions;\n private exceptionAttachments: Map;\n private archOs: string;\n private executionPhase: ExecutionPhase;\n private nixSystem: string;\n private architectureFetchSuffix: string;\n private sourceParameters: SourceDef;\n private facts: Record;\n private events: DiagnosticEvent[];\n private identity: correlation.AnonymizedCorrelationHashes;\n private idsHost: IdsHost;\n private features: { [k: string]: Feature };\n private featureEventMetadata: { [k: string]: string | boolean };\n\n private determineExecutionPhase(): ExecutionPhase {\n const currentPhase = actionsCore.getState(STATE_KEY_EXECUTION_PHASE);\n if (currentPhase === \"\") {\n actionsCore.saveState(STATE_KEY_EXECUTION_PHASE, \"post\");\n return \"main\";\n } else {\n return \"post\";\n }\n }\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.idsHost = new IdsHost(\n this.actionOptions.idsProjectName,\n actionOptions.diagnosticsSuffix,\n // Note: we don't use actionsCore.getInput('diagnostic-endpoint') on purpose:\n // getInput silently converts absent data to an empty string.\n process.env[\"INPUT_DIAGNOSTIC-ENDPOINT\"],\n );\n this.exceptionAttachments = new Map();\n this.nixStoreTrust = \"unknown\";\n this.strictMode = getBool(\"_internal-strict-mode\");\n\n this.features = {};\n this.featureEventMetadata = {};\n this.events = [];\n\n this.getCrossPhaseId();\n this.collectBacktraceSetup();\n\n // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\n project: this.actionOptions.name,\n ids_project: this.actionOptions.idsProjectName,\n };\n\n const params = [\n [\"github_action_ref\", \"GITHUB_ACTION_REF\"],\n [\"github_action_repository\", \"GITHUB_ACTION_REPOSITORY\"],\n [\"github_event_name\", \"GITHUB_EVENT_NAME\"],\n [\"$os\", \"RUNNER_OS\"],\n [\"arch\", \"RUNNER_ARCH\"],\n ];\n for (const [target, env] of params) {\n const value = process.env[env];\n if (value) {\n this.facts[target] = value;\n }\n }\n\n this.identity = correlation.identify(this.actionOptions.name);\n this.archOs = platform.getArchOs();\n this.nixSystem = platform.getNixPlatform(this.archOs);\n\n this.facts.arch_os = this.archOs;\n this.facts.nix_system = this.nixSystem;\n\n {\n ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(FACT_OS, details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(FACT_OS_VERSION, details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e: unknown) => {\n actionsCore.debug(\n `Failure getting platform details: ${stringifyError(e)}`,\n );\n });\n }\n\n this.executionPhase = this.determineExecutionPhase();\n this.facts.execution_phase = this.executionPhase;\n\n if (this.actionOptions.fetchStyle === \"gh-env-style\") {\n this.architectureFetchSuffix = this.archOs;\n } else if (this.actionOptions.fetchStyle === \"nix-style\") {\n this.architectureFetchSuffix = this.nixSystem;\n } else if (this.actionOptions.fetchStyle === \"universal\") {\n this.architectureFetchSuffix = \"universal\";\n } else {\n throw new Error(\n `fetchStyle ${this.actionOptions.fetchStyle} is not a valid style`,\n );\n }\n\n this.sourceParameters = constructSourceParameters(\n this.actionOptions.legacySourcePrefix,\n );\n\n this.recordEvent(`begin_${this.executionPhase}`);\n }\n\n /**\n * Attach a file to the diagnostics data in error conditions.\n *\n * The file at `location` doesn't need to exist when stapleFile is called.\n *\n * If the file doesn't exist or is unreadable when trying to staple the attachments, the JS error will be stored in a context value at `staple_failure_{name}`.\n * If the file is readable, the file's contents will be stored in a context value at `staple_value_{name}`.\n */\n stapleFile(name: string, location: string): void {\n this.exceptionAttachments.set(name, location);\n }\n\n /**\n * The main execution phase.\n */\n abstract main(): Promise;\n\n /**\n * The post execution phase.\n */\n abstract post(): Promise;\n\n /**\n * Execute the Action as defined.\n */\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n getTemporaryName(): string {\n const tmpDir = process.env[\"RUNNER_TEMP\"] || tmpdir();\n return path.join(tmpDir, `${this.actionOptions.name}-${randomUUID()}`);\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n async getDiagnosticsUrl(): Promise {\n return await this.idsHost.getDiagnosticsUrl();\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n // This ID will be saved in the action's state, to be persisted across phase steps\n getCrossPhaseId(): string {\n let crossPhaseId = actionsCore.getState(STATE_KEY_CROSS_PHASE_ID);\n\n if (crossPhaseId === \"\") {\n crossPhaseId = randomUUID();\n actionsCore.saveState(STATE_KEY_CROSS_PHASE_ID, crossPhaseId);\n }\n\n return crossPhaseId;\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\n }\n\n recordEvent(\n eventName: string,\n context: Record = {},\n ): void {\n const prefixedName =\n eventName === \"$feature_flag_called\"\n ? eventName\n : `${this.actionOptions.eventPrefix}${eventName}`;\n this.events.push({\n event_name: prefixedName,\n context,\n correlation: this.identity,\n facts: this.facts,\n features: this.featureEventMetadata,\n timestamp: new Date(),\n uuid: randomUUID(),\n });\n }\n\n /**\n * Unpacks the closure returned by `fetchArtifact()`, imports the\n * contents into the Nix store, and returns the path of the executable at\n * `/nix/store/STORE_PATH/bin/${bin}`.\n */\n async unpackClosure(bin: string): Promise {\n const artifact = await this.fetchArtifact();\n const { stdout } = await promisify(exec)(\n `cat \"${artifact}\" | xz -d | nix-store --import`,\n );\n const paths = stdout.split(os.EOL);\n const lastPath = paths.at(-2);\n return `${lastPath}/bin/${bin}`;\n }\n\n /**\n * Fetches the executable at the URL determined by the `source-*` inputs and\n * other facts, `chmod`s it, and returns the path to the executable on disk.\n */\n async fetchExecutable(): Promise {\n const binaryPath = await this.fetchArtifact();\n await chmod(binaryPath, fs.constants.S_IXUSR | fs.constants.S_IXGRP);\n return binaryPath;\n }\n\n private get isMain(): boolean {\n return this.executionPhase === \"main\";\n }\n\n private get isPost(): boolean {\n return this.executionPhase === \"post\";\n }\n\n private async executeAsync(): Promise {\n try {\n await this.checkIn();\n\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(EVENT_PREFLIGHT_REQUIRE_NIX_DENIED);\n return;\n } else {\n await this.preflightNixStoreInfo();\n this.addFact(FACT_NIX_STORE_TRUST, this.nixStoreTrust);\n }\n\n if (this.isMain) {\n await this.main();\n } else if (this.isPost) {\n await this.post();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (e: unknown) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable = stringifyError(e);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.isPost) {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n const doGzip = promisify(gzip);\n\n const exceptionContext: Map = new Map();\n for (const [attachmentLabel, filePath] of this.exceptionAttachments) {\n try {\n const logText = readFileSync(filePath);\n const buf = await doGzip(logText);\n exceptionContext.set(\n `staple_value_${attachmentLabel}`,\n buf.toString(\"base64\"),\n );\n } catch (innerError: unknown) {\n exceptionContext.set(\n `staple_failure_${attachmentLabel}`,\n stringifyError(innerError),\n );\n }\n }\n\n this.recordEvent(EVENT_EXCEPTION, Object.fromEntries(exceptionContext));\n } finally {\n if (this.isPost) {\n await this.collectBacktraces();\n }\n\n await this.complete();\n }\n }\n\n async getClient(): Promise {\n return await this.idsHost.getGot(\n (incitingError: unknown, prevUrl: URL, nextUrl: URL) => {\n this.recordPlausibleTimeout(incitingError);\n\n this.recordEvent(\"ids-failover\", {\n previousUrl: prevUrl.toString(),\n nextUrl: nextUrl.toString(),\n });\n },\n );\n }\n\n private async checkIn(): Promise {\n const checkin = await this.requestCheckIn();\n if (checkin === undefined) {\n return;\n }\n\n this.features = checkin.options;\n for (const [key, feature] of Object.entries(this.features)) {\n this.featureEventMetadata[key] = feature.variant;\n }\n\n const impactSymbol: Map = new Map([\n [\"none\", \"⚪\"],\n [\"maintenance\", \"🛠️\"],\n [\"minor\", \"🟡\"],\n [\"major\", \"🟠\"],\n [\"critical\", \"🔴\"],\n ]);\n const defaultImpactSymbol = \"🔵\";\n\n if (checkin.status !== null) {\n const summaries: string[] = [];\n\n for (const incident of checkin.status.incidents) {\n summaries.push(\n `${impactSymbol.get(incident.impact) || defaultImpactSymbol} ${incident.status.replace(\"_\", \" \")}: ${incident.name} (${incident.shortlink})`,\n );\n }\n\n for (const maintenance of checkin.status.scheduled_maintenances) {\n summaries.push(\n `${impactSymbol.get(maintenance.impact) || defaultImpactSymbol} ${maintenance.status.replace(\"_\", \" \")}: ${maintenance.name} (${maintenance.shortlink})`,\n );\n }\n\n if (summaries.length > 0) {\n actionsCore.info(\n // Bright red, Bold, Underline\n `${\"\\u001b[0;31m\"}${\"\\u001b[1m\"}${\"\\u001b[4m\"}${checkin.status.page.name} Status`,\n );\n for (const notice of summaries) {\n actionsCore.info(notice);\n }\n actionsCore.info(`See: ${checkin.status.page.url}`);\n actionsCore.info(``);\n }\n }\n }\n\n getFeature(name: string): Feature | undefined {\n if (!this.features.hasOwnProperty(name)) {\n return undefined;\n }\n\n const result = this.features[name];\n if (result === undefined) {\n return undefined;\n }\n\n this.recordEvent(\"$feature_flag_called\", {\n $feature_flag: name,\n $feature_flag_response: result.variant,\n });\n\n return result;\n }\n\n /**\n * Check in to install.determinate.systems, to accomplish three things:\n *\n * 1. Preflight the server selected from IdsHost, to increase the chances of success.\n * 2. Fetch any incidents and maintenance events to let users know in case things are weird.\n * 3. Get feature flag data so we can gently roll out new features.\n */\n private async requestCheckIn(): Promise {\n for (\n let attemptsRemaining = 5;\n attemptsRemaining > 0;\n attemptsRemaining--\n ) {\n const checkInUrl = await this.getCheckInUrl();\n if (checkInUrl === undefined) {\n return undefined;\n }\n\n try {\n actionsCore.debug(`Preflighting via ${checkInUrl}`);\n\n checkInUrl.searchParams.set(\"ci\", \"github\");\n checkInUrl.searchParams.set(\n \"correlation\",\n JSON.stringify(this.identity),\n );\n\n return (await this.getClient())\n .get(checkInUrl, {\n timeout: {\n request: CHECK_IN_ENDPOINT_TIMEOUT_MS,\n },\n })\n .json();\n } catch (e: unknown) {\n this.recordPlausibleTimeout(e);\n actionsCore.debug(`Error checking in: ${stringifyError(e)}`);\n this.idsHost.markCurrentHostBroken();\n }\n }\n\n return undefined;\n }\n\n private recordPlausibleTimeout(e: unknown): void {\n // see: https://github.com/sindresorhus/got/blob/895e463fa699d6f2e4b2fc01ceb3b2bb9e157f4c/documentation/8-errors.md\n if (e instanceof TimeoutError && \"timings\" in e && \"request\" in e) {\n const reportContext: {\n [index: string]: string | number | undefined;\n } = {\n url: e.request.requestUrl?.toString(),\n retry_count: e.request.retryCount,\n };\n\n for (const [key, value] of Object.entries(e.timings.phases)) {\n if (Number.isFinite(value)) {\n reportContext[`timing_phase_${key}`] = value;\n }\n }\n\n this.recordEvent(\"timeout\", reportContext);\n }\n }\n\n /**\n * Fetch an artifact, such as a tarball, from the location determined by the\n * `source-*` inputs. If `source-binary` is specified, this will return a path\n * to a binary on disk; otherwise, the artifact will be downloaded from the\n * URL determined by the other `source-*` inputs (`source-url`, `source-pr`,\n * etc.).\n */\n private async fetchArtifact(): Promise {\n const sourceBinary = getStringOrNull(\"source-binary\");\n\n // If source-binary is set, use that. Otherwise fall back to the source-* parameters.\n if (sourceBinary !== null && sourceBinary !== \"\") {\n actionsCore.debug(`Using the provided source binary at ${sourceBinary}`);\n return sourceBinary;\n }\n\n actionsCore.startGroup(\n `Downloading ${this.actionOptions.name} for ${this.architectureFetchSuffix}`,\n );\n\n try {\n actionsCore.info(`Fetching from ${await this.getSourceUrl()}`);\n\n const correlatedUrl = await this.getSourceUrl();\n correlatedUrl.searchParams.set(\"ci\", \"github\");\n correlatedUrl.searchParams.set(\n \"correlation\",\n JSON.stringify(this.identity),\n );\n\n const versionCheckup = await (await this.getClient()).head(correlatedUrl);\n if (versionCheckup.headers.etag) {\n const v = versionCheckup.headers.etag;\n this.addFact(FACT_SOURCE_URL_ETAG, v);\n\n actionsCore.debug(\n `Checking the tool cache for ${await this.getSourceUrl()} at ${v}`,\n );\n const cached = await this.getCachedVersion(v);\n if (cached) {\n this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = true;\n actionsCore.debug(`Tool cache hit.`);\n return cached;\n }\n }\n\n this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = false;\n\n actionsCore.debug(\n `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`,\n );\n\n const destFile = this.getTemporaryName();\n\n const fetchStream = await this.downloadFile(\n new URL(versionCheckup.url),\n destFile,\n );\n\n if (fetchStream.response?.headers.etag) {\n const v = fetchStream.response.headers.etag;\n\n try {\n await this.saveCachedVersion(v, destFile);\n } catch (e: unknown) {\n actionsCore.debug(`Error caching the artifact: ${stringifyError(e)}`);\n }\n }\n\n return destFile;\n } catch (e: unknown) {\n this.recordPlausibleTimeout(e);\n throw e;\n } finally {\n actionsCore.endGroup();\n }\n }\n\n /**\n * A helper function for failing on error only if strict mode is enabled.\n * This is intended only for CI environments testing Actions themselves.\n */\n failOnError(msg: string): void {\n if (this.strictMode) {\n actionsCore.setFailed(`strict mode failure: ${msg}`);\n }\n }\n\n private async downloadFile(\n url: URL,\n destination: PathLike,\n ): Promise {\n const client = await this.getClient();\n\n return new Promise((resolve, reject) => {\n // Current stream handle\n let writeStream: WriteStream | undefined;\n\n // Sentinel condition in case we want to abort retrying due to FS issues\n let failed = false;\n\n const retry = (stream: Request): void => {\n if (writeStream) {\n writeStream.destroy();\n }\n\n writeStream = createWriteStream(destination, {\n encoding: \"binary\",\n mode: 0o755,\n });\n\n writeStream.once(\"error\", (error) => {\n // Set failed here since promise rejections don't impact control flow\n failed = true;\n reject(error);\n });\n\n writeStream.on(\"finish\", () => {\n if (!failed) {\n resolve(stream);\n }\n });\n\n stream.once(\"retry\", (_count, _error, createRetryStream) => {\n // Optional: check `failed' here in case you want to stop retrying\n retry(createRetryStream());\n });\n\n // Now that all the handlers have been set up we can pipe from the HTTP\n // stream to disk\n stream.pipe(writeStream);\n };\n\n // Begin the retry logic by giving it a fresh got.Request\n retry(client.stream(url));\n });\n }\n\n private async complete(): Promise {\n this.recordEvent(`complete_${this.executionPhase}`);\n await this.submitEvents();\n }\n\n private async getCheckInUrl(): Promise {\n const checkInUrl = await this.idsHost.getDynamicRootUrl();\n\n if (checkInUrl === undefined) {\n return undefined;\n }\n\n checkInUrl.pathname += \"check-in\";\n return checkInUrl;\n }\n\n private async getSourceUrl(): Promise {\n const p = this.sourceParameters;\n\n if (p.url) {\n this.addFact(FACT_SOURCE_URL, p.url);\n return new URL(p.url);\n }\n\n const fetchUrl = await this.idsHost.getRootUrl();\n fetchUrl.pathname += this.actionOptions.idsProjectName;\n\n if (p.tag) {\n fetchUrl.pathname += `/tag/${p.tag}`;\n } else if (p.pr) {\n fetchUrl.pathname += `/pr/${p.pr}`;\n } else if (p.branch) {\n fetchUrl.pathname += `/branch/${p.branch}`;\n } else if (p.revision) {\n fetchUrl.pathname += `/rev/${p.revision}`;\n } else {\n fetchUrl.pathname += `/stable`;\n }\n\n fetchUrl.pathname += `/${this.architectureFetchSuffix}`;\n\n this.addFact(FACT_SOURCE_URL, fetchUrl.toString());\n\n return fetchUrl;\n }\n\n private cacheKey(version: string): string {\n const cleanedVersion = version.replace(/[^a-zA-Z0-9-+.]/g, \"\");\n return `determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${cleanedVersion}`;\n }\n\n private async getCachedVersion(version: string): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n if (\n await actionsCache.restoreCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n [],\n undefined,\n true,\n )\n ) {\n this.recordEvent(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_ARTIFACT_CACHE_MISS);\n return undefined;\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private async saveCachedVersion(\n version: string,\n toolPath: string,\n ): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n await copyFile(toolPath, `${tempDir}/${this.actionOptions.name}`);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n await actionsCache.saveCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n undefined,\n true,\n );\n this.recordEvent(EVENT_ARTIFACT_CACHE_PERSIST);\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private collectBacktraceSetup(): void {\n if (process.env.DETSYS_BACKTRACE_COLLECTOR === \"\") {\n actionsCore.exportVariable(\n \"DETSYS_BACKTRACE_COLLECTOR\",\n this.getCrossPhaseId(),\n );\n\n actionsCore.saveState(STATE_BACKTRACE_START_TIMESTAMP, Date.now());\n }\n }\n\n private async collectBacktraces(): Promise {\n try {\n if (process.env.DETSYS_BACKTRACE_COLLECTOR !== this.getCrossPhaseId()) {\n return;\n }\n\n const backtraces = await collectBacktraces(\n this.actionOptions.binaryNamePrefixes,\n parseInt(actionsCore.getState(STATE_BACKTRACE_START_TIMESTAMP)),\n );\n actionsCore.debug(`Backtraces identified: ${backtraces.size}`);\n if (backtraces.size > 0) {\n this.recordEvent(EVENT_BACKTRACES, Object.fromEntries(backtraces));\n }\n } catch (innerError: unknown) {\n actionsCore.debug(\n `Error collecting backtraces: ${stringifyError(innerError)}`,\n );\n }\n }\n\n private async preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n break;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(FACT_NIX_LOCATION, nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(STATE_KEY_NIX_NOT_FOUND);\n if (currentNotFoundState === STATE_NOT_FOUND) {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(STATE_KEY_NIX_NOT_FOUND, STATE_NOT_FOUND);\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n [\n \"This action can only be used when Nix is installed.\",\n \"Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n ].join(\" \"),\n );\n break;\n case \"warn\":\n actionsCore.warning(\n [\n \"This action is in no-op mode because Nix is not installed.\",\n \"Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n ].join(\" \"),\n );\n break;\n }\n\n return false;\n }\n\n private async preflightNixStoreInfo(): Promise {\n let output = \"\";\n\n const options: actionsExec.ExecOptions = {};\n options.silent = true;\n options.listeners = {\n stdout: (data) => {\n output += data.toString();\n },\n };\n\n try {\n output = \"\";\n await actionsExec.exec(\"nix\", [\"store\", \"info\", \"--json\"], options);\n this.addFact(FACT_NIX_STORE_CHECK_METHOD, \"info\");\n } catch {\n try {\n // reset output\n output = \"\";\n await actionsExec.exec(\"nix\", [\"store\", \"ping\", \"--json\"], options);\n this.addFact(FACT_NIX_STORE_CHECK_METHOD, \"ping\");\n } catch {\n this.addFact(FACT_NIX_STORE_CHECK_METHOD, \"none\");\n return;\n }\n }\n\n try {\n const parsed = JSON.parse(output);\n if (parsed.trusted === 1) {\n this.nixStoreTrust = \"trusted\";\n } else if (parsed.trusted === 0) {\n this.nixStoreTrust = \"untrusted\";\n } else if (parsed.trusted !== undefined) {\n this.addFact(\n FACT_NIX_STORE_CHECK_ERROR,\n `Mysterious trusted value: ${JSON.stringify(parsed.trusted)}`,\n );\n }\n\n this.addFact(FACT_NIX_STORE_VERSION, JSON.stringify(parsed.version));\n } catch (e: unknown) {\n this.addFact(FACT_NIX_STORE_CHECK_ERROR, stringifyError(e));\n }\n }\n\n private async submitEvents(): Promise {\n const diagnosticsUrl = await this.idsHost.getDiagnosticsUrl();\n if (diagnosticsUrl === undefined) {\n actionsCore.debug(\n \"Diagnostics are disabled. Not sending the following events:\",\n );\n actionsCore.debug(JSON.stringify(this.events, undefined, 2));\n return;\n }\n\n const batch = {\n type: \"eventlog\",\n sent_at: new Date(),\n events: this.events,\n };\n\n try {\n await (\n await this.getClient()\n ).post(diagnosticsUrl, {\n json: batch,\n timeout: {\n request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS,\n },\n });\n } catch (err: unknown) {\n this.recordPlausibleTimeout(err);\n\n actionsCore.debug(\n `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError(err)}`,\n );\n }\n this.events = [];\n }\n}\n\nfunction stringifyError(error: unknown): string {\n return error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n}\n\nfunction makeOptionsConfident(\n actionOptions: ActionOptions,\n): ConfidentActionOptions {\n const idsProjectName = actionOptions.idsProjectName ?? actionOptions.name;\n\n const finalOpts: ConfidentActionOptions = {\n name: actionOptions.name,\n idsProjectName,\n eventPrefix: actionOptions.eventPrefix || \"action:\",\n fetchStyle: actionOptions.fetchStyle,\n legacySourcePrefix: actionOptions.legacySourcePrefix,\n requireNix: actionOptions.requireNix,\n binaryNamePrefixes: actionOptions.binaryNamePrefixes ?? [\n \"nix\",\n \"determinate-nixd\",\n actionOptions.name,\n ],\n };\n\n actionsCore.debug(\"idslib options:\");\n actionsCore.debug(JSON.stringify(finalOpts, undefined, 2));\n\n return finalOpts;\n}\n\n// Public exports from other files\nexport {\n CheckIn,\n Feature,\n Incident,\n Maintenance,\n Page,\n StatusSummary,\n} from \"./check-in.js\";\nexport { AnonymizedCorrelationHashes } from \"./correlation.js\";\nexport { stringifyError } from \"./errors.js\";\nexport { IdsHost } from \"./ids-host.js\";\nexport { SourceDef } from \"./sourcedef.js\";\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACYb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AACT;AAQO,SAAS,YAAY,aAA8C;AACxE,QAAM,UAAU,EAAE,GAAG,iCAAiC,GAAG,YAAY;AAErE,QAAM,0BAAoC;AAAA,IACxC,QAAQ;AAAA,EACV;AAEA,MAAO,QAAK,MAAM,SAAS;AACzB,QAAI,QAAQ,SAAS,QAAQ;AAC3B,aAAO,UAAU;AAAA,IACnB,OAAO;AACL,aAAO,QAAQ,QAAQ,UAAU,C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AAM,YAAoC;AAAA,IACxC,MAAM,cAAc;AAAA,IACpB;AAAA,IACA,aAAa,cAAc,eAAe;AAAA,IAC1C,YAAY,cAAc;AAAA,IAC1B,oBAAoB,cAAc;AAAA,IAClC,YAAY,cAAc;AAAA,IAC1B,oBAAoB,cAAc,sBAAsB;AAAA,MACtD;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IAChB;AAAA,EACF;AAEA,EAAY,mBAAM,iBAAiB;AACnC,EAAY,mBAAM,KAAK,UAAU,WAAW,QAAW,CAAC,CAAC;AAEzD,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","exec","readFile","promisify","actionsCore","actionsCore","error","actionsCore","actionsCore","actionsCore","actionsCore","exec","readFileSync","fs","os","promisify","gzip","stringifyError","error","promisify","exec","fs","gzip","readFileSync","version"]} \ No newline at end of file diff --git a/src/ids-host.ts b/src/ids-host.ts index a26c136..e49010e 100644 --- a/src/ids-host.ts +++ b/src/ids-host.ts @@ -17,7 +17,7 @@ const ALLOWED_SUFFIXES = [ const DEFAULT_IDS_HOST = "https://install.determinate.systems"; const LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP; -const DEFAULT_TIMEOUT = 30_000; // 30 seconds in milliseconds +const DEFAULT_TIMEOUT = 10_000; // 10 seconds in ms /** * Host information for install.determinate.systems. @@ -41,7 +41,11 @@ export class IdsHost { } async getGot( - recordFailoverCallback?: (prevUrl: URL, nextUrl: URL) => void, + recordFailoverCallback?: ( + incitingError: unknown, + prevUrl: URL, + nextUrl: URL, + ) => void, ): Promise { if (this.client === undefined) { this.client = got.extend({ @@ -50,7 +54,7 @@ export class IdsHost { }, retry: { - limit: (await this.getUrlsByPreference()).length, + limit: Math.max((await this.getUrlsByPreference()).length, 3), methods: ["GET", "HEAD"], }, @@ -62,7 +66,7 @@ export class IdsHost { const nextUrl = await this.getRootUrl(); if (recordFailoverCallback !== undefined) { - recordFailoverCallback(prevUrl, nextUrl); + recordFailoverCallback(error, prevUrl, nextUrl); } actionsCore.info( diff --git a/src/index.ts b/src/index.ts index bef718b..e746b14 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,15 +14,19 @@ import { SourceDef, constructSourceParameters } from "./sourcedef.js"; import * as actionsCache from "@actions/cache"; import * as actionsCore from "@actions/core"; import * as actionsExec from "@actions/exec"; -import { Got } from "got"; +import { Got, Request, TimeoutError } from "got"; import { exec } from "node:child_process"; import { UUID, randomUUID } from "node:crypto"; -import { PathLike, createWriteStream, readFileSync } from "node:fs"; +import { + PathLike, + WriteStream, + createWriteStream, + readFileSync, +} from "node:fs"; import fs, { chmod, copyFile, mkdir } from "node:fs/promises"; import * as os from "node:os"; import { tmpdir } from "node:os"; import * as path from "node:path"; -import { pipeline } from "node:stream/promises"; import { promisify } from "node:util"; import { gzip } from "node:zlib"; @@ -53,8 +57,8 @@ const STATE_NOT_FOUND = "not-found"; const STATE_KEY_CROSS_PHASE_ID = "detsys_cross_phase_id"; const STATE_BACKTRACE_START_TIMESTAMP = "detsys_backtrace_start_timestamp"; -const DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 30_000; // 30 seconds in milliseconds -const CHECK_IN_ENDPOINT_TIMEOUT_MS = 5_000; // 5 seconds in milliseconds +const DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 10_000; // 10 seconds in ms +const CHECK_IN_ENDPOINT_TIMEOUT_MS = 1_000; // 1 second in ms /** * An enum for describing different "fetch suffixes" for i.d.s. @@ -346,7 +350,10 @@ export abstract class DetSysAction { return this.identity; } - recordEvent(eventName: string, context: Record = {}): void { + recordEvent( + eventName: string, + context: Record = {}, + ): void { const prefixedName = eventName === "$feature_flag_called" ? eventName @@ -460,12 +467,16 @@ export abstract class DetSysAction { } async getClient(): Promise { - return await this.idsHost.getGot((prevUrl: URL, nextUrl: URL) => { - this.recordEvent("ids-failover", { - previousUrl: prevUrl.toString(), - nextUrl: nextUrl.toString(), - }); - }); + return await this.idsHost.getGot( + (incitingError: unknown, prevUrl: URL, nextUrl: URL) => { + this.recordPlausibleTimeout(incitingError); + + this.recordEvent("ids-failover", { + previousUrl: prevUrl.toString(), + nextUrl: nextUrl.toString(), + }); + }, + ); } private async checkIn(): Promise { @@ -570,6 +581,7 @@ export abstract class DetSysAction { }) .json(); } catch (e: unknown) { + this.recordPlausibleTimeout(e); actionsCore.debug(`Error checking in: ${stringifyError(e)}`); this.idsHost.markCurrentHostBroken(); } @@ -578,6 +590,26 @@ export abstract class DetSysAction { return undefined; } + private recordPlausibleTimeout(e: unknown): void { + // see: https://github.com/sindresorhus/got/blob/895e463fa699d6f2e4b2fc01ceb3b2bb9e157f4c/documentation/8-errors.md + if (e instanceof TimeoutError && "timings" in e && "request" in e) { + const reportContext: { + [index: string]: string | number | undefined; + } = { + url: e.request.requestUrl?.toString(), + retry_count: e.request.retryCount, + }; + + for (const [key, value] of Object.entries(e.timings.phases)) { + if (Number.isFinite(value)) { + reportContext[`timing_phase_${key}`] = value; + } + } + + this.recordEvent("timeout", reportContext); + } + } + /** * Fetch an artifact, such as a tarball, from the location determined by the * `source-*` inputs. If `source-binary` is specified, this will return a path @@ -631,14 +663,10 @@ export abstract class DetSysAction { ); const destFile = this.getTemporaryName(); - const fetchStream = (await this.getClient()).stream(versionCheckup.url); - await pipeline( - fetchStream, - createWriteStream(destFile, { - encoding: "binary", - mode: 0o755, - }), + const fetchStream = await this.downloadFile( + new URL(versionCheckup.url), + destFile, ); if (fetchStream.response?.headers.etag) { @@ -652,6 +680,9 @@ export abstract class DetSysAction { } return destFile; + } catch (e: unknown) { + this.recordPlausibleTimeout(e); + throw e; } finally { actionsCore.endGroup(); } @@ -667,6 +698,56 @@ export abstract class DetSysAction { } } + private async downloadFile( + url: URL, + destination: PathLike, + ): Promise { + const client = await this.getClient(); + + return new Promise((resolve, reject) => { + // Current stream handle + let writeStream: WriteStream | undefined; + + // Sentinel condition in case we want to abort retrying due to FS issues + let failed = false; + + const retry = (stream: Request): void => { + if (writeStream) { + writeStream.destroy(); + } + + writeStream = createWriteStream(destination, { + encoding: "binary", + mode: 0o755, + }); + + writeStream.once("error", (error) => { + // Set failed here since promise rejections don't impact control flow + failed = true; + reject(error); + }); + + writeStream.on("finish", () => { + if (!failed) { + resolve(stream); + } + }); + + stream.once("retry", (_count, _error, createRetryStream) => { + // Optional: check `failed' here in case you want to stop retrying + retry(createRetryStream()); + }); + + // Now that all the handlers have been set up we can pipe from the HTTP + // stream to disk + stream.pipe(writeStream); + }; + + // Begin the retry logic by giving it a fresh got.Request + retry(client.stream(url)); + }); + } + private async complete(): Promise { this.recordEvent(`complete_${this.executionPhase}`); await this.submitEvents(); @@ -941,6 +1022,8 @@ export abstract class DetSysAction { }, }); } catch (err: unknown) { + this.recordPlausibleTimeout(err); + actionsCore.debug( `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError(err)}`, );