diff --git a/dist/main.d.ts b/dist/index.d.ts similarity index 100% rename from dist/main.d.ts rename to dist/index.d.ts diff --git a/dist/index.js b/dist/index.js index 8872a79..ad0c58c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -94619,8 +94619,8 @@ function mungeDiagnosticEndpoint(inputUrl) { * Copyright (c) 2018-2020 [Samuel Carreira] */ //# sourceMappingURL=index.js.map -;// CONCATENATED MODULE: ./dist/main.js -// src/main.ts +;// CONCATENATED MODULE: ./dist/index.js +// src/index.ts @@ -94880,6 +94880,6 @@ idslib.onPost(async () => { await tearDownAutoCache(); }); idslib.execute(); -//# sourceMappingURL=main.js.map +//# sourceMappingURL=index.js.map })(); diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..076ee0b --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { spawn, exec, SpawnOptions } from \"node:child_process\";\nimport { openSync, readFileSync } from \"node:fs\";\nimport { inspect, promisify } from \"node:util\";\nimport * as http from \"http\";\n\nimport * as core from \"@actions/core\";\nimport { Tail } from \"tail\";\nimport got from \"got\";\nimport { IdsToolbox } from \"detsys-ts\";\n\nconst ENV_CACHE_DAEMONDIR = \"MAGIC_NIX_CACHE_DAEMONDIR\";\n\nconst gotClient = got.extend({\n retry: {\n limit: 1,\n methods: [\"POST\", \"GET\", \"PUT\", \"HEAD\", \"DELETE\", \"OPTIONS\", \"TRACE\"],\n },\n hooks: {\n beforeRetry: [\n (error, retryCount) => {\n core.info(`Retrying after error ${error.code}, retry #: ${retryCount}`);\n },\n ],\n },\n});\n\nasync function fetchAutoCacher(toolbox: IdsToolbox): Promise {\n const closurePath = await toolbox.fetch();\n toolbox.recordEvent(\"load_closure\");\n const { stdout } = await promisify(exec)(\n `cat \"${closurePath}\" | xz -d | nix-store --import`,\n );\n\n const paths = stdout.split(os.EOL);\n // Since the export is in reverse topologically sorted order, magic-nix-cache is always the penultimate entry in the list (the empty string left by split being the last).\n const last_path = paths.at(-2);\n return `${last_path}/bin/magic-nix-cache`;\n}\n\nfunction tailLog(daemonDir: string): Tail {\n const log = new Tail(path.join(daemonDir, \"daemon.log\"));\n core.debug(`tailing daemon.log...`);\n log.on(\"line\", (line) => {\n core.info(line);\n });\n return log;\n}\n\nasync function setUpAutoCache(toolbox: IdsToolbox): Promise {\n const tmpdir = process.env[\"RUNNER_TEMP\"] || os.tmpdir();\n const required_env = [\n \"ACTIONS_CACHE_URL\",\n \"ACTIONS_RUNTIME_URL\",\n \"ACTIONS_RUNTIME_TOKEN\",\n ];\n\n let anyMissing = false;\n for (const n of required_env) {\n if (!process.env.hasOwnProperty(n)) {\n anyMissing = true;\n core.warning(\n `Disabling automatic caching since required environment ${n} isn't available`,\n );\n }\n }\n\n if (anyMissing) {\n return;\n }\n\n core.debug(`GitHub Action Cache URL: ${process.env[\"ACTIONS_CACHE_URL\"]}`);\n\n const daemonDir = await fs.mkdtemp(path.join(tmpdir, \"magic-nix-cache-\"));\n\n let daemonBin: string;\n if (core.getInput(\"source-binary\")) {\n daemonBin = core.getInput(\"source-binary\");\n } else {\n daemonBin = await fetchAutoCacher(toolbox);\n }\n\n let runEnv;\n if (core.isDebug()) {\n runEnv = {\n RUST_LOG: \"trace,magic_nix_cache=debug,gha_cache=debug\",\n RUST_BACKTRACE: \"full\",\n ...process.env,\n };\n } else {\n runEnv = process.env;\n }\n\n const notifyPort = core.getInput(\"startup-notification-port\");\n\n const notifyPromise = new Promise>((resolveListening) => {\n const promise = new Promise(async (resolveQuit) => {\n const notifyServer = http.createServer((req, res) => {\n if (req.method === \"POST\" && req.url === \"/\") {\n core.debug(`Notify server shutting down.`);\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\"{}\");\n notifyServer.close(() => {\n resolveQuit();\n });\n }\n });\n\n notifyServer.listen(notifyPort, () => {\n core.debug(`Notify server running.`);\n resolveListening(promise);\n });\n });\n });\n\n // Start tailing the daemon log.\n const outputPath = `${daemonDir}/daemon.log`;\n const output = openSync(outputPath, \"a\");\n const log = tailLog(daemonDir);\n const netrc = await netrcPath();\n const nixConfPath = `${process.env[\"HOME\"]}/.config/nix/nix.conf`;\n\n const daemonCliFlags: string[] = [\n \"--startup-notification-url\",\n `http://127.0.0.1:${notifyPort}`,\n \"--listen\",\n core.getInput(\"listen\"),\n \"--upstream\",\n core.getInput(\"upstream-cache\"),\n \"--diagnostic-endpoint\",\n core.getInput(\"diagnostic-endpoint\"),\n \"--nix-conf\",\n nixConfPath,\n ]\n .concat(\n core.getBooleanInput(\"use-flakehub\")\n ? [\n \"--use-flakehub\",\n \"--flakehub-cache-server\",\n core.getInput(\"flakehub-cache-server\"),\n \"--flakehub-api-server\",\n core.getInput(\"flakehub-api-server\"),\n \"--flakehub-api-server-netrc\",\n netrc,\n \"--flakehub-flake-name\",\n core.getInput(\"flakehub-flake-name\"),\n ]\n : [],\n )\n .concat(core.getBooleanInput(\"use-gha-cache\") ? [\"--use-gha-cache\"] : []);\n\n const opts: SpawnOptions = {\n stdio: [\"ignore\", output, output],\n env: runEnv,\n detached: true,\n };\n\n // Display the final command for debugging purposes\n core.debug(\"Full daemon start command:\");\n core.debug(`${daemonBin} ${daemonCliFlags.join(\" \")}`);\n\n // Start the server. Once it is ready, it will notify us via the notification server.\n const daemon = spawn(daemonBin, daemonCliFlags, opts);\n\n const pidFile = path.join(daemonDir, \"daemon.pid\");\n await fs.writeFile(pidFile, `${daemon.pid}`);\n\n core.info(\"Waiting for magic-nix-cache to start...\");\n\n await new Promise((resolve, reject) => {\n notifyPromise\n // eslint-disable-next-line github/no-then\n .then((_value) => {\n resolve();\n })\n // eslint-disable-next-line github/no-then\n .catch((err) => {\n reject(new Error(`error in notifyPromise: ${err}`));\n });\n daemon.on(\"exit\", async (code, signal) => {\n if (signal) {\n reject(new Error(`Daemon was killed by signal ${signal}`));\n } else if (code) {\n reject(new Error(`Daemon exited with code ${code}`));\n } else {\n reject(new Error(`Daemon unexpectedly exited`));\n }\n });\n });\n\n daemon.unref();\n\n core.info(\"Launched Magic Nix Cache\");\n core.exportVariable(ENV_CACHE_DAEMONDIR, daemonDir);\n\n log.unwatch();\n}\n\nasync function notifyAutoCache(): Promise {\n const daemonDir = process.env[ENV_CACHE_DAEMONDIR];\n\n if (!daemonDir) {\n return;\n }\n\n try {\n core.debug(`Indicating workflow start`);\n const res: Response = await gotClient\n .post(`http://${core.getInput(\"listen\")}/api/workflow-start`)\n .json();\n core.debug(`back from post: ${res}`);\n } catch (e) {\n core.info(`Error marking the workflow as started:`);\n core.info(inspect(e));\n core.info(`Magic Nix Cache may not be running for this workflow.`);\n }\n}\n\nasync function netrcPath(): Promise {\n const expectedNetrcPath = path.join(\n process.env[\"RUNNER_TEMP\"] || os.tmpdir(),\n \"determinate-nix-installer-netrc\",\n );\n try {\n await fs.access(expectedNetrcPath);\n return expectedNetrcPath;\n } catch {\n // `nix-installer` was not used, the user may be registered with FlakeHub though.\n const destinedNetrcPath = path.join(\n process.env[\"RUNNER_TEMP\"] || os.tmpdir(),\n \"magic-nix-cache-netrc\",\n );\n try {\n await flakehub_login(destinedNetrcPath);\n } catch (e) {\n core.info(\"FlakeHub cache disabled.\");\n core.debug(`Error while logging into FlakeHub: ${e}`);\n }\n return destinedNetrcPath;\n }\n}\n\nasync function flakehub_login(netrc: string): Promise {\n const jwt = await core.getIDToken(\"api.flakehub.com\");\n\n await fs.writeFile(\n netrc,\n [\n `machine api.flakehub.com login flakehub password ${jwt}`,\n `machine flakehub.com login flakehub password ${jwt}`,\n `machine cache.flakehub.com login flakehub password ${jwt}`,\n ].join(\"\\n\"),\n );\n\n core.info(\"Logged in to FlakeHub.\");\n}\n\nasync function tearDownAutoCache(): Promise {\n const daemonDir = process.env[ENV_CACHE_DAEMONDIR];\n\n if (!daemonDir) {\n core.debug(\"magic-nix-cache not started - Skipping\");\n return;\n }\n\n const pidFile = path.join(daemonDir, \"daemon.pid\");\n const pid = parseInt(await fs.readFile(pidFile, { encoding: \"ascii\" }));\n core.debug(`found daemon pid: ${pid}`);\n if (!pid) {\n throw new Error(\"magic-nix-cache did not start successfully\");\n }\n\n const log = tailLog(daemonDir);\n\n try {\n core.debug(`about to post to localhost`);\n const res: Response = await gotClient\n .post(`http://${core.getInput(\"listen\")}/api/workflow-finish`)\n .json();\n core.debug(`back from post: ${res}`);\n } finally {\n core.debug(`unwatching the daemon log`);\n log.unwatch();\n }\n\n core.debug(`killing`);\n try {\n process.kill(pid, \"SIGTERM\");\n } catch (e) {\n if (typeof e === \"object\" && e && \"code\" in e && e.code !== \"ESRCH\") {\n throw e;\n }\n } finally {\n if (core.isDebug()) {\n core.info(\"Entire log:\");\n const entireLog = readFileSync(path.join(daemonDir, \"daemon.log\"));\n core.info(entireLog.toString());\n }\n }\n}\n\nconst idslib = new IdsToolbox({\n name: \"magic-nix-cache\",\n fetchStyle: \"gh-env-style\",\n idsProjectName: \"magic-nix-cache-closure\",\n requireNix: \"warn\",\n});\n\nidslib.onMain(async () => {\n await setUpAutoCache(idslib);\n await notifyAutoCache();\n});\nidslib.onPost(async () => {\n await tearDownAutoCache();\n});\n\nidslib.execute();\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,OAAO,YAA0B;AAC1C,SAAS,UAAU,oBAAoB;AACvC,SAAS,SAAS,iBAAiB;AACnC,YAAY,UAAU;AAEtB,YAAY,UAAU;AACtB,SAAS,YAAY;AACrB,OAAO,SAAS;AAChB,SAAS,kBAAkB;AAE3B,IAAM,sBAAsB;AAE5B,IAAM,YAAY,IAAI,OAAO;AAAA,EAC3B,OAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS,CAAC,QAAQ,OAAO,OAAO,QAAQ,UAAU,WAAW,OAAO;AAAA,EACtE;AAAA,EACA,OAAO;AAAA,IACL,aAAa;AAAA,MACX,CAAC,OAAO,eAAe;AACrB,QAAK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MAAM,QAAQ,SAAS;AAE7B,MAAI;AACF,IAAK,WAAM,4BAA4B;AACvC,UAAM,MAAgB,MAAM,UACzB,KAAK,UAAe,cAAS,QAAQ,CAAC,sBAAsB,EAC5D,KAAK;AACR,IAAK,WAAM,mBAAmB,GAAG,EAAE;AAAA,EACrC,UAAE;AACA,IAAK,WAAM,2BAA2B;AACtC,QAAI,QAAQ;AAAA,EACd;AAEA,EAAK,WAAM,SAAS;AACpB,MAAI;AACF,YAAQ,KAAK,KAAK,SAAS;AAAA,EAC7B,SAAS,GAAG;AACV,QAAI,OAAO,MAAM,YAAY,KAAK,UAAU,KAAK,EAAE,SAAS,SAAS;AACnE,YAAM;AAAA,IACR;AAAA,EACF,UAAE;AACA,QAAS,aAAQ,GAAG;AAClB,MAAK,UAAK,aAAa;AACvB,YAAM,YAAY,aAAkB,UAAK,WAAW,YAAY,CAAC;AACjE,MAAK,UAAK,UAAU,SAAS,CAAC;AAAA,IAChC;AAAA,EACF;AACF;AAEA,IAAM,SAAS,IAAI,WAAW;AAAA,EAC5B,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,YAAY;AACd,CAAC;AAED,OAAO,OAAO,YAAY;AACxB,QAAM,eAAe,MAAM;AAC3B,QAAM,gBAAgB;AACxB,CAAC;AACD,OAAO,OAAO,YAAY;AACxB,QAAM,kBAAkB;AAC1B,CAAC;AAED,OAAO,QAAQ;","names":["tmpdir"]} \ No newline at end of file diff --git a/dist/main.js b/dist/main.js deleted file mode 100644 index 87d68a3..0000000 --- a/dist/main.js +++ /dev/null @@ -1,261 +0,0 @@ -// src/main.ts -import * as fs from "node:fs/promises"; -import * as os from "node:os"; -import * as path from "node:path"; -import { spawn, exec } from "node:child_process"; -import { openSync, readFileSync } from "node:fs"; -import { inspect, promisify } from "node:util"; -import * as http from "http"; -import * as core from "@actions/core"; -import { Tail } from "tail"; -import got from "got"; -import { IdsToolbox } from "detsys-ts"; -var ENV_CACHE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR"; -var gotClient = got.extend({ - retry: { - limit: 1, - methods: ["POST", "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "TRACE"] - }, - hooks: { - beforeRetry: [ - (error, retryCount) => { - core.info(`Retrying after error ${error.code}, retry #: ${retryCount}`); - } - ] - } -}); -async function fetchAutoCacher(toolbox) { - const closurePath = await toolbox.fetch(); - toolbox.recordEvent("load_closure"); - const { stdout } = await promisify(exec)( - `cat "${closurePath}" | xz -d | nix-store --import` - ); - const paths = stdout.split(os.EOL); - const last_path = paths.at(-2); - return `${last_path}/bin/magic-nix-cache`; -} -function tailLog(daemonDir) { - const log = new Tail(path.join(daemonDir, "daemon.log")); - core.debug(`tailing daemon.log...`); - log.on("line", (line) => { - core.info(line); - }); - return log; -} -async function setUpAutoCache(toolbox) { - const tmpdir2 = process.env["RUNNER_TEMP"] || os.tmpdir(); - const required_env = [ - "ACTIONS_CACHE_URL", - "ACTIONS_RUNTIME_URL", - "ACTIONS_RUNTIME_TOKEN" - ]; - let anyMissing = false; - for (const n of required_env) { - if (!process.env.hasOwnProperty(n)) { - anyMissing = true; - core.warning( - `Disabling automatic caching since required environment ${n} isn't available` - ); - } - } - if (anyMissing) { - return; - } - core.debug(`GitHub Action Cache URL: ${process.env["ACTIONS_CACHE_URL"]}`); - const daemonDir = await fs.mkdtemp(path.join(tmpdir2, "magic-nix-cache-")); - let daemonBin; - if (core.getInput("source-binary")) { - daemonBin = core.getInput("source-binary"); - } else { - daemonBin = await fetchAutoCacher(toolbox); - } - let runEnv; - if (core.isDebug()) { - runEnv = { - RUST_LOG: "trace,magic_nix_cache=debug,gha_cache=debug", - RUST_BACKTRACE: "full", - ...process.env - }; - } else { - runEnv = process.env; - } - const notifyPort = core.getInput("startup-notification-port"); - const notifyPromise = new Promise((resolveListening) => { - const promise = new Promise(async (resolveQuit) => { - const notifyServer = http.createServer((req, res) => { - if (req.method === "POST" && req.url === "/") { - core.debug(`Notify server shutting down.`); - res.writeHead(200, { "Content-Type": "application/json" }); - res.end("{}"); - notifyServer.close(() => { - resolveQuit(); - }); - } - }); - notifyServer.listen(notifyPort, () => { - core.debug(`Notify server running.`); - resolveListening(promise); - }); - }); - }); - const outputPath = `${daemonDir}/daemon.log`; - const output = openSync(outputPath, "a"); - const log = tailLog(daemonDir); - const netrc = await netrcPath(); - const nixConfPath = `${process.env["HOME"]}/.config/nix/nix.conf`; - const daemonCliFlags = [ - "--startup-notification-url", - `http://127.0.0.1:${notifyPort}`, - "--listen", - core.getInput("listen"), - "--upstream", - core.getInput("upstream-cache"), - "--diagnostic-endpoint", - core.getInput("diagnostic-endpoint"), - "--nix-conf", - nixConfPath - ].concat( - core.getBooleanInput("use-flakehub") ? [ - "--use-flakehub", - "--flakehub-cache-server", - core.getInput("flakehub-cache-server"), - "--flakehub-api-server", - core.getInput("flakehub-api-server"), - "--flakehub-api-server-netrc", - netrc, - "--flakehub-flake-name", - core.getInput("flakehub-flake-name") - ] : [] - ).concat(core.getBooleanInput("use-gha-cache") ? ["--use-gha-cache"] : []); - const opts = { - stdio: ["ignore", output, output], - env: runEnv, - detached: true - }; - core.debug("Full daemon start command:"); - core.debug(`${daemonBin} ${daemonCliFlags.join(" ")}`); - const daemon = spawn(daemonBin, daemonCliFlags, opts); - const pidFile = path.join(daemonDir, "daemon.pid"); - await fs.writeFile(pidFile, `${daemon.pid}`); - core.info("Waiting for magic-nix-cache to start..."); - await new Promise((resolve, reject) => { - notifyPromise.then((_value) => { - resolve(); - }).catch((err) => { - reject(new Error(`error in notifyPromise: ${err}`)); - }); - daemon.on("exit", async (code, signal) => { - if (signal) { - reject(new Error(`Daemon was killed by signal ${signal}`)); - } else if (code) { - reject(new Error(`Daemon exited with code ${code}`)); - } else { - reject(new Error(`Daemon unexpectedly exited`)); - } - }); - }); - daemon.unref(); - core.info("Launched Magic Nix Cache"); - core.exportVariable(ENV_CACHE_DAEMONDIR, daemonDir); - log.unwatch(); -} -async function notifyAutoCache() { - const daemonDir = process.env[ENV_CACHE_DAEMONDIR]; - if (!daemonDir) { - return; - } - try { - core.debug(`Indicating workflow start`); - const res = await gotClient.post(`http://${core.getInput("listen")}/api/workflow-start`).json(); - core.debug(`back from post: ${res}`); - } catch (e) { - core.info(`Error marking the workflow as started:`); - core.info(inspect(e)); - core.info(`Magic Nix Cache may not be running for this workflow.`); - } -} -async function netrcPath() { - const expectedNetrcPath = path.join( - process.env["RUNNER_TEMP"] || os.tmpdir(), - "determinate-nix-installer-netrc" - ); - try { - await fs.access(expectedNetrcPath); - return expectedNetrcPath; - } catch { - const destinedNetrcPath = path.join( - process.env["RUNNER_TEMP"] || os.tmpdir(), - "magic-nix-cache-netrc" - ); - try { - await flakehub_login(destinedNetrcPath); - } catch (e) { - core.info("FlakeHub cache disabled."); - core.debug(`Error while logging into FlakeHub: ${e}`); - } - return destinedNetrcPath; - } -} -async function flakehub_login(netrc) { - const jwt = await core.getIDToken("api.flakehub.com"); - await fs.writeFile( - netrc, - [ - `machine api.flakehub.com login flakehub password ${jwt}`, - `machine flakehub.com login flakehub password ${jwt}`, - `machine cache.flakehub.com login flakehub password ${jwt}` - ].join("\n") - ); - core.info("Logged in to FlakeHub."); -} -async function tearDownAutoCache() { - const daemonDir = process.env[ENV_CACHE_DAEMONDIR]; - if (!daemonDir) { - core.debug("magic-nix-cache not started - Skipping"); - return; - } - const pidFile = path.join(daemonDir, "daemon.pid"); - const pid = parseInt(await fs.readFile(pidFile, { encoding: "ascii" })); - core.debug(`found daemon pid: ${pid}`); - if (!pid) { - throw new Error("magic-nix-cache did not start successfully"); - } - const log = tailLog(daemonDir); - try { - core.debug(`about to post to localhost`); - const res = await gotClient.post(`http://${core.getInput("listen")}/api/workflow-finish`).json(); - core.debug(`back from post: ${res}`); - } finally { - core.debug(`unwatching the daemon log`); - log.unwatch(); - } - core.debug(`killing`); - try { - process.kill(pid, "SIGTERM"); - } catch (e) { - if (typeof e === "object" && e && "code" in e && e.code !== "ESRCH") { - throw e; - } - } finally { - if (core.isDebug()) { - core.info("Entire log:"); - const entireLog = readFileSync(path.join(daemonDir, "daemon.log")); - core.info(entireLog.toString()); - } - } -} -var idslib = new IdsToolbox({ - name: "magic-nix-cache", - fetchStyle: "gh-env-style", - idsProjectName: "magic-nix-cache-closure", - requireNix: "warn" -}); -idslib.onMain(async () => { - await setUpAutoCache(idslib); - await notifyAutoCache(); -}); -idslib.onPost(async () => { - await tearDownAutoCache(); -}); -idslib.execute(); -//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/dist/main.js.map b/dist/main.js.map deleted file mode 100644 index ef0d905..0000000 --- a/dist/main.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { spawn, exec, SpawnOptions } from \"node:child_process\";\nimport { openSync, readFileSync } from \"node:fs\";\nimport { inspect, promisify } from \"node:util\";\nimport * as http from \"http\";\n\nimport * as core from \"@actions/core\";\nimport { Tail } from \"tail\";\nimport got from \"got\";\nimport { IdsToolbox } from \"detsys-ts\";\n\nconst ENV_CACHE_DAEMONDIR = \"MAGIC_NIX_CACHE_DAEMONDIR\";\n\nconst gotClient = got.extend({\n retry: {\n limit: 1,\n methods: [\"POST\", \"GET\", \"PUT\", \"HEAD\", \"DELETE\", \"OPTIONS\", \"TRACE\"],\n },\n hooks: {\n beforeRetry: [\n (error, retryCount) => {\n core.info(`Retrying after error ${error.code}, retry #: ${retryCount}`);\n },\n ],\n },\n});\n\nasync function fetchAutoCacher(toolbox: IdsToolbox): Promise {\n const closurePath = await toolbox.fetch();\n toolbox.recordEvent(\"load_closure\");\n const { stdout } = await promisify(exec)(\n `cat \"${closurePath}\" | xz -d | nix-store --import`,\n );\n\n const paths = stdout.split(os.EOL);\n // Since the export is in reverse topologically sorted order, magic-nix-cache is always the penultimate entry in the list (the empty string left by split being the last).\n const last_path = paths.at(-2);\n return `${last_path}/bin/magic-nix-cache`;\n}\n\nfunction tailLog(daemonDir: string): Tail {\n const log = new Tail(path.join(daemonDir, \"daemon.log\"));\n core.debug(`tailing daemon.log...`);\n log.on(\"line\", (line) => {\n core.info(line);\n });\n return log;\n}\n\nasync function setUpAutoCache(toolbox: IdsToolbox): Promise {\n const tmpdir = process.env[\"RUNNER_TEMP\"] || os.tmpdir();\n const required_env = [\n \"ACTIONS_CACHE_URL\",\n \"ACTIONS_RUNTIME_URL\",\n \"ACTIONS_RUNTIME_TOKEN\",\n ];\n\n let anyMissing = false;\n for (const n of required_env) {\n if (!process.env.hasOwnProperty(n)) {\n anyMissing = true;\n core.warning(\n `Disabling automatic caching since required environment ${n} isn't available`,\n );\n }\n }\n\n if (anyMissing) {\n return;\n }\n\n core.debug(`GitHub Action Cache URL: ${process.env[\"ACTIONS_CACHE_URL\"]}`);\n\n const daemonDir = await fs.mkdtemp(path.join(tmpdir, \"magic-nix-cache-\"));\n\n let daemonBin: string;\n if (core.getInput(\"source-binary\")) {\n daemonBin = core.getInput(\"source-binary\");\n } else {\n daemonBin = await fetchAutoCacher(toolbox);\n }\n\n let runEnv;\n if (core.isDebug()) {\n runEnv = {\n RUST_LOG: \"trace,magic_nix_cache=debug,gha_cache=debug\",\n RUST_BACKTRACE: \"full\",\n ...process.env,\n };\n } else {\n runEnv = process.env;\n }\n\n const notifyPort = core.getInput(\"startup-notification-port\");\n\n const notifyPromise = new Promise>((resolveListening) => {\n const promise = new Promise(async (resolveQuit) => {\n const notifyServer = http.createServer((req, res) => {\n if (req.method === \"POST\" && req.url === \"/\") {\n core.debug(`Notify server shutting down.`);\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\"{}\");\n notifyServer.close(() => {\n resolveQuit();\n });\n }\n });\n\n notifyServer.listen(notifyPort, () => {\n core.debug(`Notify server running.`);\n resolveListening(promise);\n });\n });\n });\n\n // Start tailing the daemon log.\n const outputPath = `${daemonDir}/daemon.log`;\n const output = openSync(outputPath, \"a\");\n const log = tailLog(daemonDir);\n const netrc = await netrcPath();\n const nixConfPath = `${process.env[\"HOME\"]}/.config/nix/nix.conf`;\n\n const daemonCliFlags: string[] = [\n \"--startup-notification-url\",\n `http://127.0.0.1:${notifyPort}`,\n \"--listen\",\n core.getInput(\"listen\"),\n \"--upstream\",\n core.getInput(\"upstream-cache\"),\n \"--diagnostic-endpoint\",\n core.getInput(\"diagnostic-endpoint\"),\n \"--nix-conf\",\n nixConfPath,\n ]\n .concat(\n core.getBooleanInput(\"use-flakehub\")\n ? [\n \"--use-flakehub\",\n \"--flakehub-cache-server\",\n core.getInput(\"flakehub-cache-server\"),\n \"--flakehub-api-server\",\n core.getInput(\"flakehub-api-server\"),\n \"--flakehub-api-server-netrc\",\n netrc,\n \"--flakehub-flake-name\",\n core.getInput(\"flakehub-flake-name\"),\n ]\n : [],\n )\n .concat(core.getBooleanInput(\"use-gha-cache\") ? [\"--use-gha-cache\"] : []);\n\n const opts: SpawnOptions = {\n stdio: [\"ignore\", output, output],\n env: runEnv,\n detached: true,\n };\n\n // Display the final command for debugging purposes\n core.debug(\"Full daemon start command:\");\n core.debug(`${daemonBin} ${daemonCliFlags.join(\" \")}`);\n\n // Start the server. Once it is ready, it will notify us via the notification server.\n const daemon = spawn(daemonBin, daemonCliFlags, opts);\n\n const pidFile = path.join(daemonDir, \"daemon.pid\");\n await fs.writeFile(pidFile, `${daemon.pid}`);\n\n core.info(\"Waiting for magic-nix-cache to start...\");\n\n await new Promise((resolve, reject) => {\n notifyPromise\n // eslint-disable-next-line github/no-then\n .then((_value) => {\n resolve();\n })\n // eslint-disable-next-line github/no-then\n .catch((err) => {\n reject(new Error(`error in notifyPromise: ${err}`));\n });\n daemon.on(\"exit\", async (code, signal) => {\n if (signal) {\n reject(new Error(`Daemon was killed by signal ${signal}`));\n } else if (code) {\n reject(new Error(`Daemon exited with code ${code}`));\n } else {\n reject(new Error(`Daemon unexpectedly exited`));\n }\n });\n });\n\n daemon.unref();\n\n core.info(\"Launched Magic Nix Cache\");\n core.exportVariable(ENV_CACHE_DAEMONDIR, daemonDir);\n\n log.unwatch();\n}\n\nasync function notifyAutoCache(): Promise {\n const daemonDir = process.env[ENV_CACHE_DAEMONDIR];\n\n if (!daemonDir) {\n return;\n }\n\n try {\n core.debug(`Indicating workflow start`);\n const res: Response = await gotClient\n .post(`http://${core.getInput(\"listen\")}/api/workflow-start`)\n .json();\n core.debug(`back from post: ${res}`);\n } catch (e) {\n core.info(`Error marking the workflow as started:`);\n core.info(inspect(e));\n core.info(`Magic Nix Cache may not be running for this workflow.`);\n }\n}\n\nasync function netrcPath(): Promise {\n const expectedNetrcPath = path.join(\n process.env[\"RUNNER_TEMP\"] || os.tmpdir(),\n \"determinate-nix-installer-netrc\",\n );\n try {\n await fs.access(expectedNetrcPath);\n return expectedNetrcPath;\n } catch {\n // `nix-installer` was not used, the user may be registered with FlakeHub though.\n const destinedNetrcPath = path.join(\n process.env[\"RUNNER_TEMP\"] || os.tmpdir(),\n \"magic-nix-cache-netrc\",\n );\n try {\n await flakehub_login(destinedNetrcPath);\n } catch (e) {\n core.info(\"FlakeHub cache disabled.\");\n core.debug(`Error while logging into FlakeHub: ${e}`);\n }\n return destinedNetrcPath;\n }\n}\n\nasync function flakehub_login(netrc: string): Promise {\n const jwt = await core.getIDToken(\"api.flakehub.com\");\n\n await fs.writeFile(\n netrc,\n [\n `machine api.flakehub.com login flakehub password ${jwt}`,\n `machine flakehub.com login flakehub password ${jwt}`,\n `machine cache.flakehub.com login flakehub password ${jwt}`,\n ].join(\"\\n\"),\n );\n\n core.info(\"Logged in to FlakeHub.\");\n}\n\nasync function tearDownAutoCache(): Promise {\n const daemonDir = process.env[ENV_CACHE_DAEMONDIR];\n\n if (!daemonDir) {\n core.debug(\"magic-nix-cache not started - Skipping\");\n return;\n }\n\n const pidFile = path.join(daemonDir, \"daemon.pid\");\n const pid = parseInt(await fs.readFile(pidFile, { encoding: \"ascii\" }));\n core.debug(`found daemon pid: ${pid}`);\n if (!pid) {\n throw new Error(\"magic-nix-cache did not start successfully\");\n }\n\n const log = tailLog(daemonDir);\n\n try {\n core.debug(`about to post to localhost`);\n const res: Response = await gotClient\n .post(`http://${core.getInput(\"listen\")}/api/workflow-finish`)\n .json();\n core.debug(`back from post: ${res}`);\n } finally {\n core.debug(`unwatching the daemon log`);\n log.unwatch();\n }\n\n core.debug(`killing`);\n try {\n process.kill(pid, \"SIGTERM\");\n } catch (e) {\n if (typeof e === \"object\" && e && \"code\" in e && e.code !== \"ESRCH\") {\n throw e;\n }\n } finally {\n if (core.isDebug()) {\n core.info(\"Entire log:\");\n const entireLog = readFileSync(path.join(daemonDir, \"daemon.log\"));\n core.info(entireLog.toString());\n }\n }\n}\n\nconst idslib = new IdsToolbox({\n name: \"magic-nix-cache\",\n fetchStyle: \"gh-env-style\",\n idsProjectName: \"magic-nix-cache-closure\",\n requireNix: \"warn\",\n});\n\nidslib.onMain(async () => {\n await setUpAutoCache(idslib);\n await notifyAutoCache();\n});\nidslib.onPost(async () => {\n await tearDownAutoCache();\n});\n\nidslib.execute();\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,OAAO,YAA0B;AAC1C,SAAS,UAAU,oBAAoB;AACvC,SAAS,SAAS,iBAAiB;AACnC,YAAY,UAAU;AAEtB,YAAY,UAAU;AACtB,SAAS,YAAY;AACrB,OAAO,SAAS;AAChB,SAAS,kBAAkB;AAE3B,IAAM,sBAAsB;AAE5B,IAAM,YAAY,IAAI,OAAO;AAAA,EAC3B,OAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS,CAAC,QAAQ,OAAO,OAAO,QAAQ,UAAU,WAAW,OAAO;AAAA,EACtE;AAAA,EACA,OAAO;AAAA,IACL,aAAa;AAAA,MACX,CAAC,OAAO,eAAe;AACrB,QAAK,UAAK,wBAAwB,MAAM,IAAI,cAAc,UAAU,EAAE;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,eAAe,gBAAgB,SA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,CAAC,sBAAsB,EAC5D,KAAK;AACR,IAAK,WAAM,mBAAmB,GAAG,EAAE;AAAA,EACrC,UAAE;AACA,IAAK,WAAM,2BAA2B;AACtC,QAAI,QAAQ;AAAA,EACd;AAEA,EAAK,WAAM,SAAS;AACpB,MAAI;AACF,YAAQ,KAAK,KAAK,SAAS;AAAA,EAC7B,SAAS,GAAG;AACV,QAAI,OAAO,MAAM,YAAY,KAAK,UAAU,KAAK,EAAE,SAAS,SAAS;AACnE,YAAM;AAAA,IACR;AAAA,EACF,UAAE;AACA,QAAS,aAAQ,GAAG;AAClB,MAAK,UAAK,aAAa;AACvB,YAAM,YAAY,aAAkB,UAAK,WAAW,YAAY,CAAC;AACjE,MAAK,UAAK,UAAU,SAAS,CAAC;AAAA,IAChC;AAAA,EACF;AACF;AAEA,IAAM,SAAS,IAAI,WAAW;AAAA,EAC5B,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,YAAY;AACd,CAAC;AAED,OAAO,OAAO,YAAY;AACxB,QAAM,eAAe,MAAM;AAC3B,QAAM,gBAAgB;AACxB,CAAC;AACD,OAAO,OAAO,YAAY;AACxB,QAAM,kBAAkB;AAC1B,CAAC;AAED,OAAO,QAAQ;","names":["tmpdir"]} \ No newline at end of file diff --git a/package.json b/package.json index a49188c..1df1938 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "tsup", "format": "prettier --write .", "lint": "eslint src/**/*.ts", - "package": "ncc build ./dist/main.js", + "package": "ncc build", "all": "pnpm run format && pnpm run lint && pnpm run build && pnpm run package" }, "repository": { diff --git a/src/main.ts b/src/index.ts similarity index 100% rename from src/main.ts rename to src/index.ts diff --git a/tsup.config.ts b/tsup.config.ts index d9a29e5..14b9b14 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from "tsup"; export default defineConfig({ name: "detsys-ts", - entry: ["src/main.ts"], + entry: ["src/index.ts"], format: ["esm"], target: "node20", bundle: true,