mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-27 01:30:35 +01:00
Use built-in closure unpacking
This commit is contained in:
parent
e1ac823346
commit
6e56af9a6e
3 changed files with 7 additions and 30 deletions
13
dist/index.js
generated
vendored
13
dist/index.js
generated
vendored
|
@ -95169,7 +95169,6 @@ async function flakeHubLogin(netrc) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
var STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
var STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
var STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
var STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
||||||
|
@ -95272,7 +95271,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
`GitHub Action Cache URL: ${process.env["ACTIONS_CACHE_URL"]}`
|
`GitHub Action Cache URL: ${process.env["ACTIONS_CACHE_URL"]}`
|
||||||
);
|
);
|
||||||
const sourceBinary = inputs_exports.getStringOrNull("source-binary");
|
const sourceBinary = inputs_exports.getStringOrNull("source-binary");
|
||||||
const daemonBin = sourceBinary !== null ? sourceBinary : await this.fetchAutoCacher();
|
const daemonBin = sourceBinary !== null ? sourceBinary : await this.unpackClosure("magic-nix-cache");
|
||||||
let runEnv;
|
let runEnv;
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
runEnv = {
|
runEnv = {
|
||||||
|
@ -95374,16 +95373,6 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
core.info("Launched Magic Nix Cache");
|
core.info("Launched Magic Nix Cache");
|
||||||
log.unwatch();
|
log.unwatch();
|
||||||
}
|
}
|
||||||
async fetchAutoCacher() {
|
|
||||||
const closurePath = await this.fetchExecutable();
|
|
||||||
this.recordEvent("load_closure");
|
|
||||||
const { stdout } = await (0,external_node_util_.promisify)(external_node_child_process_namespaceObject.exec)(
|
|
||||||
`cat "${closurePath}" | xz -d | nix-store --import`
|
|
||||||
);
|
|
||||||
const paths = stdout.split(external_node_os_.EOL);
|
|
||||||
const lastPath = paths.at(-2);
|
|
||||||
return `${lastPath}/bin/magic-nix-cache`;
|
|
||||||
}
|
|
||||||
async notifyAutoCache() {
|
async notifyAutoCache() {
|
||||||
if (!this.daemonStarted) {
|
if (!this.daemonStarted) {
|
||||||
core.debug("magic-nix-cache not started - Skipping");
|
core.debug("magic-nix-cache not started - Skipping");
|
||||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
22
src/index.ts
22
src/index.ts
|
@ -3,12 +3,11 @@ import * as actionsCore from "@actions/core";
|
||||||
import { DetSysAction, inputs } from "detsys-ts";
|
import { DetSysAction, inputs } from "detsys-ts";
|
||||||
import got, { Got, Response } from "got";
|
import got, { Got, Response } from "got";
|
||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
import { SpawnOptions, exec, spawn } from "node:child_process";
|
import { SpawnOptions, spawn } from "node:child_process";
|
||||||
import { mkdirSync, openSync, readFileSync } from "node:fs";
|
import { mkdirSync, openSync, readFileSync } from "node:fs";
|
||||||
import * as fs from "node:fs/promises";
|
import * as fs from "node:fs/promises";
|
||||||
import * as os from "node:os";
|
|
||||||
import * as path from "node:path";
|
import * as path from "node:path";
|
||||||
import { inspect, promisify } from "node:util";
|
import { inspect } from "node:util";
|
||||||
|
|
||||||
// The ENV_DAEMON_DIR is intended to determine if we "own" the daemon or not,
|
// The ENV_DAEMON_DIR is intended to determine if we "own" the daemon or not,
|
||||||
// in the case that a user has put the magic nix cache into their workflow
|
// in the case that a user has put the magic nix cache into their workflow
|
||||||
|
@ -147,7 +146,9 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
|
|
||||||
const sourceBinary = inputs.getStringOrNull("source-binary");
|
const sourceBinary = inputs.getStringOrNull("source-binary");
|
||||||
const daemonBin =
|
const daemonBin =
|
||||||
sourceBinary !== null ? sourceBinary : await this.fetchAutoCacher();
|
sourceBinary !== null
|
||||||
|
? sourceBinary
|
||||||
|
: await this.unpackClosure("magic-nix-cache");
|
||||||
|
|
||||||
let runEnv;
|
let runEnv;
|
||||||
if (actionsCore.isDebug()) {
|
if (actionsCore.isDebug()) {
|
||||||
|
@ -277,19 +278,6 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
log.unwatch();
|
log.unwatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async fetchAutoCacher(): Promise<string> {
|
|
||||||
const closurePath = await this.fetchExecutable();
|
|
||||||
this.recordEvent("load_closure");
|
|
||||||
const { stdout } = await promisify(exec)(
|
|
||||||
`cat "${closurePath}" | xz -d | nix-store --import`,
|
|
||||||
);
|
|
||||||
|
|
||||||
const paths = stdout.split(os.EOL);
|
|
||||||
// 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).
|
|
||||||
const lastPath = paths.at(-2);
|
|
||||||
return `${lastPath}/bin/magic-nix-cache`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async notifyAutoCache(): Promise<void> {
|
async notifyAutoCache(): Promise<void> {
|
||||||
if (!this.daemonStarted) {
|
if (!this.daemonStarted) {
|
||||||
actionsCore.debug("magic-nix-cache not started - Skipping");
|
actionsCore.debug("magic-nix-cache not started - Skipping");
|
||||||
|
|
Loading…
Reference in a new issue