Skip to content

Commit

Permalink
Merge pull request #99 from DeterminateSystems/science/debug-fly
Browse files Browse the repository at this point in the history
science: probes to debug fly on GHA
  • Loading branch information
lucperkins authored Jun 3, 2024
2 parents 7993355 + f92f108 commit 9d5faf4
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
41 changes: 41 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 41 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -117,6 +118,7 @@ class NixInstallerAction extends DetSysAction {
}

async main(): Promise<void> {
await this.scienceDebugFly();
await this.detectAndForceDockerShim();
await this.install();
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9d5faf4

Please sign in to comment.