mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-26 01:12:17 +01:00
Add store diff fact
This commit is contained in:
parent
cc5cb2a8e5
commit
a31b1826d0
3 changed files with 30 additions and 16 deletions
26
dist/index.js
generated
vendored
26
dist/index.js
generated
vendored
|
@ -94066,7 +94066,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
|
||||||
const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
|
const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
|
||||||
;// CONCATENATED MODULE: external "node:zlib"
|
;// CONCATENATED MODULE: external "node:zlib"
|
||||||
const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:zlib");
|
const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:zlib");
|
||||||
;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@a089656286a58dc6767247181b5280826f20473a_q6benjgi5pgerrbnqocqupyoxq/node_modules/detsys-ts/dist/index.js
|
;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@848cedfa44c31ae5ed7995350bb2707b9422840e_heluh4h342h2muwandvhzbsvpi/node_modules/detsys-ts/dist/index.js
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __export = (target, all) => {
|
var __export = (target, all) => {
|
||||||
for (var name in all)
|
for (var name in all)
|
||||||
|
@ -94528,6 +94528,7 @@ var EVENT_ARTIFACT_CACHE_HIT = "artifact_cache_hit";
|
||||||
var EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss";
|
var EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss";
|
||||||
var EVENT_ARTIFACT_CACHE_PERSIST = "artifact_cache_persist";
|
var EVENT_ARTIFACT_CACHE_PERSIST = "artifact_cache_persist";
|
||||||
var EVENT_PREFLIGHT_REQUIRE_NIX_DENIED = "preflight-require-nix-denied";
|
var EVENT_PREFLIGHT_REQUIRE_NIX_DENIED = "preflight-require-nix-denied";
|
||||||
|
var FACT_ARTIFACT_FETCHED_FROM_CACHE = "artifact_fetched_from_cache";
|
||||||
var FACT_ENDED_WITH_EXCEPTION = "ended_with_exception";
|
var FACT_ENDED_WITH_EXCEPTION = "ended_with_exception";
|
||||||
var FACT_FINAL_EXCEPTION = "final_exception";
|
var FACT_FINAL_EXCEPTION = "final_exception";
|
||||||
var FACT_OS = "$os";
|
var FACT_OS = "$os";
|
||||||
|
@ -94754,8 +94755,11 @@ var DetSysAction = class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fetch an artifact, such as a tarball, from the URL determined by the
|
* Fetch an artifact, such as a tarball, from the location determined by the
|
||||||
* `source-*` inputs.
|
* `source-*` inputs. If `source-binary` is specified, this will return a path
|
||||||
|
* to a binary on disk; otherwise, the artifact will be downloaded from the
|
||||||
|
* URL determined by the other `source-*` inputs (`source-url`, `source-pr`,
|
||||||
|
* etc.).
|
||||||
*/
|
*/
|
||||||
async fetchArtifact() {
|
async fetchArtifact() {
|
||||||
const sourceBinary = getStringOrNull("source-binary");
|
const sourceBinary = getStringOrNull("source-binary");
|
||||||
|
@ -94783,12 +94787,12 @@ var DetSysAction = class {
|
||||||
);
|
);
|
||||||
const cached = await this.getCachedVersion(v);
|
const cached = await this.getCachedVersion(v);
|
||||||
if (cached) {
|
if (cached) {
|
||||||
this.facts["artifact_fetched_from_cache"] = true;
|
this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = true;
|
||||||
core.debug(`Tool cache hit.`);
|
core.debug(`Tool cache hit.`);
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.facts["artifact_fetched_from_cache"] = false;
|
this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = false;
|
||||||
core.debug(
|
core.debug(
|
||||||
`No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`
|
`No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`
|
||||||
);
|
);
|
||||||
|
@ -95165,6 +95169,9 @@ async function flakeHubLogin(netrc) {
|
||||||
|
|
||||||
|
|
||||||
var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
|
var FACT_AUTHENTICATED_ENV = "authenticated_env";
|
||||||
|
var FACT_DIFF_STORE = "diff_store";
|
||||||
|
var FACT_NOOP_MODE = "noop_mode";
|
||||||
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";
|
||||||
var STARTED_HINT = "true";
|
var STARTED_HINT = "true";
|
||||||
|
@ -95180,6 +95187,8 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
requireNix: "warn"
|
requireNix: "warn"
|
||||||
});
|
});
|
||||||
this.hostAndPort = inputs_exports.getString("listen");
|
this.hostAndPort = inputs_exports.getString("listen");
|
||||||
|
this.diffStore = inputs_exports.getBool("diff-store");
|
||||||
|
this.addFact(FACT_DIFF_STORE, this.diffStore);
|
||||||
this.httpClient = got_dist_source.extend({
|
this.httpClient = got_dist_source.extend({
|
||||||
retry: {
|
retry: {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
@ -95209,7 +95218,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
} else {
|
} else {
|
||||||
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
||||||
}
|
}
|
||||||
this.addFact("noop_mode", this.noopMode);
|
this.addFact(FACT_NOOP_MODE, this.noopMode);
|
||||||
this.stapleFile("daemon.log", external_node_path_namespaceObject.join(this.daemonDir, "daemon.log"));
|
this.stapleFile("daemon.log", external_node_path_namespaceObject.join(this.daemonDir, "daemon.log"));
|
||||||
}
|
}
|
||||||
async main() {
|
async main() {
|
||||||
|
@ -95254,7 +95263,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.addFact("authenticated_env", !anyMissing);
|
this.addFact(FACT_AUTHENTICATED_ENV, !anyMissing);
|
||||||
if (anyMissing) {
|
if (anyMissing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95307,7 +95316,6 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
const flakeHubApiServer = inputs_exports.getString("flakehub-api-server");
|
const flakeHubApiServer = inputs_exports.getString("flakehub-api-server");
|
||||||
const flakeHubFlakeName = inputs_exports.getString("flakehub-flake-name");
|
const flakeHubFlakeName = inputs_exports.getString("flakehub-flake-name");
|
||||||
const useGhaCache = inputs_exports.getBool("use-gha-cache");
|
const useGhaCache = inputs_exports.getBool("use-gha-cache");
|
||||||
const diffStore = inputs_exports.getBool("diff-store");
|
|
||||||
const daemonCliFlags = [
|
const daemonCliFlags = [
|
||||||
"--startup-notification-url",
|
"--startup-notification-url",
|
||||||
`http://127.0.0.1:${notifyPort}`,
|
`http://127.0.0.1:${notifyPort}`,
|
||||||
|
@ -95319,7 +95327,7 @@ var MagicNixCacheAction = class extends DetSysAction {
|
||||||
diagnosticEndpoint,
|
diagnosticEndpoint,
|
||||||
"--nix-conf",
|
"--nix-conf",
|
||||||
nixConfPath
|
nixConfPath
|
||||||
].concat(diffStore ? ["--diff-store"] : []).concat(
|
].concat(this.diffStore ? ["--diff-store"] : []).concat(
|
||||||
useFlakeHub ? [
|
useFlakeHub ? [
|
||||||
"--use-flakehub",
|
"--use-flakehub",
|
||||||
"--flakehub-cache-server",
|
"--flakehub-cache-server",
|
||||||
|
|
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
18
src/index.ts
18
src/index.ts
|
@ -14,6 +14,10 @@ import { inspect } from "node:util";
|
||||||
// twice.
|
// twice.
|
||||||
const ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
const ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
|
|
||||||
|
const FACT_AUTHENTICATED_ENV = "authenticated_env";
|
||||||
|
const FACT_DIFF_STORE = "diff_store";
|
||||||
|
const FACT_NOOP_MODE = "noop_mode";
|
||||||
|
|
||||||
const STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
const STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
|
||||||
const STARTED_HINT = "true";
|
const STARTED_HINT = "true";
|
||||||
|
@ -27,9 +31,9 @@ const TEXT_TRUST_UNKNOWN =
|
||||||
|
|
||||||
class MagicNixCacheAction extends DetSysAction {
|
class MagicNixCacheAction extends DetSysAction {
|
||||||
private hostAndPort: string;
|
private hostAndPort: string;
|
||||||
|
private diffStore: boolean;
|
||||||
private httpClient: Got;
|
private httpClient: Got;
|
||||||
|
private noopMode: boolean;
|
||||||
noopMode: boolean;
|
|
||||||
private daemonDir: string;
|
private daemonDir: string;
|
||||||
private daemonStarted: boolean;
|
private daemonStarted: boolean;
|
||||||
|
|
||||||
|
@ -42,6 +46,9 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.hostAndPort = inputs.getString("listen");
|
this.hostAndPort = inputs.getString("listen");
|
||||||
|
this.diffStore = inputs.getBool("diff-store");
|
||||||
|
|
||||||
|
this.addFact(FACT_DIFF_STORE, this.diffStore);
|
||||||
|
|
||||||
this.httpClient = got.extend({
|
this.httpClient = got.extend({
|
||||||
retry: {
|
retry: {
|
||||||
|
@ -75,7 +82,7 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
} else {
|
} else {
|
||||||
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
|
||||||
}
|
}
|
||||||
this.addFact("noop_mode", this.noopMode);
|
this.addFact(FACT_NOOP_MODE, this.noopMode);
|
||||||
|
|
||||||
this.stapleFile("daemon.log", path.join(this.daemonDir, "daemon.log"));
|
this.stapleFile("daemon.log", path.join(this.daemonDir, "daemon.log"));
|
||||||
}
|
}
|
||||||
|
@ -130,7 +137,7 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addFact("authenticated_env", !anyMissing);
|
this.addFact(FACT_AUTHENTICATED_ENV, !anyMissing);
|
||||||
if (anyMissing) {
|
if (anyMissing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +199,6 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
const flakeHubApiServer = inputs.getString("flakehub-api-server");
|
const flakeHubApiServer = inputs.getString("flakehub-api-server");
|
||||||
const flakeHubFlakeName = inputs.getString("flakehub-flake-name");
|
const flakeHubFlakeName = inputs.getString("flakehub-flake-name");
|
||||||
const useGhaCache = inputs.getBool("use-gha-cache");
|
const useGhaCache = inputs.getBool("use-gha-cache");
|
||||||
const diffStore = inputs.getBool("diff-store");
|
|
||||||
|
|
||||||
const daemonCliFlags: string[] = [
|
const daemonCliFlags: string[] = [
|
||||||
"--startup-notification-url",
|
"--startup-notification-url",
|
||||||
|
@ -206,7 +212,7 @@ class MagicNixCacheAction extends DetSysAction {
|
||||||
"--nix-conf",
|
"--nix-conf",
|
||||||
nixConfPath,
|
nixConfPath,
|
||||||
]
|
]
|
||||||
.concat(diffStore ? ["--diff-store"] : [])
|
.concat(this.diffStore ? ["--diff-store"] : [])
|
||||||
.concat(
|
.concat(
|
||||||
useFlakeHub
|
useFlakeHub
|
||||||
? [
|
? [
|
||||||
|
|
Loading…
Reference in a new issue