Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

science: probes to debug fly on GHA #99

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
lucperkins marked this conversation as resolved.
Show resolved Hide resolved
});
} 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