Update detsys-ts

This commit is contained in:
Luc Perkins 2024-05-29 15:18:32 -03:00
parent 222f041780
commit 559c3e249c
No known key found for this signature in database
GPG key ID: 16DB1108FB591835
3 changed files with 273 additions and 222 deletions

236
dist/index.js vendored
View file

@ -39513,7 +39513,7 @@ module.exports =
{
parallel : __nccwpck_require__(644),
serial : __nccwpck_require__(4501),
serialOrdered : __nccwpck_require__(3958)
serialOrdered : __nccwpck_require__(2362)
};
@ -39844,7 +39844,7 @@ function parallel(list, iterator, callback)
/***/ 4501:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var serialOrdered = __nccwpck_require__(3958);
var serialOrdered = __nccwpck_require__(2362);
// Public API
module.exports = serial;
@ -39865,7 +39865,7 @@ function serial(list, iterator, callback)
/***/ }),
/***/ 3958:
/***/ 2362:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var iterate = __nccwpck_require__(5748)
@ -47866,7 +47866,7 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
/***/ }),
/***/ 1538:
/***/ 4438:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
;(function (sax) { // wrapper for non-node envs
@ -47942,6 +47942,12 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
parser.ns = Object.create(rootNS)
}
// disallow unquoted attribute values if not otherwise configured
// and strict mode is true
if (parser.opt.unquotedAttributeValues === undefined) {
parser.opt.unquotedAttributeValues = !strict;
}
// mostly just for error reporting
parser.trackPosition = parser.opt.position !== false
if (parser.trackPosition) {
@ -48961,15 +48967,22 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
continue
case S.SGML_DECL:
if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
if (parser.sgmlDecl + c === '--') {
parser.state = S.COMMENT
parser.comment = ''
parser.sgmlDecl = ''
continue;
}
if (parser.doctype && parser.doctype !== true && parser.sgmlDecl) {
parser.state = S.DOCTYPE_DTD
parser.doctype += '<!' + parser.sgmlDecl + c
parser.sgmlDecl = ''
} else if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
emitNode(parser, 'onopencdata')
parser.state = S.CDATA
parser.sgmlDecl = ''
parser.cdata = ''
} else if (parser.sgmlDecl + c === '--') {
parser.state = S.COMMENT
parser.comment = ''
parser.sgmlDecl = ''
} else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
parser.state = S.DOCTYPE
if (parser.doctype || parser.sawRoot) {
@ -49023,12 +49036,18 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
continue
case S.DOCTYPE_DTD:
parser.doctype += c
if (c === ']') {
parser.doctype += c
parser.state = S.DOCTYPE
} else if (c === '<') {
parser.state = S.OPEN_WAKA
parser.startTagPosition = parser.position
} else if (isQuote(c)) {
parser.doctype += c
parser.state = S.DOCTYPE_DTD_QUOTED
parser.q = c
} else {
parser.doctype += c
}
continue
@ -49069,6 +49088,8 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
// which is a comment of " blah -- bloo "
parser.comment += '--' + c
parser.state = S.COMMENT
} else if (parser.doctype && parser.doctype !== true) {
parser.state = S.DOCTYPE_DTD
} else {
parser.state = S.TEXT
}
@ -49236,7 +49257,9 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
parser.q = c
parser.state = S.ATTRIB_VALUE_QUOTED
} else {
strictFail(parser, 'Unquoted attribute value')
if (!parser.opt.unquotedAttributeValues) {
error(parser, 'Unquoted attribute value')
}
parser.state = S.ATTRIB_VALUE_UNQUOTED
parser.attribValue = c
}
@ -49354,13 +49377,13 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
}
if (c === ';') {
if (parser.opt.unparsedEntities) {
var parsedEntity = parseEntity(parser)
var parsedEntity = parseEntity(parser)
if (parser.opt.unparsedEntities && !Object.values(sax.XML_ENTITIES).includes(parsedEntity)) {
parser.entity = ''
parser.state = returnState
parser.write(parsedEntity)
} else {
parser[buffer] += parseEntity(parser)
parser[buffer] += parsedEntity
parser.entity = ''
parser.state = returnState
}
@ -77136,7 +77159,7 @@ module.exports.implForWrapper = function (wrapper) {
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
sax = __nccwpck_require__(1538);
sax = __nccwpck_require__(4438);
events = __nccwpck_require__(2361);
@ -93710,7 +93733,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@ed02129aed8e4d6402d920152652877189bece70_3whmnlhrx56zhgtsjnkrhnutfu/node_modules/detsys-ts/dist/index.js
;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@5fcb0532d85556ebc2de286e483885976531339d_uqngfub4ls4loys67iy653x57e/node_modules/detsys-ts/dist/index.js
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
@ -94018,6 +94041,7 @@ function hashEnvironmentVariables(prefix, variables) {
var inputs_exports = {};
__export(inputs_exports, {
getArrayOfStrings: () => getArrayOfStrings,
getArrayOfStringsOrNull: () => getArrayOfStringsOrNull,
getBool: () => getBool,
getMultilineStringOrNull: () => getMultilineStringOrNull,
getNumberOrNull: () => getNumberOrNull,
@ -94034,6 +94058,14 @@ var getArrayOfStrings = (name, separator) => {
const original = getString(name);
return handleString(original, separator);
};
var getArrayOfStringsOrNull = (name, separator) => {
const original = getStringOrNull(name);
if (original === null) {
return null;
} else {
return handleString(original, separator);
}
};
var handleString = (input, separator) => {
const sepChar = separator === "comma" ? "," : /\s+/;
const trimmed = input.trim();
@ -94165,6 +94197,19 @@ function noisilyGetInput(suffix, legacyPrefix) {
// src/errors.ts
function stringifyError(e) {
if (e instanceof Error) {
return e.message;
} else if (typeof e === "string") {
return e;
} else {
return JSON.stringify(e);
}
}
// src/index.ts
var DEFAULT_IDS_HOST = "https://install.determinate.systems";
var IDS_HOST = process.env["IDS_HOST"] ?? DEFAULT_IDS_HOST;
var EVENT_EXCEPTION = "exception";
@ -94172,6 +94217,7 @@ var EVENT_ARTIFACT_CACHE_HIT = "artifact_cache_hit";
var EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss";
var EVENT_ARTIFACT_CACHE_PERSIST = "artifact_cache_persist";
var EVENT_PREFLIGHT_REQUIRE_NIX_DENIED = "preflight-require-nix-denied";
var FACT_ARTIFACT_FETCHED_FROM_CACHE = "artifact_fetched_from_cache";
var FACT_ENDED_WITH_EXCEPTION = "ended_with_exception";
var FACT_FINAL_EXCEPTION = "final_exception";
var FACT_OS = "$os";
@ -94186,6 +94232,7 @@ var FACT_NIX_STORE_CHECK_ERROR = "nix_store_check_error";
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 DetSysAction = class {
determineExecutionPhase() {
const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE);
@ -94251,7 +94298,7 @@ var DetSysAction = class {
}
}).catch((e) => {
core.debug(
`Failure getting platform details: ${stringifyError(e)}`
`Failure getting platform details: ${stringifyError2(e)}`
);
});
}
@ -94284,16 +94331,6 @@ var DetSysAction = class {
stapleFile(name, location) {
this.exceptionAttachments.set(name, location);
}
setExecutionPhase() {
const phase = core.getState(STATE_KEY_EXECUTION_PHASE);
if (phase === "") {
core.saveState(STATE_KEY_EXECUTION_PHASE, "post");
this.executionPhase = "main";
} else {
this.executionPhase = "post";
}
this.facts.execution_phase = this.executionPhase;
}
/**
* Execute the Action as defined.
*/
@ -94303,7 +94340,55 @@ var DetSysAction = class {
process.exitCode = 1;
});
}
// Whether the
getTemporaryName() {
const tmpDir = process.env["RUNNER_TEMP"] || (0,external_node_os_.tmpdir)();
return external_node_path_namespaceObject.join(tmpDir, `${this.actionOptions.name}-${(0,external_node_crypto_namespaceObject.randomUUID)()}`);
}
addFact(key, value) {
this.facts[key] = value;
}
getDiagnosticsUrl() {
return this.actionOptions.diagnosticsUrl;
}
getUniqueId() {
return this.identity.run_differentiator || process.env.RUNNER_TRACKING_ID || (0,external_node_crypto_namespaceObject.randomUUID)();
}
getCorrelationHashes() {
return this.identity;
}
recordEvent(eventName, context = {}) {
this.events.push({
event_name: `${this.actionOptions.eventPrefix}${eventName}`,
context,
correlation: this.identity,
facts: this.facts,
timestamp: /* @__PURE__ */ new Date(),
uuid: (0,external_node_crypto_namespaceObject.randomUUID)()
});
}
/**
* Unpacks the closure returned by `fetchArtifact()`, imports the
* contents into the Nix store, and returns the path of the executable at
* `/nix/store/STORE_PATH/bin/${bin}`.
*/
async unpackClosure(bin) {
const artifact = await this.fetchArtifact();
const { stdout } = await (0,external_node_util_.promisify)(external_node_child_process_namespaceObject.exec)(
`cat "${artifact}" | xz -d | nix-store --import`
);
const paths = stdout.split(external_node_os_.EOL);
const lastPath = paths.at(-2);
return `${lastPath}/bin/${bin}`;
}
/**
* Fetches the executable at the URL determined by the `source-*` inputs and
* other facts, `chmod`s it, and returns the path to the executable on disk.
*/
async fetchExecutable() {
const binaryPath = await this.fetchArtifact();
await (0,promises_namespaceObject.chmod)(binaryPath, promises_namespaceObject.constants.S_IXUSR | promises_namespaceObject.constants.S_IXGRP);
return binaryPath;
}
get isMain() {
return this.executionPhase === "main";
}
@ -94330,7 +94415,7 @@ var DetSysAction = class {
this.addFact(FACT_ENDED_WITH_EXCEPTION, false);
} catch (e) {
this.addFact(FACT_ENDED_WITH_EXCEPTION, true);
const reportable = stringifyError(e);
const reportable = stringifyError2(e);
this.addFact(FACT_FINAL_EXCEPTION, reportable);
if (this.isPost) {
core.warning(reportable);
@ -94350,7 +94435,7 @@ var DetSysAction = class {
} catch (innerError) {
exceptionContext.set(
`staple_failure_${attachmentLabel}`,
stringifyError(innerError)
stringifyError2(innerError)
);
}
}
@ -94359,52 +94444,25 @@ var DetSysAction = class {
await this.complete();
}
}
addFact(key, value) {
this.facts[key] = value;
}
getDiagnosticsUrl() {
return this.actionOptions.diagnosticsUrl;
}
getUniqueId() {
return this.identity.run_differentiator || process.env.RUNNER_TRACKING_ID || (0,external_node_crypto_namespaceObject.randomUUID)();
}
getCorrelationHashes() {
return this.identity;
}
recordEvent(eventName, context = {}) {
this.events.push({
event_name: `${this.actionOptions.eventPrefix}${eventName}`,
context,
correlation: this.identity,
facts: this.facts,
timestamp: /* @__PURE__ */ new Date(),
uuid: (0,external_node_crypto_namespaceObject.randomUUID)()
});
}
/**
* Fetches a file in `.xz` format, imports its contents into the Nix store,
* and returns the path of the executable at `/nix/store/STORE_PATH/bin/${bin}`.
*/
async unpackClosure(bin) {
const artifact = this.fetchArtifact();
const { stdout } = await (0,external_node_util_.promisify)(external_node_child_process_namespaceObject.exec)(
`cat "${artifact}" | xz -d | nix-store --import`
);
const paths = stdout.split(external_node_os_.EOL);
const lastPath = paths.at(-2);
return `${lastPath}/bin/${bin}`;
}
/**
* Fetch an artifact, such as a tarball, from the URL determined by the `source-*`
* inputs and other factors.
* 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
* to a binary on disk; otherwise, the artifact will be downloaded from the
* URL determined by the other `source-*` inputs (`source-url`, `source-pr`,
* etc.).
*/
async fetchArtifact() {
const sourceBinary = getStringOrNull("source-binary");
if (sourceBinary !== null && sourceBinary !== "") {
core.debug(`Using the provided source binary at ${sourceBinary}`);
return sourceBinary;
}
core.startGroup(
`Downloading ${this.actionOptions.name} for ${this.architectureFetchSuffix}`
);
try {
core.info(`Fetching from ${this.getUrl()}`);
const correlatedUrl = this.getUrl();
core.info(`Fetching from ${this.getSourceUrl()}`);
const correlatedUrl = this.getSourceUrl();
correlatedUrl.searchParams.set("ci", "github");
correlatedUrl.searchParams.set(
"correlation",
@ -94415,16 +94473,16 @@ var DetSysAction = class {
const v = versionCheckup.headers.etag;
this.addFact(FACT_SOURCE_URL_ETAG, v);
core.debug(
`Checking the tool cache for ${this.getUrl()} at ${v}`
`Checking the tool cache for ${this.getSourceUrl()} at ${v}`
);
const cached = await this.getCachedVersion(v);
if (cached) {
this.facts["artifact_fetched_from_cache"] = true;
this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = true;
core.debug(`Tool cache hit.`);
return cached;
}
}
this.facts["artifact_fetched_from_cache"] = false;
this.facts[FACT_ARTIFACT_FETCHED_FROM_CACHE] = false;
core.debug(
`No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`
);
@ -94442,7 +94500,7 @@ var DetSysAction = class {
try {
await this.saveCachedVersion(v, destFile);
} catch (e) {
core.debug(`Error caching the artifact: ${stringifyError(e)}`);
core.debug(`Error caching the artifact: ${stringifyError2(e)}`);
}
}
return destFile;
@ -94450,15 +94508,6 @@ var DetSysAction = class {
core.endGroup();
}
}
/**
* Fetches the executable at the URL determined by the `source-*` inputs and
* other facts, `chmod`s it, and returns the path to the executable on disk.
*/
async fetchExecutable() {
const binaryPath = await this.fetchArtifact();
await (0,promises_namespaceObject.chmod)(binaryPath, promises_namespaceObject.constants.S_IXUSR | promises_namespaceObject.constants.S_IXGRP);
return binaryPath;
}
/**
* A helper function for failing on error only if strict mode is enabled.
* This is intended only for CI environments testing Actions themselves.
@ -94472,7 +94521,7 @@ var DetSysAction = class {
this.recordEvent(`complete_${this.executionPhase}`);
await this.submitEvents();
}
getUrl() {
getSourceUrl() {
const p = this.sourceParameters;
if (p.url) {
this.addFact(FACT_SOURCE_URL, p.url);
@ -94630,7 +94679,7 @@ var DetSysAction = class {
}
this.addFact(FACT_NIX_STORE_VERSION, JSON.stringify(parsed.version));
} catch (e) {
this.addFact(FACT_NIX_STORE_CHECK_ERROR, stringifyError(e));
this.addFact(FACT_NIX_STORE_CHECK_ERROR, stringifyError2(e));
}
}
async submitEvents() {
@ -94648,21 +94697,20 @@ var DetSysAction = class {
};
try {
await this.client.post(this.actionOptions.diagnosticsUrl, {
json: batch
json: batch,
timeout: {
request: DIAGNOSTIC_ENDPOINT_TIMEOUT_MS
}
});
} catch (e) {
core.debug(
`Error submitting diagnostics event: ${stringifyError(e)}`
`Error submitting diagnostics event: ${stringifyError2(e)}`
);
}
this.events = [];
}
getTemporaryName() {
const _tmpdir = process.env["RUNNER_TEMP"] || (0,external_node_os_.tmpdir)();
return external_node_path_namespaceObject.join(_tmpdir, `${this.actionOptions.name}-${(0,external_node_crypto_namespaceObject.randomUUID)()}`);
}
};
function stringifyError(error2) {
function stringifyError2(error2) {
return error2 instanceof Error || typeof error2 == "string" ? error2.toString() : JSON.stringify(error2);
}
function makeOptionsConfident(actionOptions) {
@ -94700,7 +94748,7 @@ function determineDiagnosticsUrl(idsProjectName, urlOption) {
return mungeDiagnosticEndpoint(new URL(providedDiagnosticEndpoint));
} catch (e) {
core.info(
`User-provided diagnostic endpoint ignored: not a valid URL: ${stringifyError(e)}`
`User-provided diagnostic endpoint ignored: not a valid URL: ${stringifyError2(e)}`
);
}
}
@ -94712,7 +94760,7 @@ function determineDiagnosticsUrl(idsProjectName, urlOption) {
return diagnosticUrl;
} catch (e) {
core.info(
`Generated diagnostic endpoint ignored: not a valid URL: ${stringifyError(e)}`
`Generated diagnostic endpoint ignored: not a valid URL: ${stringifyError2(e)}`
);
}
return void 0;
@ -94734,7 +94782,7 @@ function mungeDiagnosticEndpoint(inputUrl) {
return inputUrl;
} catch (e) {
core.info(
`Default or overridden IDS host isn't a valid URL: ${stringifyError(e)}`
`Default or overridden IDS host isn't a valid URL: ${stringifyError2(e)}`
);
}
return inputUrl;