@datadog/datadog-ci-plugin-terraform 5.20.1 → 5.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +156 -24
- package/dist/bundle.js.map +1 -1
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -10914,7 +10914,7 @@ var require_glob = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
10914
10914
|
var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10915
10915
|
module.exports = {
|
|
10916
10916
|
"name": "@datadog/datadog-ci-base",
|
|
10917
|
-
"version": "5.
|
|
10917
|
+
"version": "5.21.1",
|
|
10918
10918
|
"description": "Base package for Datadog CI",
|
|
10919
10919
|
"license": "Apache-2.0",
|
|
10920
10920
|
"keywords": ["datadog", "datadog-ci"],
|
|
@@ -11042,13 +11042,14 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11042
11042
|
//#region ../base/dist/constants.js
|
|
11043
11043
|
var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11044
11044
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11045
|
-
exports.METHOD_POST = exports.CONTENT_TYPE_VALUE_JSON = exports.CONTENT_TYPE_VALUE_PROTOBUF = exports.CONTENT_TYPE_HEADER = exports.SKIP_VERSION_BANNER_ENV_VAR = exports.LOG_FORMAT_ENV_VAR = exports.FIPS_IGNORE_ERROR_ENV_VAR = exports.FIPS_ENV_VAR = exports.DATADOG_SITES = exports.DATADOG_SITE_US2_GOV = exports.DATADOG_SITE_GOV = exports.DATADOG_SITE_AP2 = exports.DATADOG_SITE_AP1 = exports.DATADOG_SITE_US5 = exports.DATADOG_SITE_US3 = exports.DATADOG_SITE_EU1 = exports.DATADOG_SITE_US1 = void 0;
|
|
11045
|
+
exports.METHOD_POST = exports.CONTENT_TYPE_VALUE_JSON = exports.CONTENT_TYPE_VALUE_PROTOBUF = exports.CONTENT_TYPE_HEADER = exports.SKIP_VERSION_BANNER_ENV_VAR = exports.LOG_FORMAT_ENV_VAR = exports.FIPS_IGNORE_ERROR_ENV_VAR = exports.FIPS_ENV_VAR = exports.DATADOG_SITES = exports.DATADOG_SITE_US2_GOV = exports.DATADOG_SITE_GOV = exports.DATADOG_SITE_UK1 = exports.DATADOG_SITE_AP2 = exports.DATADOG_SITE_AP1 = exports.DATADOG_SITE_US5 = exports.DATADOG_SITE_US3 = exports.DATADOG_SITE_EU1 = exports.DATADOG_SITE_US1 = void 0;
|
|
11046
11046
|
exports.DATADOG_SITE_US1 = "datadoghq.com";
|
|
11047
11047
|
exports.DATADOG_SITE_EU1 = "datadoghq.eu";
|
|
11048
11048
|
exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
|
|
11049
11049
|
exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
|
|
11050
11050
|
exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
|
|
11051
11051
|
exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
|
|
11052
|
+
exports.DATADOG_SITE_UK1 = "uk1.datadoghq.com";
|
|
11052
11053
|
exports.DATADOG_SITE_GOV = "ddog-gov.com";
|
|
11053
11054
|
exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
|
|
11054
11055
|
exports.DATADOG_SITES = [
|
|
@@ -11058,6 +11059,7 @@ var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
11058
11059
|
exports.DATADOG_SITE_US5,
|
|
11059
11060
|
exports.DATADOG_SITE_AP1,
|
|
11060
11061
|
exports.DATADOG_SITE_AP2,
|
|
11062
|
+
exports.DATADOG_SITE_UK1,
|
|
11061
11063
|
exports.DATADOG_SITE_GOV,
|
|
11062
11064
|
exports.DATADOG_SITE_US2_GOV
|
|
11063
11065
|
];
|
|
@@ -64713,11 +64715,38 @@ var require_tags = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
64713
64715
|
//#endregion
|
|
64714
64716
|
//#region ../base/dist/helpers/ci.js
|
|
64715
64717
|
var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
64718
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
64719
|
+
function adopt(value) {
|
|
64720
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
64721
|
+
resolve(value);
|
|
64722
|
+
});
|
|
64723
|
+
}
|
|
64724
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
64725
|
+
function fulfilled(value) {
|
|
64726
|
+
try {
|
|
64727
|
+
step(generator.next(value));
|
|
64728
|
+
} catch (e) {
|
|
64729
|
+
reject(e);
|
|
64730
|
+
}
|
|
64731
|
+
}
|
|
64732
|
+
function rejected(value) {
|
|
64733
|
+
try {
|
|
64734
|
+
step(generator["throw"](value));
|
|
64735
|
+
} catch (e) {
|
|
64736
|
+
reject(e);
|
|
64737
|
+
}
|
|
64738
|
+
}
|
|
64739
|
+
function step(result) {
|
|
64740
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
64741
|
+
}
|
|
64742
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64743
|
+
});
|
|
64744
|
+
};
|
|
64716
64745
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
64717
64746
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
64718
64747
|
};
|
|
64719
64748
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64720
|
-
exports.getGithubJobIDFromLogs = exports.getGithubStepInfoFromLogs = exports.enrichCIEnvFromGithubLogs = exports.getGithubJobNameFromLogs = exports.isGithubWindowsRunner = exports.shouldGetGithubJobID = exports.shouldGetGithubJobDisplayName = exports.isInteractive = exports.getCIProvider = exports.isCI = exports.getCIEnv = exports.getCIMetadata = exports.getCISpanTags = exports.githubWellKnownDiagnosticDirPatternsWin = exports.githubWellKnownDiagnosticDirPatternsUnix = exports.githubWellKnownDiagnosticDirsWin = exports.githubWellKnownDiagnosticDirsUnix = exports.validateLevel = exports.LEVEL_TO_NUMBER = exports.VALID_LEVELS = exports.CI_LEVELS = exports.envDDGithubStepIndex = exports.envDDGithubJobName = exports.CI_ENGINES = void 0;
|
|
64749
|
+
exports.getGithubJobIDFromLogs = exports.getGithubStepInfoFromLogs = exports.processLevels = exports.enrichCIEnvFromGithubLogs = exports.getGithubJobNameFromLogs = exports.createGithubLogCache = exports.isGithubWindowsRunner = exports.shouldGetGithubJobID = exports.shouldGetGithubJobDisplayName = exports.isInteractive = exports.getCIProvider = exports.isCI = exports.getCIEnv = exports.getCIMetadata = exports.getCISpanTags = exports.githubWellKnownDiagnosticDirPatternsWin = exports.githubWellKnownDiagnosticDirPatternsUnix = exports.githubWellKnownDiagnosticDirsWin = exports.githubWellKnownDiagnosticDirsUnix = exports.parseLevels = exports.validateLevel = exports.LEVEL_TO_NUMBER = exports.VALID_LEVELS = exports.CI_LEVELS = exports.envDDGithubStepIndex = exports.envDDGithubJobName = exports.CI_ENGINES = void 0;
|
|
64721
64750
|
const fs_1$2 = __importDefault(require("fs"));
|
|
64722
64751
|
const chalk_1 = __importDefault(require_source());
|
|
64723
64752
|
const upath_1 = __importDefault(require_upath());
|
|
@@ -64775,7 +64804,31 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
64775
64804
|
if (level === exports.CI_LEVELS.STEP && provider !== exports.CI_ENGINES.GITHUB) return `Level '${exports.CI_LEVELS.STEP}' is only supported for provider [${exports.CI_ENGINES.GITHUB}]`;
|
|
64776
64805
|
};
|
|
64777
64806
|
exports.validateLevel = validateLevel;
|
|
64778
|
-
|
|
64807
|
+
/**
|
|
64808
|
+
* Parses an additive, comma-separated `--level` value (e.g. "pipeline,stage").
|
|
64809
|
+
* Trims each member, drops empties, dedupes, sorts by span depth, and validates
|
|
64810
|
+
* every member (known value + provider support). Returns the parsed levels or,
|
|
64811
|
+
* if anything is invalid or empty, a single aggregated error message.
|
|
64812
|
+
*/
|
|
64813
|
+
const parseLevels = (input) => {
|
|
64814
|
+
const unique = uniq((input !== null && input !== void 0 ? input : "").split(",").map((p) => p.trim()).filter((p) => p.length > 0));
|
|
64815
|
+
if (unique.length === 0) return {
|
|
64816
|
+
levels: [],
|
|
64817
|
+
error: `Level must be one of [${exports.VALID_LEVELS.join(", ")}]`
|
|
64818
|
+
};
|
|
64819
|
+
const errors = uniq(unique.map((p) => (0, exports.validateLevel)(p)).filter((e) => Boolean(e)));
|
|
64820
|
+
if (errors.length > 0) return {
|
|
64821
|
+
levels: [],
|
|
64822
|
+
error: errors.join("; ")
|
|
64823
|
+
};
|
|
64824
|
+
return { levels: unique.sort((a, b) => exports.LEVEL_TO_NUMBER[a] - exports.LEVEL_TO_NUMBER[b]) };
|
|
64825
|
+
};
|
|
64826
|
+
exports.parseLevels = parseLevels;
|
|
64827
|
+
exports.githubWellKnownDiagnosticDirsUnix = [
|
|
64828
|
+
"/home/runner/_diag",
|
|
64829
|
+
"/home/runner/actions-runner/_diag",
|
|
64830
|
+
"/opt/actions-runner/_diag"
|
|
64831
|
+
];
|
|
64779
64832
|
exports.githubWellKnownDiagnosticDirsWin = ["C:/actions-runner/_diag"];
|
|
64780
64833
|
exports.githubWellKnownDiagnosticDirPatternsUnix = ["/home/runner/actions-runner/*/_diag", "/home/runner/actions-runner/*/*/_diag"];
|
|
64781
64834
|
exports.githubWellKnownDiagnosticDirPatternsWin = ["C:/actions-runner/*/_diag", "C:/actions-runner/*/*/_diag"];
|
|
@@ -64816,6 +64869,11 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
64816
64869
|
dirs.push(`${runnerRoot}/actions-runner/*/*/_diag`);
|
|
64817
64870
|
dirs.push(upath_1.default.join(runnerRoot, "actions-runner", "_diag"));
|
|
64818
64871
|
}
|
|
64872
|
+
const home = process.env.HOME;
|
|
64873
|
+
if (home) {
|
|
64874
|
+
dirs.push(upath_1.default.join(home, "_diag"));
|
|
64875
|
+
dirs.push(upath_1.default.join(home, "actions-runner", "_diag"));
|
|
64876
|
+
}
|
|
64819
64877
|
return uniq(dirs.filter(Boolean));
|
|
64820
64878
|
};
|
|
64821
64879
|
/**
|
|
@@ -65092,7 +65150,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65092
65150
|
}
|
|
65093
65151
|
}
|
|
65094
65152
|
if (env.BITBUCKET_COMMIT) {
|
|
65095
|
-
const { BITBUCKET_REPO_FULL_NAME, BITBUCKET_BUILD_NUMBER, BITBUCKET_BRANCH, BITBUCKET_COMMIT, BITBUCKET_GIT_SSH_ORIGIN, BITBUCKET_GIT_HTTP_ORIGIN, BITBUCKET_TAG, BITBUCKET_PIPELINE_UUID, BITBUCKET_PR_ID, BITBUCKET_PR_DESTINATION_BRANCH, BITBUCKET_CLONE_DIR } = env;
|
|
65153
|
+
const { BITBUCKET_REPO_FULL_NAME, BITBUCKET_BUILD_NUMBER, BITBUCKET_BRANCH, BITBUCKET_COMMIT, BITBUCKET_GIT_SSH_ORIGIN, BITBUCKET_GIT_HTTP_ORIGIN, BITBUCKET_TAG, BITBUCKET_PIPELINE_UUID, BITBUCKET_PR_ID, BITBUCKET_PR_DESTINATION_BRANCH, BITBUCKET_PR_DESTINATION_COMMIT, BITBUCKET_CLONE_DIR } = env;
|
|
65096
65154
|
const url = `https://bitbucket.org/${BITBUCKET_REPO_FULL_NAME}/addon/pipelines/home#!/results/${BITBUCKET_BUILD_NUMBER}`;
|
|
65097
65155
|
tags = {
|
|
65098
65156
|
[tags_1.CI_PROVIDER_NAME]: exports.CI_ENGINES.BITBUCKET,
|
|
@@ -65110,6 +65168,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65110
65168
|
if (BITBUCKET_PR_ID) {
|
|
65111
65169
|
tags[tags_1.PR_NUMBER] = BITBUCKET_PR_ID;
|
|
65112
65170
|
tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH] = BITBUCKET_PR_DESTINATION_BRANCH;
|
|
65171
|
+
if (BITBUCKET_PR_DESTINATION_COMMIT) tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH_SHA] = BITBUCKET_PR_DESTINATION_COMMIT;
|
|
65113
65172
|
}
|
|
65114
65173
|
}
|
|
65115
65174
|
if (env.CF_BUILD_ID) {
|
|
@@ -65419,7 +65478,32 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65419
65478
|
return os.toLowerCase() === "windows";
|
|
65420
65479
|
};
|
|
65421
65480
|
exports.isGithubWindowsRunner = isGithubWindowsRunner;
|
|
65422
|
-
const
|
|
65481
|
+
const createGithubLogCache = () => ({
|
|
65482
|
+
workerLogFilesResolved: false,
|
|
65483
|
+
workerLogFiles: void 0,
|
|
65484
|
+
targetLogFilesResolved: false,
|
|
65485
|
+
targetLogFiles: [],
|
|
65486
|
+
fileContents: /* @__PURE__ */ new Map()
|
|
65487
|
+
});
|
|
65488
|
+
exports.createGithubLogCache = createGithubLogCache;
|
|
65489
|
+
/** Reads a diagnostic log file, serving from (and populating) `cache` when provided. */
|
|
65490
|
+
const readLogFile = (filePath, cache) => {
|
|
65491
|
+
const cached = cache === null || cache === void 0 ? void 0 : cache.fileContents.get(filePath);
|
|
65492
|
+
if (cached !== void 0) return cached;
|
|
65493
|
+
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
65494
|
+
cache === null || cache === void 0 || cache.fileContents.set(filePath, content);
|
|
65495
|
+
return content;
|
|
65496
|
+
};
|
|
65497
|
+
const getGithubWorkerLogFiles = (context, cache) => {
|
|
65498
|
+
if (cache === null || cache === void 0 ? void 0 : cache.workerLogFilesResolved) return cache.workerLogFiles;
|
|
65499
|
+
const result = computeGithubWorkerLogFiles(context);
|
|
65500
|
+
if (cache) {
|
|
65501
|
+
cache.workerLogFilesResolved = true;
|
|
65502
|
+
cache.workerLogFiles = result;
|
|
65503
|
+
}
|
|
65504
|
+
return result;
|
|
65505
|
+
};
|
|
65506
|
+
const computeGithubWorkerLogFiles = (context) => {
|
|
65423
65507
|
let foundDiagDir = "";
|
|
65424
65508
|
let workerLogFiles = [];
|
|
65425
65509
|
let wellKnownDirs = expandDiagnosticDirCandidates([
|
|
@@ -65476,13 +65560,21 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65476
65560
|
* which on a single-job runner is immediate, and on a multi-runner is the current
|
|
65477
65561
|
* job's (most recent) log.
|
|
65478
65562
|
*/
|
|
65479
|
-
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles) => {
|
|
65563
|
+
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
65564
|
+
if (cache === null || cache === void 0 ? void 0 : cache.targetLogFilesResolved) return cache.targetLogFiles;
|
|
65565
|
+
const result = computeTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
65566
|
+
if (cache) {
|
|
65567
|
+
cache.targetLogFilesResolved = true;
|
|
65568
|
+
cache.targetLogFiles = result;
|
|
65569
|
+
}
|
|
65570
|
+
return result;
|
|
65571
|
+
};
|
|
65572
|
+
const computeTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
65480
65573
|
const sortedNewestFirst = [...workerLogFiles].sort().reverse();
|
|
65481
65574
|
const orchestrationId = process.env.ACTIONS_ORCHESTRATION_ID;
|
|
65482
65575
|
if (orchestrationId) {
|
|
65483
65576
|
for (const logFile of sortedNewestFirst) {
|
|
65484
|
-
const
|
|
65485
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
65577
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
65486
65578
|
if (content.includes("\"system.orchestrationId\":") && content.includes(`"${orchestrationId}"`)) {
|
|
65487
65579
|
context.stdout.write(`Found Worker log via system.orchestrationId for ${orchestrationId}: ${logFile}\n`);
|
|
65488
65580
|
return [logFile];
|
|
@@ -65492,11 +65584,10 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65492
65584
|
}
|
|
65493
65585
|
return sortedNewestFirst;
|
|
65494
65586
|
};
|
|
65495
|
-
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex) => {
|
|
65496
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
65587
|
+
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex, cache) => {
|
|
65588
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
65497
65589
|
for (const logFile of logsToCheck) {
|
|
65498
|
-
const
|
|
65499
|
-
const match = fs_1$2.default.readFileSync(filePath, "utf-8").match(jobAttributeRegex);
|
|
65590
|
+
const match = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache).match(jobAttributeRegex);
|
|
65500
65591
|
if (match && match[1]) return unescapeJsonString(match[1]);
|
|
65501
65592
|
}
|
|
65502
65593
|
};
|
|
@@ -65516,13 +65607,13 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65516
65607
|
*
|
|
65517
65608
|
* @returns The job display name, or undefined if not found
|
|
65518
65609
|
*/
|
|
65519
|
-
const getGithubJobNameFromLogs = (context) => {
|
|
65610
|
+
const getGithubJobNameFromLogs = (context, cache) => {
|
|
65520
65611
|
if (!(0, exports.shouldGetGithubJobDisplayName)()) return;
|
|
65521
65612
|
context.stdout.write("Determining GitHub job name\n");
|
|
65522
|
-
const result = getGithubWorkerLogFiles(context);
|
|
65613
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
65523
65614
|
if (!result) return;
|
|
65524
65615
|
const [foundDiagDir, workerLogFiles] = result;
|
|
65525
|
-
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex);
|
|
65616
|
+
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex, cache);
|
|
65526
65617
|
if (!jobDisplayName) context.stderr.write(`${chalk_1.default.yellow.bold("[WARNING]")} could not find "jobDisplayName" attribute in GitHub diagnostic logs`);
|
|
65527
65618
|
else {
|
|
65528
65619
|
context.stdout.write(`Successfully extracted job name: ${jobDisplayName}\n`);
|
|
@@ -65536,16 +65627,16 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65536
65627
|
* - job: extracts job display name
|
|
65537
65628
|
* - pipeline/stage: no-op
|
|
65538
65629
|
*/
|
|
65539
|
-
const enrichCIEnvFromGithubLogs = (context, level, ciEnv) => {
|
|
65630
|
+
const enrichCIEnvFromGithubLogs = (context, level, ciEnv, cache) => {
|
|
65540
65631
|
switch (level) {
|
|
65541
65632
|
case exports.CI_LEVELS.STEP: {
|
|
65542
|
-
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context);
|
|
65633
|
+
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context, cache);
|
|
65543
65634
|
if (!ciEnv[exports.envDDGithubJobName]) ciEnv[exports.envDDGithubJobName] = stepInfo.jobDisplayName;
|
|
65544
65635
|
ciEnv[exports.envDDGithubStepIndex] = String(stepInfo.stepIndex);
|
|
65545
65636
|
break;
|
|
65546
65637
|
}
|
|
65547
65638
|
case exports.CI_LEVELS.JOB: {
|
|
65548
|
-
const jobName = (0, exports.getGithubJobNameFromLogs)(context);
|
|
65639
|
+
const jobName = (0, exports.getGithubJobNameFromLogs)(context, cache);
|
|
65549
65640
|
if (jobName) ciEnv[exports.envDDGithubJobName] = jobName;
|
|
65550
65641
|
break;
|
|
65551
65642
|
}
|
|
@@ -65554,6 +65645,48 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65554
65645
|
};
|
|
65555
65646
|
exports.enrichCIEnvFromGithubLogs = enrichCIEnvFromGithubLogs;
|
|
65556
65647
|
/**
|
|
65648
|
+
* Sends the same payload to each requested CI level, one request per level.
|
|
65649
|
+
*
|
|
65650
|
+
* Shared by the `tag` and `measure` commands. Each level is enriched on its own
|
|
65651
|
+
* copy of `ciEnv` (so e.g. the step index never leaks into the job request).
|
|
65652
|
+
*
|
|
65653
|
+
* Failure handling mirrors the original single-level behavior:
|
|
65654
|
+
* - A setup/config error — a missing API key, or GitHub diagnostic logs that
|
|
65655
|
+
* cannot be located — is thrown and propagates to the caller's outer catch,
|
|
65656
|
+
* making it fatal regardless of `--no-fail`. The thrown error is annotated
|
|
65657
|
+
* with the failing level so the report says which one broke.
|
|
65658
|
+
* - A request that completes but reports a non-zero status sets the returned
|
|
65659
|
+
* flag and the loop continues; the caller decides whether `--no-fail` turns
|
|
65660
|
+
* it into a success.
|
|
65661
|
+
*
|
|
65662
|
+
* A single `GithubLogCache` lives for the duration of the loop so the GitHub
|
|
65663
|
+
* diagnostic logs are located and read at most once even when several levels
|
|
65664
|
+
* need them (e.g. `--level job,step`).
|
|
65665
|
+
*
|
|
65666
|
+
* Returns `true` if any level reported a non-zero status. Callers own the
|
|
65667
|
+
* `--no-fail`/success messaging and exit code based on this flag.
|
|
65668
|
+
*/
|
|
65669
|
+
const processLevels = (context, levels, ciEnv, sendForLevel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65670
|
+
const cache = (0, exports.createGithubLogCache)();
|
|
65671
|
+
let anyFailed = false;
|
|
65672
|
+
for (const level of levels) {
|
|
65673
|
+
let exitStatus;
|
|
65674
|
+
try {
|
|
65675
|
+
const levelEnv = Object.assign({}, ciEnv);
|
|
65676
|
+
(0, exports.enrichCIEnvFromGithubLogs)(context, level, levelEnv, cache);
|
|
65677
|
+
exitStatus = yield sendForLevel(levelEnv, exports.LEVEL_TO_NUMBER[level]);
|
|
65678
|
+
} catch (error) {
|
|
65679
|
+
throw new Error(`level '${level}': ${error.message}`);
|
|
65680
|
+
}
|
|
65681
|
+
if (exitStatus !== 0) {
|
|
65682
|
+
anyFailed = true;
|
|
65683
|
+
context.stderr.write(`${chalk_1.default.red.bold("[ERROR]")} failed to send for level '${level}'\n`);
|
|
65684
|
+
}
|
|
65685
|
+
}
|
|
65686
|
+
return anyFailed;
|
|
65687
|
+
});
|
|
65688
|
+
exports.processLevels = processLevels;
|
|
65689
|
+
/**
|
|
65557
65690
|
* Extracts the job display name and step index from GitHub Actions diagnostic logs.
|
|
65558
65691
|
*
|
|
65559
65692
|
* To avoid parsing the full Job message JSON (~26KB), we:
|
|
@@ -65561,18 +65694,17 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65561
65694
|
* 2. Extract only the `"steps": [...]` array from the Job message via bracket-depth tracking
|
|
65562
65695
|
* 3. Parse just that array and match `contextName` against `GITHUB_ACTION`
|
|
65563
65696
|
*/
|
|
65564
|
-
const getGithubStepInfoFromLogs = (context) => {
|
|
65697
|
+
const getGithubStepInfoFromLogs = (context, cache) => {
|
|
65565
65698
|
if ((0, exports.getCIProvider)() !== exports.CI_ENGINES.GITHUB) throw new Error("Step level is only supported for GitHub Actions");
|
|
65566
65699
|
const githubAction = process.env.GITHUB_ACTION;
|
|
65567
65700
|
if (!githubAction) throw new Error("GITHUB_ACTION environment variable is not set, cannot determine step index");
|
|
65568
65701
|
context.stdout.write("Determining GitHub step info from diagnostic logs\n");
|
|
65569
|
-
const result = getGithubWorkerLogFiles(context);
|
|
65702
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
65570
65703
|
if (!result) throw new Error("Could not find GitHub diagnostic log files, cannot determine step index");
|
|
65571
65704
|
const [foundDiagDir, workerLogFiles] = result;
|
|
65572
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
65705
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
65573
65706
|
for (const logFile of logsToCheck) {
|
|
65574
|
-
const
|
|
65575
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
65707
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
65576
65708
|
const displayNameMatch = content.match(githubJobDisplayNameRegex);
|
|
65577
65709
|
if (!displayNameMatch || !displayNameMatch[1]) continue;
|
|
65578
65710
|
const jobDisplayName = unescapeJsonString(displayNameMatch[1]);
|