mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-23 05:22:07 +01:00
Always log status code and body
This commit is contained in:
parent
ec531ea91f
commit
afefc2fc85
3 changed files with 24 additions and 17 deletions
17
dist/index.js
generated
vendored
17
dist/index.js
generated
vendored
|
@ -94811,6 +94811,7 @@ var MagicNixCacheAction = class {
|
|||
requireNix: "warn"
|
||||
});
|
||||
this.strictMode = inputs_exports.getBool("strict-mode");
|
||||
this.hostAndPort = inputs_exports.getString("listen");
|
||||
this.client = got_dist_source.extend({
|
||||
retry: {
|
||||
limit: 1,
|
||||
|
@ -94908,7 +94909,6 @@ var MagicNixCacheAction = class {
|
|||
const log = tailLog(this.daemonDir);
|
||||
const netrc = await netrcPath();
|
||||
const nixConfPath = `${process.env["HOME"]}/.config/nix/nix.conf`;
|
||||
const hostAndPort = inputs_exports.getString("listen");
|
||||
const upstreamCache = inputs_exports.getString("upstream-cache");
|
||||
const diagnosticEndpoint = inputs_exports.getString("diagnostic-endpoint");
|
||||
const useFlakeHub = inputs_exports.getBool("use-flakehub");
|
||||
|
@ -94920,7 +94920,7 @@ var MagicNixCacheAction = class {
|
|||
"--startup-notification-url",
|
||||
`http://127.0.0.1:${notifyPort}`,
|
||||
"--listen",
|
||||
hostAndPort,
|
||||
this.hostAndPort,
|
||||
"--upstream",
|
||||
upstreamCache,
|
||||
"--diagnostic-endpoint",
|
||||
|
@ -94995,9 +94995,11 @@ var MagicNixCacheAction = class {
|
|||
}
|
||||
try {
|
||||
core.debug(`Indicating workflow start`);
|
||||
const hostAndPort = inputs_exports.getString("listen");
|
||||
const res = await this.client.post(
|
||||
`http://${hostAndPort}/api/workflow-start`
|
||||
`http://${this.hostAndPort}/api/workflow-start`
|
||||
);
|
||||
core.debug(
|
||||
`post to /api/workflow-start (status: ${res.statusCode}, body: ${res.body})`
|
||||
);
|
||||
if (res.statusCode !== 200) {
|
||||
this.failInStrictMode(
|
||||
|
@ -95028,16 +95030,17 @@ var MagicNixCacheAction = class {
|
|||
const log = tailLog(this.daemonDir);
|
||||
try {
|
||||
core.debug(`about to post to localhost`);
|
||||
const hostAndPort = inputs_exports.getString("listen");
|
||||
const res = await this.client.post(
|
||||
`http://${hostAndPort}/api/workflow-finish`
|
||||
`http://${this.hostAndPort}/api/workflow-finish`
|
||||
);
|
||||
core.debug(
|
||||
`post to /api/workflow-finish (status: ${res.statusCode}, body: ${res.body})`
|
||||
);
|
||||
if (res.statusCode !== 200) {
|
||||
this.failInStrictMode(
|
||||
`Failed to trigger workflow finish hook; expected status 200 but got ${res.statusCode}`
|
||||
);
|
||||
}
|
||||
core.debug(`back from post: ${res.body}`);
|
||||
} finally {
|
||||
core.debug(`unwatching the daemon log`);
|
||||
log.unwatch();
|
||||
|
|
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
|
@ -29,6 +29,7 @@ const TEXT_TRUST_UNKNOWN =
|
|||
class MagicNixCacheAction {
|
||||
idslib: IdsToolbox;
|
||||
private strictMode: boolean;
|
||||
private hostAndPort: string;
|
||||
private client: Got;
|
||||
|
||||
noopMode: boolean;
|
||||
|
@ -44,6 +45,7 @@ class MagicNixCacheAction {
|
|||
});
|
||||
|
||||
this.strictMode = inputs.getBool("strict-mode");
|
||||
this.hostAndPort = inputs.getString("listen");
|
||||
|
||||
this.client = got.extend({
|
||||
retry: {
|
||||
|
@ -159,8 +161,6 @@ class MagicNixCacheAction {
|
|||
const log = tailLog(this.daemonDir);
|
||||
const netrc = await netrcPath();
|
||||
const nixConfPath = `${process.env["HOME"]}/.config/nix/nix.conf`;
|
||||
|
||||
const hostAndPort = inputs.getString("listen");
|
||||
const upstreamCache = inputs.getString("upstream-cache");
|
||||
const diagnosticEndpoint = inputs.getString("diagnostic-endpoint");
|
||||
const useFlakeHub = inputs.getBool("use-flakehub");
|
||||
|
@ -173,7 +173,7 @@ class MagicNixCacheAction {
|
|||
"--startup-notification-url",
|
||||
`http://127.0.0.1:${notifyPort}`,
|
||||
"--listen",
|
||||
hostAndPort,
|
||||
this.hostAndPort,
|
||||
"--upstream",
|
||||
upstreamCache,
|
||||
"--diagnostic-endpoint",
|
||||
|
@ -273,9 +273,12 @@ class MagicNixCacheAction {
|
|||
|
||||
try {
|
||||
actionsCore.debug(`Indicating workflow start`);
|
||||
const hostAndPort = inputs.getString("listen");
|
||||
const res: Response<string> = await this.client.post(
|
||||
`http://${hostAndPort}/api/workflow-start`,
|
||||
`http://${this.hostAndPort}/api/workflow-start`,
|
||||
);
|
||||
|
||||
actionsCore.debug(
|
||||
`post to /api/workflow-start (status: ${res.statusCode}, body: ${res.body})`,
|
||||
);
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
|
@ -313,9 +316,12 @@ class MagicNixCacheAction {
|
|||
|
||||
try {
|
||||
actionsCore.debug(`about to post to localhost`);
|
||||
const hostAndPort = inputs.getString("listen");
|
||||
const res: Response<string> = await this.client.post(
|
||||
`http://${hostAndPort}/api/workflow-finish`,
|
||||
`http://${this.hostAndPort}/api/workflow-finish`,
|
||||
);
|
||||
|
||||
actionsCore.debug(
|
||||
`post to /api/workflow-finish (status: ${res.statusCode}, body: ${res.body})`,
|
||||
);
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
|
@ -323,8 +329,6 @@ class MagicNixCacheAction {
|
|||
`Failed to trigger workflow finish hook; expected status 200 but got ${res.statusCode}`,
|
||||
);
|
||||
}
|
||||
|
||||
actionsCore.debug(`back from post: ${res.body}`);
|
||||
} finally {
|
||||
actionsCore.debug(`unwatching the daemon log`);
|
||||
log.unwatch();
|
||||
|
|
Loading…
Reference in a new issue