mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-27 01:30:35 +01:00
Fix HTTP handling logic
This commit is contained in:
parent
a8b68ff5ba
commit
7f10b5e63d
3 changed files with 15 additions and 15 deletions
13
dist/index.js
generated
vendored
13
dist/index.js
generated
vendored
|
@ -94816,6 +94816,7 @@ var MagicNixCacheAction = class {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
methods: ["POST", "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "TRACE"]
|
methods: ["POST", "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "TRACE"]
|
||||||
},
|
},
|
||||||
|
resolveBodyOnly: false,
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeRetry: [
|
beforeRetry: [
|
||||||
(error, retryCount) => {
|
(error, retryCount) => {
|
||||||
|
@ -94999,10 +95000,10 @@ var MagicNixCacheAction = class {
|
||||||
const res = await this.client.post(`http://${hostAndPort}/api/workflow-start`).json();
|
const res = await this.client.post(`http://${hostAndPort}/api/workflow-start`).json();
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
this.failInStrictMode(
|
this.failInStrictMode(
|
||||||
`Failed to trigger workflow start hook. Expected status 200 but got ${res.statusCode}`
|
`Failed to trigger workflow start hook; expected status 200 but got ${res.statusCode}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
core.debug(`back from post: ${JSON.stringify(res.body)}`);
|
core.debug(`back from post: ${res.body}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
core.info(`Error marking the workflow as started:`);
|
core.info(`Error marking the workflow as started:`);
|
||||||
core.info((0,external_node_util_.inspect)(e));
|
core.info((0,external_node_util_.inspect)(e));
|
||||||
|
@ -95027,15 +95028,13 @@ var MagicNixCacheAction = class {
|
||||||
try {
|
try {
|
||||||
core.debug(`about to post to localhost`);
|
core.debug(`about to post to localhost`);
|
||||||
const hostAndPort = inputs_exports.getString("listen");
|
const hostAndPort = inputs_exports.getString("listen");
|
||||||
const res = await this.client.post(
|
const res = await this.client.post(`http://${hostAndPort}/api/workflow-finish`).json();
|
||||||
`http://${hostAndPort}/api/workflow-finish`
|
|
||||||
);
|
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
this.failInStrictMode(
|
this.failInStrictMode(
|
||||||
`Failed to trigger workflow finish hook. Expected status 200 but got ${res.statusCode}`
|
`Failed to trigger workflow finish hook; expected status 200 but got ${res.statusCode}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
core.debug(`back from post: ${JSON.stringify(res.body)}`);
|
core.debug(`back from post: ${res.body}`);
|
||||||
} finally {
|
} finally {
|
||||||
core.debug(`unwatching the daemon log`);
|
core.debug(`unwatching the daemon log`);
|
||||||
log.unwatch();
|
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
15
src/index.ts
15
src/index.ts
|
@ -50,6 +50,7 @@ class MagicNixCacheAction {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
methods: ["POST", "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "TRACE"],
|
methods: ["POST", "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "TRACE"],
|
||||||
},
|
},
|
||||||
|
resolveBodyOnly: false,
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeRetry: [
|
beforeRetry: [
|
||||||
(error, retryCount) => {
|
(error, retryCount) => {
|
||||||
|
@ -280,11 +281,11 @@ class MagicNixCacheAction {
|
||||||
|
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
this.failInStrictMode(
|
this.failInStrictMode(
|
||||||
`Failed to trigger workflow start hook. Expected status 200 but got ${res.statusCode}`,
|
`Failed to trigger workflow start hook; expected status 200 but got ${res.statusCode}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
actionsCore.debug(`back from post: ${JSON.stringify(res.body)}`);
|
actionsCore.debug(`back from post: ${res.body}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
actionsCore.info(`Error marking the workflow as started:`);
|
actionsCore.info(`Error marking the workflow as started:`);
|
||||||
actionsCore.info(inspect(e));
|
actionsCore.info(inspect(e));
|
||||||
|
@ -314,17 +315,17 @@ class MagicNixCacheAction {
|
||||||
try {
|
try {
|
||||||
actionsCore.debug(`about to post to localhost`);
|
actionsCore.debug(`about to post to localhost`);
|
||||||
const hostAndPort = inputs.getString("listen");
|
const hostAndPort = inputs.getString("listen");
|
||||||
const res: Response<string> = await this.client.post(
|
const res: Response<string> = await this.client
|
||||||
`http://${hostAndPort}/api/workflow-finish`,
|
.post(`http://${hostAndPort}/api/workflow-finish`)
|
||||||
);
|
.json();
|
||||||
|
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
this.failInStrictMode(
|
this.failInStrictMode(
|
||||||
`Failed to trigger workflow finish hook. Expected status 200 but got ${res.statusCode}`,
|
`Failed to trigger workflow finish hook; expected status 200 but got ${res.statusCode}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
actionsCore.debug(`back from post: ${JSON.stringify(res.body)}`);
|
actionsCore.debug(`back from post: ${res.body}`);
|
||||||
} finally {
|
} finally {
|
||||||
actionsCore.debug(`unwatching the daemon log`);
|
actionsCore.debug(`unwatching the daemon log`);
|
||||||
log.unwatch();
|
log.unwatch();
|
||||||
|
|
Loading…
Reference in a new issue