mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-27 09:35:23 +01:00
Fix HTTP status code logic
This commit is contained in:
parent
93f3ded0b4
commit
edc61c4d5a
4 changed files with 36 additions and 18 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -32,6 +32,7 @@ jobs:
|
||||||
- run: git diff --exit-code
|
- run: git diff --exit-code
|
||||||
|
|
||||||
test-no-nix:
|
test-no-nix:
|
||||||
|
needs: build
|
||||||
name: "Test: Nix not installed"
|
name: "Test: Nix not installed"
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
permissions:
|
permissions:
|
||||||
|
@ -47,6 +48,7 @@ jobs:
|
||||||
strict-mode: true
|
strict-mode: true
|
||||||
|
|
||||||
run-x86_64-linux-untrusted:
|
run-x86_64-linux-untrusted:
|
||||||
|
needs: build
|
||||||
name: Run x86_64 Linux, Untrusted
|
name: Run x86_64 Linux, Untrusted
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
permissions:
|
permissions:
|
||||||
|
|
21
dist/index.js
generated
vendored
21
dist/index.js
generated
vendored
|
@ -94996,8 +94996,15 @@ var MagicNixCacheAction = class {
|
||||||
try {
|
try {
|
||||||
core.debug(`Indicating workflow start`);
|
core.debug(`Indicating workflow start`);
|
||||||
const hostAndPort = inputs_exports.getString("listen");
|
const hostAndPort = inputs_exports.getString("listen");
|
||||||
const res = await this.client.post(`http://${hostAndPort}/api/workflow-start`).json();
|
const res = await this.client.post(
|
||||||
core.debug(`back from post: ${res}`);
|
`http://${hostAndPort}/api/workflow-start`
|
||||||
|
);
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
this.failInStrictMode(
|
||||||
|
`Failed to trigger workflow start hook. Expected status 200 but got ${res.statusCode}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
core.debug(`back from post: ${JSON.stringify(res)}`);
|
||||||
} 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));
|
||||||
|
@ -95022,13 +95029,15 @@ 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(`http://${hostAndPort}/api/workflow-finish`).json();
|
const res = await this.client.post(
|
||||||
if (res.status !== 200) {
|
`http://${hostAndPort}/api/workflow-finish`
|
||||||
|
);
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
this.failInStrictMode(
|
this.failInStrictMode(
|
||||||
`Failed to trigger workflow finish hook. Response: ${JSON.stringify(res)}`
|
`Failed to trigger workflow finish hook. Expected status 200 but got ${res.statusCode}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
core.debug(`back from post: ${res}`);
|
core.debug(`back from post: ${JSON.stringify(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
29
src/index.ts
29
src/index.ts
|
@ -1,7 +1,7 @@
|
||||||
import { netrcPath, tailLog } from "./helpers.js";
|
import { netrcPath, tailLog } from "./helpers.js";
|
||||||
import * as actionsCore from "@actions/core";
|
import * as actionsCore from "@actions/core";
|
||||||
import { IdsToolbox, inputs } from "detsys-ts";
|
import { IdsToolbox, inputs } from "detsys-ts";
|
||||||
import got, { Got } 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, exec, spawn } from "node:child_process";
|
||||||
import { mkdirSync, openSync, readFileSync } from "node:fs";
|
import { mkdirSync, openSync, readFileSync } from "node:fs";
|
||||||
|
@ -274,10 +274,17 @@ class MagicNixCacheAction {
|
||||||
try {
|
try {
|
||||||
actionsCore.debug(`Indicating workflow start`);
|
actionsCore.debug(`Indicating workflow start`);
|
||||||
const hostAndPort = inputs.getString("listen");
|
const hostAndPort = inputs.getString("listen");
|
||||||
const res: Response = await this.client
|
const res: Response<string> = await this.client.post(
|
||||||
.post(`http://${hostAndPort}/api/workflow-start`)
|
`http://${hostAndPort}/api/workflow-start`,
|
||||||
.json();
|
);
|
||||||
actionsCore.debug(`back from post: ${res}`);
|
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
this.failInStrictMode(
|
||||||
|
`Failed to trigger workflow start hook. Expected status 200 but got ${res.statusCode}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
actionsCore.debug(`back from post: ${JSON.stringify(res)}`);
|
||||||
} 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));
|
||||||
|
@ -307,17 +314,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 = await this.client
|
const res: Response<string> = await this.client.post(
|
||||||
.post(`http://${hostAndPort}/api/workflow-finish`)
|
`http://${hostAndPort}/api/workflow-finish`,
|
||||||
.json();
|
);
|
||||||
|
|
||||||
if (res.status !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
this.failInStrictMode(
|
this.failInStrictMode(
|
||||||
`Failed to trigger workflow finish hook. Response: ${JSON.stringify(res)}`,
|
`Failed to trigger workflow finish hook. Expected status 200 but got ${res.statusCode}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
actionsCore.debug(`back from post: ${res}`);
|
actionsCore.debug(`back from post: ${JSON.stringify(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