From b165581b395d75f1d6f1942004373310218b631b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 17 Jun 2024 10:05:22 -0400 Subject: [PATCH 1/6] Support single-platform evaluations for home manager --- dist/index.js | 285 +++++++++++--------------------------------- dist/index.js.map | 2 +- src/cli/mod.rs | 14 +++ src/flake_info.rs | 37 +++--- src/push_context.rs | 7 +- ts/index.ts | 5 + 6 files changed, 117 insertions(+), 233 deletions(-) diff --git a/dist/index.js b/dist/index.js index 939a5f7f..89f7b6f6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -43671,7 +43671,7 @@ module.exports = self => { const tls = __nccwpck_require__(4404); const http = __nccwpck_require__(3685); const https = __nccwpck_require__(5687); -const JSStreamSocket = __nccwpck_require__(3595); +const JSStreamSocket = __nccwpck_require__(8679); const {globalAgent} = __nccwpck_require__(1840); const UnexpectedStatusCodeError = __nccwpck_require__(8859); const initialize = __nccwpck_require__(4031); @@ -43860,7 +43860,7 @@ module.exports = Http2OverHttp2; const {Agent} = __nccwpck_require__(1840); -const JSStreamSocket = __nccwpck_require__(3595); +const JSStreamSocket = __nccwpck_require__(8679); const UnexpectedStatusCodeError = __nccwpck_require__(8859); const initialize = __nccwpck_require__(4031); @@ -44129,7 +44129,7 @@ module.exports = header => { /***/ }), -/***/ 3595: +/***/ 8679: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { @@ -76944,7 +76944,7 @@ module.exports.implForWrapper = function (wrapper) { var builder, defaults, escapeCDATA, requiresCDATA, wrapCDATA, hasProp = {}.hasOwnProperty; - builder = __nccwpck_require__(9399); + builder = __nccwpck_require__(3595); defaults = (__nccwpck_require__(4617).defaults); @@ -81851,7 +81851,7 @@ module.exports.implForWrapper = function (wrapper) { /***/ }), -/***/ 9399: +/***/ 3595: /***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { // Generated by CoffeeScript 1.12.7 @@ -86333,6 +86333,10 @@ var external_node_util_ = __nccwpck_require__(7261); var external_os_ = __nccwpck_require__(2037); ;// CONCATENATED MODULE: external "node:crypto" const external_node_crypto_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:crypto"); +;// CONCATENATED MODULE: external "node:dns/promises" +const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:dns/promises"); +// EXTERNAL MODULE: ./node_modules/.pnpm/@actions+cache@3.2.4/node_modules/@actions/cache/lib/cache.js +var cache = __nccwpck_require__(6878); ;// CONCATENATED MODULE: ./node_modules/.pnpm/@sindresorhus+is@6.3.1/node_modules/@sindresorhus/is/dist/index.js const typedArrayTypeNames = [ 'Int8Array', @@ -87764,7 +87768,7 @@ class PCancelable { Object.setPrototypeOf(PCancelable.prototype, Promise.prototype); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/errors.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/errors.js // A hacky check to prevent circular references. function isRequest(x) { @@ -89854,13 +89858,13 @@ getContentLength_fn = function() { }; -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/is-form-data.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-form-data.js function is_form_data_isFormData(body) { return dist.nodeStream(body) && dist.function_(body.getBoundary); } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/get-body-size.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/get-body-size.js @@ -89884,7 +89888,7 @@ async function getBodySize(body, headers) { return undefined; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/proxy-events.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/proxy-events.js function proxyEvents(from, to, events) { const eventFunctions = {}; for (const event of events) { @@ -89903,7 +89907,7 @@ function proxyEvents(from, to, events) { ;// CONCATENATED MODULE: external "node:net" const external_node_net_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:net"); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/unhandle.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/unhandle.js // When attaching listeners, it's very easy to forget about them. // Especially if you do error handling and set timeouts. // So instead of checking if it's proper to throw an error on every timeout ever, @@ -89925,7 +89929,7 @@ function unhandle() { }; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/timed-out.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/timed-out.js const reentry = Symbol('reentry'); @@ -90056,7 +90060,7 @@ function timedOut(request, delays, options) { return cancelTimeouts; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/url-to-options.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/url-to-options.js function urlToOptions(url) { // Cast to URL @@ -90080,7 +90084,7 @@ function urlToOptions(url) { return options; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/weakable-map.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/weakable-map.js class WeakableMap { weakMap; map; @@ -90110,7 +90114,7 @@ class WeakableMap { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/calculate-retry-delay.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/calculate-retry-delay.js const calculateRetryDelay = ({ attemptCount, retryOptions, error, retryAfter, computedValue, }) => { if (error.name === 'RetryError') { return 1; @@ -90597,7 +90601,7 @@ class CacheableLookup { // EXTERNAL MODULE: ./node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/index.js var http2_wrapper_source = __nccwpck_require__(9695); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/parse-link-header.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/parse-link-header.js function parseLinkHeader(link) { const parsed = []; const items = link.split(','); @@ -90632,7 +90636,7 @@ function parseLinkHeader(link) { return parsed; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/options.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/options.js @@ -92269,7 +92273,7 @@ class Options { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/response.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/response.js const isResponseOk = (response) => { const { statusCode } = response; @@ -92312,19 +92316,19 @@ const parseBody = (response, responseType, parseJson, encoding) => { }, response); }; -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/is-client-request.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-client-request.js function isClientRequest(clientRequest) { return clientRequest.writable && !clientRequest.writableEnded; } /* harmony default export */ const is_client_request = (isClientRequest); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/is-unix-socket-url.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-unix-socket-url.js // eslint-disable-next-line @typescript-eslint/naming-convention function isUnixSocketURL(url) { return url.protocol === 'unix:' || url.hostname === 'unix'; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/index.js @@ -93328,7 +93332,7 @@ class Request extends external_node_stream_.Duplex { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/as-promise/types.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/as-promise/types.js /** An error to be thrown when the request is aborted with `.cancel()`. @@ -93347,7 +93351,7 @@ class types_CancelError extends RequestError { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/as-promise/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/as-promise/index.js @@ -93513,7 +93517,7 @@ function asPromise(firstRequest) { return promise; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/create.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/create.js @@ -93698,7 +93702,7 @@ const create = (defaults) => { }; /* harmony default export */ const source_create = (create); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/index.js const defaults = { @@ -93721,10 +93725,6 @@ const got = source_create(defaults); -;// CONCATENATED MODULE: external "node:dns/promises" -const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:dns/promises"); -// EXTERNAL MODULE: ./node_modules/.pnpm/@actions+cache@3.2.4/node_modules/@actions/cache/lib/cache.js -var cache = __nccwpck_require__(6878); ;// CONCATENATED MODULE: external "node:child_process" const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process"); ;// CONCATENATED MODULE: external "node:fs/promises" @@ -93735,7 +93735,7 @@ const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(impo const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises"); ;// CONCATENATED MODULE: external "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@bc45b6c0a6318ae30192c4bf23a73dc879bdb632_gnkvhsupsr4227wkpq3ncrmpsq/node_modules/detsys-ts/dist/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@9d66d2c89c150f796165fdcc20b3be538807c0f4_46ybmzqhaua4eiwu3nj2qm63te/node_modules/detsys-ts/dist/index.js var __defProp = Object.defineProperty; var __export = (target, all) => { for (var name in all) @@ -94053,7 +94053,6 @@ function stringifyError(e) { // src/ids-host.ts - var DEFAULT_LOOKUP = "_detsys_ids._tcp.install.determinate.systems."; var ALLOWED_SUFFIXES = [ ".install.determinate.systems", @@ -94061,56 +94060,11 @@ var ALLOWED_SUFFIXES = [ ]; var DEFAULT_IDS_HOST = "https://install.determinate.systems"; var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP; -var DEFAULT_TIMEOUT = 3e4; var IdsHost = class { constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) { this.idsProjectName = idsProjectName; this.diagnosticsSuffix = diagnosticsSuffix; this.runtimeDiagnosticsUrl = runtimeDiagnosticsUrl; - this.client = void 0; - } - async getGot(recordFailoverCallback) { - if (this.client === void 0) { - this.client = got_dist_source.extend({ - timeout: { - request: DEFAULT_TIMEOUT - }, - retry: { - limit: (await this.getUrlsByPreference()).length, - methods: ["GET", "HEAD"] - }, - hooks: { - beforeRetry: [ - async (error3, retryCount) => { - const prevUrl = await this.getRootUrl(); - this.markCurrentHostBroken(); - const nextUrl = await this.getRootUrl(); - if (recordFailoverCallback !== void 0) { - recordFailoverCallback(prevUrl, nextUrl); - } - core.info( - `Retrying after error ${error3.code}, retry #: ${retryCount}` - ); - } - ], - beforeRequest: [ - async (options) => { - const currentUrl = options.url; - if (this.isUrlSubjectToDynamicUrls(currentUrl)) { - const newUrl = new URL(currentUrl); - const url = await this.getRootUrl(); - newUrl.host = url.host; - options.url = newUrl; - core.debug(`Transmuted ${currentUrl} into ${newUrl}`); - } else { - core.debug(`No transmutations on ${currentUrl}`); - } - } - ] - } - }); - } - return this.client; } markCurrentHostBroken() { this.prioritizedURLs?.shift(); @@ -94118,18 +94072,7 @@ var IdsHost = class { setPrioritizedUrls(urls) { this.prioritizedURLs = urls; } - isUrlSubjectToDynamicUrls(url) { - if (url.origin === DEFAULT_IDS_HOST) { - return true; - } - for (const suffix of ALLOWED_SUFFIXES) { - if (url.host.endsWith(suffix)) { - return true; - } - } - return false; - } - async getDynamicRootUrl() { + async getRootUrl() { const idsHost = process.env["IDS_HOST"]; if (idsHost !== void 0) { try { @@ -94150,17 +94093,9 @@ var IdsHost = class { ); } if (url === void 0) { - return void 0; - } else { - return new URL(url); + url = new URL(DEFAULT_IDS_HOST); } - } - async getRootUrl() { - const url = await this.getDynamicRootUrl(); - if (url === void 0) { - return new URL(DEFAULT_IDS_HOST); - } - return url; + return new URL(url); } async getDiagnosticsUrl() { if (this.runtimeDiagnosticsUrl === "") { @@ -94449,6 +94384,7 @@ function noisilyGetInput(suffix, legacyPrefix) { + var EVENT_EXCEPTION = "exception"; var EVENT_ARTIFACT_CACHE_HIT = "artifact_cache_hit"; var EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss"; @@ -94470,7 +94406,6 @@ var STATE_KEY_EXECUTION_PHASE = "detsys_action_execution_phase"; var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found"; var STATE_NOT_FOUND = "not-found"; var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4; -var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3; var DetSysAction = class { determineExecutionPhase() { const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE); @@ -94493,9 +94428,22 @@ var DetSysAction = class { this.exceptionAttachments = /* @__PURE__ */ new Map(); this.nixStoreTrust = "unknown"; this.strictMode = getBool("_internal-strict-mode"); - this.features = {}; - this.featureEventMetadata = {}; this.events = []; + this.client = got_dist_source.extend({ + retry: { + limit: 3, + methods: ["GET", "HEAD"] + }, + hooks: { + beforeRetry: [ + (error3, retryCount) => { + core.info( + `Retrying after error ${error3.code}, retry #: ${retryCount}` + ); + } + ] + } + }); this.facts = { $lib: "idslib", $lib_version: version, @@ -94589,13 +94537,11 @@ var DetSysAction = class { return this.identity; } recordEvent(eventName, context = {}) { - const prefixedName = eventName === "$feature_flag_called" ? eventName : `${this.actionOptions.eventPrefix}${eventName}`; this.events.push({ - event_name: prefixedName, + event_name: `${this.actionOptions.eventPrefix}${eventName}`, context, correlation: this.identity, facts: this.facts, - features: this.featureEventMetadata, timestamp: /* @__PURE__ */ new Date(), uuid: (0,external_node_crypto_namespaceObject.randomUUID)() }); @@ -94631,7 +94577,6 @@ var DetSysAction = class { } async executeAsync() { try { - await this.checkIn(); process.env.DETSYS_CORRELATION = JSON.stringify( this.getCorrelationHashes() ); @@ -94679,102 +94624,6 @@ var DetSysAction = class { await this.complete(); } } - async getClient() { - return await this.idsHost.getGot((prevUrl, nextUrl) => { - this.recordEvent("ids-failover", { - previousUrl: prevUrl.toString(), - nextUrl: nextUrl.toString() - }); - }); - } - 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[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.getClient()).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 * `source-*` inputs. If `source-binary` is specified, this will return a path @@ -94799,7 +94648,7 @@ var DetSysAction = class { "correlation", JSON.stringify(this.identity) ); - const versionCheckup = await (await this.getClient()).head(correlatedUrl); + const versionCheckup = await this.client.head(correlatedUrl); if (versionCheckup.headers.etag) { const v = versionCheckup.headers.etag; this.addFact(FACT_SOURCE_URL_ETAG, v); @@ -94818,7 +94667,7 @@ var DetSysAction = class { `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}` ); const destFile = this.getTemporaryName(); - const fetchStream = (await this.getClient()).stream(versionCheckup.url); + const fetchStream = this.client.stream(versionCheckup.url); await (0,external_node_stream_promises_namespaceObject.pipeline)( fetchStream, (0,external_node_fs_namespaceObject.createWriteStream)(destFile, { @@ -94852,14 +94701,6 @@ var DetSysAction = class { this.recordEvent(`complete_${this.executionPhase}`); 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() { const p = this.sourceParameters; if (p.url) { @@ -95036,16 +94877,32 @@ var DetSysAction = class { events: this.events }; try { - await (await this.getClient()).post(diagnosticsUrl, { + await this.client.post(diagnosticsUrl, { json: batch, timeout: { request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS } }); - } catch (err) { + } catch (e) { core.debug( - `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError2(err)}` + `Error submitting diagnostics event: ${stringifyError2(e)}` ); + this.idsHost.markCurrentHostBroken(); + const secondaryDiagnosticsUrl = await this.idsHost.getDiagnosticsUrl(); + if (secondaryDiagnosticsUrl !== void 0) { + try { + await this.client.post(secondaryDiagnosticsUrl, { + json: batch, + timeout: { + request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS + } + }); + } catch (err) { + core.debug( + `Error submitting diagnostics event to secondary host (${secondaryDiagnosticsUrl}): ${stringifyError2(err)}` + ); + } + } } this.events = []; } @@ -95103,6 +94960,7 @@ var FlakeHubPushAction = class extends DetSysAction { this.repository = inputs_exports.getString("repository"); this.directory = inputs_exports.getString("directory"); this.gitRoot = inputs_exports.getString("git-root"); + this.singleSystemEvaluation = inputs_exports.getBool("single-system-evaluation"); this.spdxExpression = inputs_exports.getString("spdx-expression"); this.errorOnConflict = inputs_exports.getBool("error-on-conflict"); this.includeOutputPaths = inputs_exports.getBool("include-output-paths"); @@ -95143,6 +95001,7 @@ var FlakeHubPushAction = class extends DetSysAction { env.FLAKEHUB_PUSH_REPOSITORY = this.repository; env.FLAKEHUB_PUSH_DIRECTORY = this.directory; env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot; + env.FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION = this.singleSystemEvaluation.toString(); env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels; env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression; env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString(); diff --git a/dist/index.js.map b/dist/index.js.map index ed91b7c4..ac8aafb7 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":"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","names":[]} \ No newline at end of file +{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private singleSystemEvaluation: boolean;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.singleSystemEvaluation = inputs.getBool(\"single-system-evaluation\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n env.FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION =\n this.singleSystemEvaluation.toString();\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":"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","names":[]} \ No newline at end of file diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 138a2ec9..0a94b298 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -87,6 +87,20 @@ pub(crate) struct FlakeHubPushCli { )] pub(crate) error_on_conflict: bool, + /// Single-system evaluation. + /// + /// This flag is intended to limit the scope of evaluations which are too large to complete on one machine. + /// This flag should NOT be used to paper over evaluation errors across different architectures. + /// + /// Please do not turn this flag on without opening an issue to decide if it applies to your scenario. + #[clap( + long, + env = "FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION", + value_parser = EmptyBoolParser, + default_value_t = false + )] + pub(crate) single_system_evaluation: bool, + #[clap(flatten)] pub instrumentation: instrumentation::Instrumentation, diff --git a/src/flake_info.rs b/src/flake_info.rs index 9f670f74..d04dd0bd 100644 --- a/src/flake_info.rs +++ b/src/flake_info.rs @@ -19,13 +19,14 @@ pub struct FlakeMetadata { pub(crate) source_dir: std::path::PathBuf, pub(crate) flake_locked_url: String, pub(crate) metadata_json: serde_json::Value, + single_system_evaluation: bool, } #[derive(Debug, Deserialize)] pub struct FlakeOutputs(pub serde_json::Value); impl FlakeMetadata { - pub async fn from_dir(directory: &Path) -> Result { + pub async fn from_dir(directory: &Path, single_system_evaluation: bool) -> Result { let output = tokio::process::Command::new("nix") .arg("flake") .arg("metadata") @@ -77,27 +78,31 @@ impl FlakeMetadata { source_dir: source, flake_locked_url: flake_locked_url.to_string(), metadata_json, + single_system_evaluation, }) } /// check_evalutes checks that the flake evaluates /// (note it is not necessary for the target to have a flake.lock) pub async fn check_evaluates(&self) -> Result<()> { - let output = tokio::process::Command::new("nix") - .arg("flake") - .arg("show") - .arg("--all-systems") - .arg("--json") - .arg("--no-write-lock-file") - .arg(&self.source_dir) - .output() - .await - .wrap_err_with(|| { - eyre!( - "Failed to execute `nix flake show --all-systems --json --no-write-lock-file {}`", - self.source_dir.display() - ) - })?; + let mut command = tokio::process::Command::new("nix"); + command.arg("flake"); + command.arg("show"); + + if !self.single_system_evaluation { + command.arg("--all-systems"); + } + + command.arg("--json"); + command.arg("--no-write-lock-file"); + command.arg(&self.source_dir); + + let output = command.output().await.wrap_err_with(|| { + eyre!( + "Failed to execute `nix flake show --all-systems --json --no-write-lock-file {}`", + self.source_dir.display() + ) + })?; if !output.status.success() { let command = format!( diff --git a/src/push_context.rs b/src/push_context.rs index 2b718875..6adf0ed3 100644 --- a/src/push_context.rs +++ b/src/push_context.rs @@ -325,9 +325,10 @@ impl PushContext { let flake_dir = local_git_root.join(&subdir); // FIXME: bail out if flake_metadata denotes a dirty tree. - let flake_metadata = flake_info::FlakeMetadata::from_dir(&flake_dir) - .await - .wrap_err("Getting flake metadata")?; + let flake_metadata = + flake_info::FlakeMetadata::from_dir(&flake_dir, cli.single_system_evaluation) + .await + .wrap_err("Getting flake metadata")?; tracing::debug!("Got flake metadata: {:?}", flake_metadata); // sanity checks diff --git a/ts/index.ts b/ts/index.ts index 60025c4b..8b32fa6b 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -15,6 +15,7 @@ type ExecutionEnvironment = { FLAKEHUB_PUSH_REPOSITORY?: string; FLAKEHUB_PUSH_DIRECTORY?: string; FLAKEHUB_PUSH_GIT_ROOT?: string; + FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION?: string; FLAKEHUB_PUSH_EXTRA_LABELS?: string; FLAKEHUB_PUSH_SPDX_EXPRESSION?: string; FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string; @@ -35,6 +36,7 @@ class FlakeHubPushAction extends DetSysAction { private repository: string; private directory: string; private gitRoot: string; + private singleSystemEvaluation: boolean; private spdxExpression: string; private errorOnConflict: boolean; private includeOutputPaths: boolean; @@ -62,6 +64,7 @@ class FlakeHubPushAction extends DetSysAction { this.repository = inputs.getString("repository"); this.directory = inputs.getString("directory"); this.gitRoot = inputs.getString("git-root"); + this.singleSystemEvaluation = inputs.getBool("single-system-evaluation"); this.spdxExpression = inputs.getString("spdx-expression"); this.errorOnConflict = inputs.getBool("error-on-conflict"); this.includeOutputPaths = inputs.getBool("include-output-paths"); @@ -114,6 +117,8 @@ class FlakeHubPushAction extends DetSysAction { env.FLAKEHUB_PUSH_REPOSITORY = this.repository; env.FLAKEHUB_PUSH_DIRECTORY = this.directory; env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot; + env.FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION = + this.singleSystemEvaluation.toString(); // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels; env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression; From 8bffb798ab01f75582bb0d30dafadf28660fc457 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 17 Jun 2024 10:22:51 -0400 Subject: [PATCH 2/6] repack --- dist/index.js | 283 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 213 insertions(+), 70 deletions(-) diff --git a/dist/index.js b/dist/index.js index 89f7b6f6..461be02f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -43671,7 +43671,7 @@ module.exports = self => { const tls = __nccwpck_require__(4404); const http = __nccwpck_require__(3685); const https = __nccwpck_require__(5687); -const JSStreamSocket = __nccwpck_require__(8679); +const JSStreamSocket = __nccwpck_require__(3595); const {globalAgent} = __nccwpck_require__(1840); const UnexpectedStatusCodeError = __nccwpck_require__(8859); const initialize = __nccwpck_require__(4031); @@ -43860,7 +43860,7 @@ module.exports = Http2OverHttp2; const {Agent} = __nccwpck_require__(1840); -const JSStreamSocket = __nccwpck_require__(8679); +const JSStreamSocket = __nccwpck_require__(3595); const UnexpectedStatusCodeError = __nccwpck_require__(8859); const initialize = __nccwpck_require__(4031); @@ -44129,7 +44129,7 @@ module.exports = header => { /***/ }), -/***/ 8679: +/***/ 3595: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { @@ -76944,7 +76944,7 @@ module.exports.implForWrapper = function (wrapper) { var builder, defaults, escapeCDATA, requiresCDATA, wrapCDATA, hasProp = {}.hasOwnProperty; - builder = __nccwpck_require__(3595); + builder = __nccwpck_require__(9399); defaults = (__nccwpck_require__(4617).defaults); @@ -81851,7 +81851,7 @@ module.exports.implForWrapper = function (wrapper) { /***/ }), -/***/ 3595: +/***/ 9399: /***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { // Generated by CoffeeScript 1.12.7 @@ -86333,10 +86333,6 @@ var external_node_util_ = __nccwpck_require__(7261); var external_os_ = __nccwpck_require__(2037); ;// CONCATENATED MODULE: external "node:crypto" const external_node_crypto_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:crypto"); -;// CONCATENATED MODULE: external "node:dns/promises" -const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:dns/promises"); -// EXTERNAL MODULE: ./node_modules/.pnpm/@actions+cache@3.2.4/node_modules/@actions/cache/lib/cache.js -var cache = __nccwpck_require__(6878); ;// CONCATENATED MODULE: ./node_modules/.pnpm/@sindresorhus+is@6.3.1/node_modules/@sindresorhus/is/dist/index.js const typedArrayTypeNames = [ 'Int8Array', @@ -87768,7 +87764,7 @@ class PCancelable { Object.setPrototypeOf(PCancelable.prototype, Promise.prototype); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/errors.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/errors.js // A hacky check to prevent circular references. function isRequest(x) { @@ -89858,13 +89854,13 @@ getContentLength_fn = function() { }; -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-form-data.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/is-form-data.js function is_form_data_isFormData(body) { return dist.nodeStream(body) && dist.function_(body.getBoundary); } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/get-body-size.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/get-body-size.js @@ -89888,7 +89884,7 @@ async function getBodySize(body, headers) { return undefined; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/proxy-events.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/proxy-events.js function proxyEvents(from, to, events) { const eventFunctions = {}; for (const event of events) { @@ -89907,7 +89903,7 @@ function proxyEvents(from, to, events) { ;// CONCATENATED MODULE: external "node:net" const external_node_net_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:net"); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/unhandle.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/unhandle.js // When attaching listeners, it's very easy to forget about them. // Especially if you do error handling and set timeouts. // So instead of checking if it's proper to throw an error on every timeout ever, @@ -89929,7 +89925,7 @@ function unhandle() { }; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/timed-out.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/timed-out.js const reentry = Symbol('reentry'); @@ -90060,7 +90056,7 @@ function timedOut(request, delays, options) { return cancelTimeouts; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/url-to-options.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/url-to-options.js function urlToOptions(url) { // Cast to URL @@ -90084,7 +90080,7 @@ function urlToOptions(url) { return options; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/weakable-map.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/weakable-map.js class WeakableMap { weakMap; map; @@ -90114,7 +90110,7 @@ class WeakableMap { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/calculate-retry-delay.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/calculate-retry-delay.js const calculateRetryDelay = ({ attemptCount, retryOptions, error, retryAfter, computedValue, }) => { if (error.name === 'RetryError') { return 1; @@ -90601,7 +90597,7 @@ class CacheableLookup { // EXTERNAL MODULE: ./node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/index.js var http2_wrapper_source = __nccwpck_require__(9695); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/parse-link-header.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/parse-link-header.js function parseLinkHeader(link) { const parsed = []; const items = link.split(','); @@ -90636,7 +90632,7 @@ function parseLinkHeader(link) { return parsed; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/options.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/options.js @@ -92273,7 +92269,7 @@ class Options { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/response.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/response.js const isResponseOk = (response) => { const { statusCode } = response; @@ -92316,19 +92312,19 @@ const parseBody = (response, responseType, parseJson, encoding) => { }, response); }; -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-client-request.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/is-client-request.js function isClientRequest(clientRequest) { return clientRequest.writable && !clientRequest.writableEnded; } /* harmony default export */ const is_client_request = (isClientRequest); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-unix-socket-url.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/utils/is-unix-socket-url.js // eslint-disable-next-line @typescript-eslint/naming-convention function isUnixSocketURL(url) { return url.protocol === 'unix:' || url.hostname === 'unix'; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/core/index.js @@ -93332,7 +93328,7 @@ class Request extends external_node_stream_.Duplex { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/as-promise/types.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/as-promise/types.js /** An error to be thrown when the request is aborted with `.cancel()`. @@ -93351,7 +93347,7 @@ class types_CancelError extends RequestError { } } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/as-promise/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/as-promise/index.js @@ -93517,7 +93513,7 @@ function asPromise(firstRequest) { return promise; } -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/create.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/create.js @@ -93702,7 +93698,7 @@ const create = (defaults) => { }; /* harmony default export */ const source_create = (create); -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.4.0/node_modules/got/dist/source/index.js const defaults = { @@ -93725,6 +93721,10 @@ const got = source_create(defaults); +;// CONCATENATED MODULE: external "node:dns/promises" +const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:dns/promises"); +// EXTERNAL MODULE: ./node_modules/.pnpm/@actions+cache@3.2.4/node_modules/@actions/cache/lib/cache.js +var cache = __nccwpck_require__(6878); ;// CONCATENATED MODULE: external "node:child_process" const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process"); ;// CONCATENATED MODULE: external "node:fs/promises" @@ -93735,7 +93735,7 @@ const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(impo const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises"); ;// CONCATENATED MODULE: external "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@bc45b6c0a6318ae30192c4bf23a73dc879bdb632_gnkvhsupsr4227wkpq3ncrmpsq/node_modules/detsys-ts/dist/index.js var __defProp = Object.defineProperty; var __export = (target, all) => { for (var name in all) @@ -94053,6 +94053,7 @@ function stringifyError(e) { // src/ids-host.ts + var DEFAULT_LOOKUP = "_detsys_ids._tcp.install.determinate.systems."; var ALLOWED_SUFFIXES = [ ".install.determinate.systems", @@ -94060,11 +94061,56 @@ var ALLOWED_SUFFIXES = [ ]; var DEFAULT_IDS_HOST = "https://install.determinate.systems"; var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP; +var DEFAULT_TIMEOUT = 3e4; var IdsHost = class { constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) { this.idsProjectName = idsProjectName; this.diagnosticsSuffix = diagnosticsSuffix; this.runtimeDiagnosticsUrl = runtimeDiagnosticsUrl; + this.client = void 0; + } + async getGot(recordFailoverCallback) { + if (this.client === void 0) { + this.client = got_dist_source.extend({ + timeout: { + request: DEFAULT_TIMEOUT + }, + retry: { + limit: (await this.getUrlsByPreference()).length, + methods: ["GET", "HEAD"] + }, + hooks: { + beforeRetry: [ + async (error3, retryCount) => { + const prevUrl = await this.getRootUrl(); + this.markCurrentHostBroken(); + const nextUrl = await this.getRootUrl(); + if (recordFailoverCallback !== void 0) { + recordFailoverCallback(prevUrl, nextUrl); + } + core.info( + `Retrying after error ${error3.code}, retry #: ${retryCount}` + ); + } + ], + beforeRequest: [ + async (options) => { + const currentUrl = options.url; + if (this.isUrlSubjectToDynamicUrls(currentUrl)) { + const newUrl = new URL(currentUrl); + const url = await this.getRootUrl(); + newUrl.host = url.host; + options.url = newUrl; + core.debug(`Transmuted ${currentUrl} into ${newUrl}`); + } else { + core.debug(`No transmutations on ${currentUrl}`); + } + } + ] + } + }); + } + return this.client; } markCurrentHostBroken() { this.prioritizedURLs?.shift(); @@ -94072,7 +94118,18 @@ var IdsHost = class { setPrioritizedUrls(urls) { this.prioritizedURLs = urls; } - async getRootUrl() { + isUrlSubjectToDynamicUrls(url) { + if (url.origin === DEFAULT_IDS_HOST) { + return true; + } + for (const suffix of ALLOWED_SUFFIXES) { + if (url.host.endsWith(suffix)) { + return true; + } + } + return false; + } + async getDynamicRootUrl() { const idsHost = process.env["IDS_HOST"]; if (idsHost !== void 0) { try { @@ -94093,9 +94150,17 @@ var IdsHost = class { ); } 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() { if (this.runtimeDiagnosticsUrl === "") { @@ -94384,7 +94449,6 @@ function noisilyGetInput(suffix, legacyPrefix) { - var EVENT_EXCEPTION = "exception"; var EVENT_ARTIFACT_CACHE_HIT = "artifact_cache_hit"; var EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss"; @@ -94406,6 +94470,7 @@ var STATE_KEY_EXECUTION_PHASE = "detsys_action_execution_phase"; var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found"; var STATE_NOT_FOUND = "not-found"; var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4; +var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3; var DetSysAction = class { determineExecutionPhase() { const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE); @@ -94428,22 +94493,9 @@ var DetSysAction = class { this.exceptionAttachments = /* @__PURE__ */ new Map(); this.nixStoreTrust = "unknown"; this.strictMode = getBool("_internal-strict-mode"); + this.features = {}; + this.featureEventMetadata = {}; this.events = []; - this.client = got_dist_source.extend({ - retry: { - limit: 3, - methods: ["GET", "HEAD"] - }, - hooks: { - beforeRetry: [ - (error3, retryCount) => { - core.info( - `Retrying after error ${error3.code}, retry #: ${retryCount}` - ); - } - ] - } - }); this.facts = { $lib: "idslib", $lib_version: version, @@ -94537,11 +94589,13 @@ var DetSysAction = class { return this.identity; } recordEvent(eventName, context = {}) { + const prefixedName = eventName === "$feature_flag_called" ? eventName : `${this.actionOptions.eventPrefix}${eventName}`; this.events.push({ - event_name: `${this.actionOptions.eventPrefix}${eventName}`, + event_name: prefixedName, context, correlation: this.identity, facts: this.facts, + features: this.featureEventMetadata, timestamp: /* @__PURE__ */ new Date(), uuid: (0,external_node_crypto_namespaceObject.randomUUID)() }); @@ -94577,6 +94631,7 @@ var DetSysAction = class { } async executeAsync() { try { + await this.checkIn(); process.env.DETSYS_CORRELATION = JSON.stringify( this.getCorrelationHashes() ); @@ -94624,6 +94679,102 @@ var DetSysAction = class { await this.complete(); } } + async getClient() { + return await this.idsHost.getGot((prevUrl, nextUrl) => { + this.recordEvent("ids-failover", { + previousUrl: prevUrl.toString(), + nextUrl: nextUrl.toString() + }); + }); + } + 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[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.getClient()).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 * `source-*` inputs. If `source-binary` is specified, this will return a path @@ -94648,7 +94799,7 @@ var DetSysAction = class { "correlation", JSON.stringify(this.identity) ); - const versionCheckup = await this.client.head(correlatedUrl); + const versionCheckup = await (await this.getClient()).head(correlatedUrl); if (versionCheckup.headers.etag) { const v = versionCheckup.headers.etag; this.addFact(FACT_SOURCE_URL_ETAG, v); @@ -94667,7 +94818,7 @@ var DetSysAction = class { `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}` ); const destFile = this.getTemporaryName(); - const fetchStream = this.client.stream(versionCheckup.url); + const fetchStream = (await this.getClient()).stream(versionCheckup.url); await (0,external_node_stream_promises_namespaceObject.pipeline)( fetchStream, (0,external_node_fs_namespaceObject.createWriteStream)(destFile, { @@ -94701,6 +94852,14 @@ var DetSysAction = class { this.recordEvent(`complete_${this.executionPhase}`); 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() { const p = this.sourceParameters; if (p.url) { @@ -94877,32 +95036,16 @@ var DetSysAction = class { events: this.events }; try { - await this.client.post(diagnosticsUrl, { + await (await this.getClient()).post(diagnosticsUrl, { json: batch, timeout: { request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS } }); - } catch (e) { + } catch (err) { core.debug( - `Error submitting diagnostics event: ${stringifyError2(e)}` + `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError2(err)}` ); - this.idsHost.markCurrentHostBroken(); - const secondaryDiagnosticsUrl = await this.idsHost.getDiagnosticsUrl(); - if (secondaryDiagnosticsUrl !== void 0) { - try { - await this.client.post(secondaryDiagnosticsUrl, { - json: batch, - timeout: { - request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS - } - }); - } catch (err) { - core.debug( - `Error submitting diagnostics event to secondary host (${secondaryDiagnosticsUrl}): ${stringifyError2(err)}` - ); - } - } } this.events = []; } From 85f23c3eaba05e5b1f793bbfe290024c071e2719 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 17 Jun 2024 10:41:22 -0400 Subject: [PATCH 3/6] Update src/cli/mod.rs Co-authored-by: Cole Helbling --- src/cli/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 0a94b298..5527dc6d 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -98,7 +98,7 @@ pub(crate) struct FlakeHubPushCli { env = "FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION", value_parser = EmptyBoolParser, default_value_t = false - )] + )] pub(crate) single_system_evaluation: bool, #[clap(flatten)] From e3b56a3604bc7065c01047a5a270ec060fefb744 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 17 Jun 2024 11:31:04 -0400 Subject: [PATCH 4/6] Don't run schemas on gigantic flakes --- src/flake_info.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/flake_info.rs b/src/flake_info.rs index d04dd0bd..e9f6e9ba 100644 --- a/src/flake_info.rs +++ b/src/flake_info.rs @@ -241,6 +241,10 @@ impl FlakeMetadata { } pub async fn outputs(&self, include_output_paths: bool) -> Result { + if self.single_system_evaluation { + return Ok(FlakeOutputs(serde_json::json!({}))); + } + let tempdir = tempfile::Builder::new() .prefix("flakehub_push_outputs") .tempdir() From 29a87cfadea58f28df7ed6f168a67b7eae12f880 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 17 Jun 2024 12:06:24 -0400 Subject: [PATCH 5/6] rename single system evaluation to my-flake-is-too-big, ref 'my spoon is too big'. --- dist/index.js | 4 ++-- dist/index.js.map | 2 +- src/cli/mod.rs | 4 ++-- src/flake_info.rs | 10 +++++----- src/push_context.rs | 2 +- ts/index.ts | 9 ++++----- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/dist/index.js b/dist/index.js index 461be02f..6c4ebc8b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -95103,7 +95103,7 @@ var FlakeHubPushAction = class extends DetSysAction { this.repository = inputs_exports.getString("repository"); this.directory = inputs_exports.getString("directory"); this.gitRoot = inputs_exports.getString("git-root"); - this.singleSystemEvaluation = inputs_exports.getBool("single-system-evaluation"); + this.myFlakeIsTooBig = inputs_exports.getBool("my-flake-is-too-big"); this.spdxExpression = inputs_exports.getString("spdx-expression"); this.errorOnConflict = inputs_exports.getBool("error-on-conflict"); this.includeOutputPaths = inputs_exports.getBool("include-output-paths"); @@ -95144,7 +95144,7 @@ var FlakeHubPushAction = class extends DetSysAction { env.FLAKEHUB_PUSH_REPOSITORY = this.repository; env.FLAKEHUB_PUSH_DIRECTORY = this.directory; env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot; - env.FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION = this.singleSystemEvaluation.toString(); + env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString(); env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels; env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression; env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString(); diff --git a/dist/index.js.map b/dist/index.js.map index ac8aafb7..7751ffc6 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private singleSystemEvaluation: boolean;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.singleSystemEvaluation = inputs.getBool(\"single-system-evaluation\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n env.FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION =\n this.singleSystemEvaluation.toString();\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":"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","names":[]} \ No newline at end of file +{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private myFlakeIsTooBig: boolean;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.myFlakeIsTooBig = inputs.getBool(\"my-flake-is-too-big\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString();\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":"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","names":[]} \ No newline at end of file diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 5527dc6d..aaff3049 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -95,11 +95,11 @@ pub(crate) struct FlakeHubPushCli { /// Please do not turn this flag on without opening an issue to decide if it applies to your scenario. #[clap( long, - env = "FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION", + env = "FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG", value_parser = EmptyBoolParser, default_value_t = false )] - pub(crate) single_system_evaluation: bool, + pub(crate) my_flake_is_too_big: bool, #[clap(flatten)] pub instrumentation: instrumentation::Instrumentation, diff --git a/src/flake_info.rs b/src/flake_info.rs index e9f6e9ba..d79830b7 100644 --- a/src/flake_info.rs +++ b/src/flake_info.rs @@ -19,14 +19,14 @@ pub struct FlakeMetadata { pub(crate) source_dir: std::path::PathBuf, pub(crate) flake_locked_url: String, pub(crate) metadata_json: serde_json::Value, - single_system_evaluation: bool, + my_flake_is_too_big: bool, } #[derive(Debug, Deserialize)] pub struct FlakeOutputs(pub serde_json::Value); impl FlakeMetadata { - pub async fn from_dir(directory: &Path, single_system_evaluation: bool) -> Result { + pub async fn from_dir(directory: &Path, my_flake_is_too_big: bool) -> Result { let output = tokio::process::Command::new("nix") .arg("flake") .arg("metadata") @@ -78,7 +78,7 @@ impl FlakeMetadata { source_dir: source, flake_locked_url: flake_locked_url.to_string(), metadata_json, - single_system_evaluation, + my_flake_is_too_big, }) } @@ -89,7 +89,7 @@ impl FlakeMetadata { command.arg("flake"); command.arg("show"); - if !self.single_system_evaluation { + if !self.my_flake_is_too_big { command.arg("--all-systems"); } @@ -241,7 +241,7 @@ impl FlakeMetadata { } pub async fn outputs(&self, include_output_paths: bool) -> Result { - if self.single_system_evaluation { + if self.my_flake_is_too_big { return Ok(FlakeOutputs(serde_json::json!({}))); } diff --git a/src/push_context.rs b/src/push_context.rs index 6adf0ed3..05a45fa0 100644 --- a/src/push_context.rs +++ b/src/push_context.rs @@ -326,7 +326,7 @@ impl PushContext { // FIXME: bail out if flake_metadata denotes a dirty tree. let flake_metadata = - flake_info::FlakeMetadata::from_dir(&flake_dir, cli.single_system_evaluation) + flake_info::FlakeMetadata::from_dir(&flake_dir, cli.my_flake_is_too_big) .await .wrap_err("Getting flake metadata")?; tracing::debug!("Got flake metadata: {:?}", flake_metadata); diff --git a/ts/index.ts b/ts/index.ts index 8b32fa6b..50dc295f 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -15,7 +15,7 @@ type ExecutionEnvironment = { FLAKEHUB_PUSH_REPOSITORY?: string; FLAKEHUB_PUSH_DIRECTORY?: string; FLAKEHUB_PUSH_GIT_ROOT?: string; - FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION?: string; + FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG?: string; FLAKEHUB_PUSH_EXTRA_LABELS?: string; FLAKEHUB_PUSH_SPDX_EXPRESSION?: string; FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string; @@ -36,7 +36,7 @@ class FlakeHubPushAction extends DetSysAction { private repository: string; private directory: string; private gitRoot: string; - private singleSystemEvaluation: boolean; + private myFlakeIsTooBig: boolean; private spdxExpression: string; private errorOnConflict: boolean; private includeOutputPaths: boolean; @@ -64,7 +64,7 @@ class FlakeHubPushAction extends DetSysAction { this.repository = inputs.getString("repository"); this.directory = inputs.getString("directory"); this.gitRoot = inputs.getString("git-root"); - this.singleSystemEvaluation = inputs.getBool("single-system-evaluation"); + this.myFlakeIsTooBig = inputs.getBool("my-flake-is-too-big"); this.spdxExpression = inputs.getString("spdx-expression"); this.errorOnConflict = inputs.getBool("error-on-conflict"); this.includeOutputPaths = inputs.getBool("include-output-paths"); @@ -117,8 +117,7 @@ class FlakeHubPushAction extends DetSysAction { env.FLAKEHUB_PUSH_REPOSITORY = this.repository; env.FLAKEHUB_PUSH_DIRECTORY = this.directory; env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot; - env.FLAKEHUB_PUSH_SINGLE_SYSTEM_EVALUATION = - this.singleSystemEvaluation.toString(); + env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString(); // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels; env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression; From 4a50c246d5e676ba99335f1cd7192f36cd517455 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 17 Jun 2024 12:09:51 -0400 Subject: [PATCH 6/6] docs --- src/cli/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index aaff3049..4da5ef33 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -87,12 +87,14 @@ pub(crate) struct FlakeHubPushCli { )] pub(crate) error_on_conflict: bool, - /// Single-system evaluation. + /// Do less work on extremely large flakes. /// /// This flag is intended to limit the scope of evaluations which are too large to complete on one machine. /// This flag should NOT be used to paper over evaluation errors across different architectures. /// /// Please do not turn this flag on without opening an issue to decide if it applies to your scenario. + /// + /// Note: the behavior of this flag could change at any time, please don't count on it for anything specific. #[clap( long, env = "FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG",