Update detsys-ts (status page changes)

This commit is contained in:
Luc Perkins 2024-06-03 09:17:21 -07:00
parent ae93aac549
commit bbb32efce5
No known key found for this signature in database
GPG key ID: 16DB1108FB591835
2 changed files with 118 additions and 8 deletions

120
dist/index.js generated vendored
View file

@ -94091,7 +94091,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises"); const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
;// CONCATENATED MODULE: external "node:zlib" ;// CONCATENATED MODULE: external "node:zlib"
const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:zlib"); const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:zlib");
;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@9d66d2c89c150f796165fdcc20b3be538807c0f4_46ybmzqhaua4eiwu3nj2qm63te/node_modules/detsys-ts/dist/index.js ;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@fe64ba33b4bdeec0991bb65ae00420bf68b9954c_ler7zqcm5mrt635umsvjcuxcmy/node_modules/detsys-ts/dist/index.js
var __defProp = Object.defineProperty; var __defProp = Object.defineProperty;
var __export = (target, all) => { var __export = (target, all) => {
for (var name in all) for (var name in all)
@ -94428,7 +94428,7 @@ var IdsHost = class {
setPrioritizedUrls(urls) { setPrioritizedUrls(urls) {
this.prioritizedURLs = urls; this.prioritizedURLs = urls;
} }
async getRootUrl() { async getDynamicRootUrl() {
const idsHost = process.env["IDS_HOST"]; const idsHost = process.env["IDS_HOST"];
if (idsHost !== void 0) { if (idsHost !== void 0) {
try { try {
@ -94449,9 +94449,17 @@ var IdsHost = class {
); );
} }
if (url === void 0) { if (url === void 0) {
url = new URL(DEFAULT_IDS_HOST); return void 0;
} else {
return new URL(url);
} }
return new URL(url); }
async getRootUrl() {
const url = await this.getDynamicRootUrl();
if (url === void 0) {
return new URL(DEFAULT_IDS_HOST);
}
return url;
} }
async getDiagnosticsUrl() { async getDiagnosticsUrl() {
if (this.runtimeDiagnosticsUrl === "") { if (this.runtimeDiagnosticsUrl === "") {
@ -94762,6 +94770,7 @@ var STATE_KEY_EXECUTION_PHASE = "detsys_action_execution_phase";
var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found"; var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found";
var STATE_NOT_FOUND = "not-found"; var STATE_NOT_FOUND = "not-found";
var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4; var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4;
var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3;
var DetSysAction = class { var DetSysAction = class {
determineExecutionPhase() { determineExecutionPhase() {
const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE); const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE);
@ -94784,6 +94793,8 @@ var DetSysAction = class {
this.exceptionAttachments = /* @__PURE__ */ new Map(); this.exceptionAttachments = /* @__PURE__ */ new Map();
this.nixStoreTrust = "unknown"; this.nixStoreTrust = "unknown";
this.strictMode = getBool("_internal-strict-mode"); this.strictMode = getBool("_internal-strict-mode");
this.features = {};
this.featureEventMetadata = /* @__PURE__ */ new Map();
this.events = []; this.events = [];
this.client = got_dist_source.extend({ this.client = got_dist_source.extend({
retry: { retry: {
@ -94893,11 +94904,13 @@ var DetSysAction = class {
return this.identity; return this.identity;
} }
recordEvent(eventName, context = {}) { recordEvent(eventName, context = {}) {
const prefixedName = eventName === "$feature_flag_called" ? eventName : `${this.actionOptions.eventPrefix}${eventName}`;
this.events.push({ this.events.push({
event_name: `${this.actionOptions.eventPrefix}${eventName}`, event_name: prefixedName,
context, context,
correlation: this.identity, correlation: this.identity,
facts: this.facts, facts: this.facts,
features: this.featureEventMetadata,
timestamp: /* @__PURE__ */ new Date(), timestamp: /* @__PURE__ */ new Date(),
uuid: (0,external_node_crypto_namespaceObject.randomUUID)() uuid: (0,external_node_crypto_namespaceObject.randomUUID)()
}); });
@ -94933,6 +94946,7 @@ var DetSysAction = class {
} }
async executeAsync() { async executeAsync() {
try { try {
await this.checkIn();
process.env.DETSYS_CORRELATION = JSON.stringify( process.env.DETSYS_CORRELATION = JSON.stringify(
this.getCorrelationHashes() this.getCorrelationHashes()
); );
@ -94980,6 +94994,94 @@ var DetSysAction = class {
await this.complete(); await this.complete();
} }
} }
async checkIn() {
const checkin = await this.requestCheckIn();
if (checkin === void 0) {
return;
}
this.features = checkin.options;
for (const [key, feature] of Object.entries(this.features)) {
this.featureEventMetadata.set(key, feature.variant);
}
const impactSymbol = /* @__PURE__ */ new Map([
["none", "\u26AA"],
["maintenance", "\u{1F6E0}\uFE0F"],
["minor", "\u{1F7E1}"],
["major", "\u{1F7E0}"],
["critical", "\u{1F534}"]
]);
const defaultImpactSymbol = "\u{1F535}";
if (checkin.status !== null) {
const summaries = [];
for (const incident of checkin.status.incidents) {
summaries.push(
`${impactSymbol.get(incident.impact) || defaultImpactSymbol} ${incident.status.replace("_", " ")}: ${incident.name} (${incident.shortlink})`
);
}
for (const maintenance of checkin.status.scheduled_maintenances) {
summaries.push(
`${impactSymbol.get(maintenance.impact) || defaultImpactSymbol} ${maintenance.status.replace("_", " ")}: ${maintenance.name} (${maintenance.shortlink})`
);
}
if (summaries.length > 0) {
core.info(
// Bright red, Bold, Underline
`${"\x1B[0;31m"}${"\x1B[1m"}${"\x1B[4m"}${checkin.status.page.name} Status`
);
for (const notice of summaries) {
core.info(notice);
}
core.info(`See: ${checkin.status.page.url}`);
core.info(``);
}
}
}
getFeature(name) {
if (!this.features.hasOwnProperty(name)) {
return void 0;
}
const result = this.features[name];
if (result === void 0) {
return void 0;
}
this.recordEvent("$feature_flag_called", {
$feature_flag: name,
$feature_flag_response: result.variant
});
return result;
}
/**
* Check in to install.determinate.systems, to accomplish three things:
*
* 1. Preflight the server selected from IdsHost, to increase the chances of success.
* 2. Fetch any incidents and maintenance events to let users know in case things are weird.
* 3. Get feature flag data so we can gently roll out new features.
*/
async requestCheckIn() {
for (let attemptsRemaining = 5; attemptsRemaining > 0; attemptsRemaining--) {
const checkInUrl = await this.getCheckInUrl();
if (checkInUrl === void 0) {
return void 0;
}
try {
core.debug(`Preflighting via ${checkInUrl}`);
checkInUrl.searchParams.set("ci", "github");
checkInUrl.searchParams.set(
"correlation",
JSON.stringify(this.identity)
);
return await this.client.get(checkInUrl, {
timeout: {
request: CHECK_IN_ENDPOINT_TIMEOUT_MS
}
}).json();
} catch (e) {
core.debug(`Error checking in: ${stringifyError2(e)}`);
this.idsHost.markCurrentHostBroken();
}
}
return void 0;
}
/** /**
* Fetch an artifact, such as a tarball, from the location determined by the * Fetch an artifact, such as a tarball, from the location determined by the
* `source-*` inputs. If `source-binary` is specified, this will return a path * `source-*` inputs. If `source-binary` is specified, this will return a path
@ -95057,6 +95159,14 @@ var DetSysAction = class {
this.recordEvent(`complete_${this.executionPhase}`); this.recordEvent(`complete_${this.executionPhase}`);
await this.submitEvents(); await this.submitEvents();
} }
async getCheckInUrl() {
const checkInUrl = await this.idsHost.getDynamicRootUrl();
if (checkInUrl === void 0) {
return void 0;
}
checkInUrl.pathname += "check-in";
return checkInUrl;
}
async getSourceUrl() { async getSourceUrl() {
const p = this.sourceParameters; const p = this.sourceParameters;
if (p.url) { if (p.url) {

View file

@ -13,7 +13,7 @@ dependencies:
version: 1.1.1 version: 1.1.1
detsys-ts: detsys-ts:
specifier: github:DeterminateSystems/detsys-ts specifier: github:DeterminateSystems/detsys-ts
version: github.com/DeterminateSystems/detsys-ts/9d66d2c89c150f796165fdcc20b3be538807c0f4 version: github.com/DeterminateSystems/detsys-ts/fe64ba33b4bdeec0991bb65ae00420bf68b9954c
got: got:
specifier: ^14.3.0 specifier: ^14.3.0
version: 14.3.0 version: 14.3.0
@ -3826,8 +3826,8 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dev: true dev: true
github.com/DeterminateSystems/detsys-ts/9d66d2c89c150f796165fdcc20b3be538807c0f4: github.com/DeterminateSystems/detsys-ts/fe64ba33b4bdeec0991bb65ae00420bf68b9954c:
resolution: {tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/9d66d2c89c150f796165fdcc20b3be538807c0f4} resolution: {tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/fe64ba33b4bdeec0991bb65ae00420bf68b9954c}
name: detsys-ts name: detsys-ts
version: 1.0.0 version: 1.0.0
dependencies: dependencies: