mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-23 13:32:06 +01:00
science: probes to debug fly on GHA
This commit is contained in:
parent
7993355175
commit
5adb94fc48
4 changed files with 82 additions and 2 deletions
39
dist/index.js
generated
vendored
39
dist/index.js
generated
vendored
|
@ -98043,6 +98043,7 @@ function makeOptionsConfident(actionOptions) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var EVENT_INSTALL_NIX_FAILURE = "install_nix_failure";
|
var EVENT_INSTALL_NIX_FAILURE = "install_nix_failure";
|
||||||
var EVENT_INSTALL_NIX_START = "install_nix_start";
|
var EVENT_INSTALL_NIX_START = "install_nix_start";
|
||||||
var EVENT_INSTALL_NIX_SUCCESS = "install_nix_start";
|
var EVENT_INSTALL_NIX_SUCCESS = "install_nix_start";
|
||||||
|
@ -98099,6 +98100,7 @@ var NixInstallerAction = class extends DetSysAction {
|
||||||
this.runnerOs = process.env["RUNNER_OS"];
|
this.runnerOs = process.env["RUNNER_OS"];
|
||||||
}
|
}
|
||||||
async main() {
|
async main() {
|
||||||
|
await this.scienceDebugFly();
|
||||||
await this.detectAndForceDockerShim();
|
await this.detectAndForceDockerShim();
|
||||||
await this.install();
|
await this.install();
|
||||||
}
|
}
|
||||||
|
@ -98118,6 +98120,43 @@ var NixInstallerAction = class extends DetSysAction {
|
||||||
get isRunningInNamespaceRunner() {
|
get isRunningInNamespaceRunner() {
|
||||||
return process.env["NSC_VM_ID"] !== void 0 && !(process.env["NOT_NAMESPACE"] === "true");
|
return process.env["NSC_VM_ID"] !== void 0 && !(process.env["NOT_NAMESPACE"] === "true");
|
||||||
}
|
}
|
||||||
|
async scienceDebugFly() {
|
||||||
|
try {
|
||||||
|
const feat = this.getFeature("debug-probe-urls");
|
||||||
|
if (feat === void 0 || feat.payload === void 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { timeoutMs, url } = JSON.parse(
|
||||||
|
feat.payload
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const resp = await got_dist_source.get(url, {
|
||||||
|
timeout: {
|
||||||
|
request: timeoutMs
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.recordEvent("debug-probe-urls:response", {
|
||||||
|
debug_probe_urls_ip: resp.ip,
|
||||||
|
// eslint-disable-line camelcase
|
||||||
|
debug_probe_urls_ok: resp.ok,
|
||||||
|
// eslint-disable-line camelcase
|
||||||
|
debug_probe_urls_status_code: resp.statusCode,
|
||||||
|
// eslint-disable-line camelcase
|
||||||
|
debug_probe_urls_body: resp.body
|
||||||
|
// eslint-disable-line camelcase
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
this.recordEvent("debug-probe-urls:exception", {
|
||||||
|
debug_probe_urls_exception: stringifyError(e)
|
||||||
|
// eslint-disable-line camelcase
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.recordEvent("debug-probe-urls:error", {
|
||||||
|
exception: stringifyError(err)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
// Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker.
|
// Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker.
|
||||||
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
|
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
|
||||||
// and especially GitHub Enterprise Server.
|
// and especially GitHub Enterprise Server.
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"detsys-ts": "github:DeterminateSystems/detsys-ts",
|
"detsys-ts": "github:DeterminateSystems/detsys-ts",
|
||||||
"string-argv": "^0.3.2"
|
"string-argv": "^0.3.2",
|
||||||
|
"got": "^14.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||||
|
|
|
@ -17,6 +17,9 @@ dependencies:
|
||||||
detsys-ts:
|
detsys-ts:
|
||||||
specifier: github:DeterminateSystems/detsys-ts
|
specifier: github:DeterminateSystems/detsys-ts
|
||||||
version: github.com/DeterminateSystems/detsys-ts/fe64ba33b4bdeec0991bb65ae00420bf68b9954c
|
version: github.com/DeterminateSystems/detsys-ts/fe64ba33b4bdeec0991bb65ae00420bf68b9954c
|
||||||
|
got:
|
||||||
|
specifier: ^14.2.1
|
||||||
|
version: 14.3.0
|
||||||
string-argv:
|
string-argv:
|
||||||
specifier: ^0.3.2
|
specifier: ^0.3.2
|
||||||
version: 0.3.2
|
version: 0.3.2
|
||||||
|
|
39
src/index.ts
39
src/index.ts
|
@ -7,8 +7,9 @@ import fs from "node:fs";
|
||||||
import { userInfo } from "node:os";
|
import { userInfo } from "node:os";
|
||||||
import stringArgv from "string-argv";
|
import stringArgv from "string-argv";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { DetSysAction, inputs, platform } from "detsys-ts";
|
import { DetSysAction, inputs, platform, stringifyError } from "detsys-ts";
|
||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
|
import got from "got";
|
||||||
|
|
||||||
// Nix installation events
|
// Nix installation events
|
||||||
const EVENT_INSTALL_NIX_FAILURE = "install_nix_failure";
|
const EVENT_INSTALL_NIX_FAILURE = "install_nix_failure";
|
||||||
|
@ -117,6 +118,7 @@ class NixInstallerAction extends DetSysAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async main(): Promise<void> {
|
async main(): Promise<void> {
|
||||||
|
await this.scienceDebugFly();
|
||||||
await this.detectAndForceDockerShim();
|
await this.detectAndForceDockerShim();
|
||||||
await this.install();
|
await this.install();
|
||||||
}
|
}
|
||||||
|
@ -145,6 +147,41 @@ class NixInstallerAction extends DetSysAction {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async scienceDebugFly(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const feat = this.getFeature("debug-probe-urls");
|
||||||
|
if (feat === undefined || feat.payload === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { timeoutMs, url }: { timeoutMs: number; url: string } = JSON.parse(
|
||||||
|
feat.payload,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const resp = await got.get(url, {
|
||||||
|
timeout: {
|
||||||
|
request: timeoutMs,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.recordEvent("debug-probe-urls:response", {
|
||||||
|
debug_probe_urls_ip: resp.ip, // eslint-disable-line camelcase
|
||||||
|
debug_probe_urls_ok: resp.ok, // eslint-disable-line camelcase
|
||||||
|
debug_probe_urls_status_code: resp.statusCode, // eslint-disable-line camelcase
|
||||||
|
debug_probe_urls_body: resp.body, // eslint-disable-line camelcase
|
||||||
|
});
|
||||||
|
} catch (e: unknown) {
|
||||||
|
this.recordEvent("debug-probe-urls:exception", {
|
||||||
|
debug_probe_urls_exception: stringifyError(e), // eslint-disable-line camelcase
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err: unknown) {
|
||||||
|
this.recordEvent("debug-probe-urls:error", {
|
||||||
|
exception: stringifyError(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker.
|
// Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker.
|
||||||
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
|
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
|
||||||
// and especially GitHub Enterprise Server.
|
// and especially GitHub Enterprise Server.
|
||||||
|
|
Loading…
Reference in a new issue