mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-22 21:12:08 +01:00
Merge pull request #99 from DeterminateSystems/science/debug-fly
science: probes to debug fly on GHA
This commit is contained in:
commit
9d5faf48ab
4 changed files with 87 additions and 2 deletions
41
dist/index.js
generated
vendored
41
dist/index.js
generated
vendored
|
@ -98043,6 +98043,7 @@ function makeOptionsConfident(actionOptions) {
|
|||
|
||||
|
||||
|
||||
|
||||
var EVENT_INSTALL_NIX_FAILURE = "install_nix_failure";
|
||||
var EVENT_INSTALL_NIX_START = "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"];
|
||||
}
|
||||
async main() {
|
||||
await this.scienceDebugFly();
|
||||
await this.detectAndForceDockerShim();
|
||||
await this.install();
|
||||
}
|
||||
|
@ -98118,6 +98120,45 @@ var NixInstallerAction = class extends DetSysAction {
|
|||
get isRunningInNamespaceRunner() {
|
||||
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
|
||||
// eslint-disable-next-line camelcase
|
||||
debug_probe_urls_elapsed: (resp.timings.end ?? 0) - resp.timings.start
|
||||
});
|
||||
} 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.
|
||||
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
|
||||
// and especially GitHub Enterprise Server.
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^5.1.1",
|
||||
"detsys-ts": "github:DeterminateSystems/detsys-ts",
|
||||
"string-argv": "^0.3.2"
|
||||
"string-argv": "^0.3.2",
|
||||
"got": "^14.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||
|
|
|
@ -17,6 +17,9 @@ dependencies:
|
|||
detsys-ts:
|
||||
specifier: github:DeterminateSystems/detsys-ts
|
||||
version: github.com/DeterminateSystems/detsys-ts/fe64ba33b4bdeec0991bb65ae00420bf68b9954c
|
||||
got:
|
||||
specifier: ^14.2.1
|
||||
version: 14.3.0
|
||||
string-argv:
|
||||
specifier: ^0.3.2
|
||||
version: 0.3.2
|
||||
|
|
42
src/index.ts
42
src/index.ts
|
@ -7,8 +7,9 @@ import fs from "node:fs";
|
|||
import { userInfo } from "node:os";
|
||||
import stringArgv from "string-argv";
|
||||
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 got from "got";
|
||||
|
||||
// Nix installation events
|
||||
const EVENT_INSTALL_NIX_FAILURE = "install_nix_failure";
|
||||
|
@ -117,6 +118,7 @@ class NixInstallerAction extends DetSysAction {
|
|||
}
|
||||
|
||||
async main(): Promise<void> {
|
||||
await this.scienceDebugFly();
|
||||
await this.detectAndForceDockerShim();
|
||||
await this.install();
|
||||
}
|
||||
|
@ -145,6 +147,44 @@ 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
|
||||
// eslint-disable-next-line camelcase
|
||||
debug_probe_urls_elapsed:
|
||||
(resp.timings.end ?? 0) - resp.timings.start,
|
||||
});
|
||||
} 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.
|
||||
// This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/),
|
||||
// and especially GitHub Enterprise Server.
|
||||
|
|
Loading…
Reference in a new issue