@datadog/datadog-ci-plugin-synthetics 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
|
@@ -5761,7 +5761,7 @@ var require_glob = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5761
5761
|
var require_package$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5762
5762
|
module.exports = {
|
|
5763
5763
|
"name": "@datadog/datadog-ci-base",
|
|
5764
|
-
"version": "5.
|
|
5764
|
+
"version": "5.21.1",
|
|
5765
5765
|
"description": "Base package for Datadog CI",
|
|
5766
5766
|
"license": "Apache-2.0",
|
|
5767
5767
|
"keywords": ["datadog", "datadog-ci"],
|
|
@@ -5889,13 +5889,14 @@ var require_package$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5889
5889
|
//#region ../base/dist/constants.js
|
|
5890
5890
|
var require_constants$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5891
5891
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5892
|
-
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;
|
|
5892
|
+
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;
|
|
5893
5893
|
exports.DATADOG_SITE_US1 = "datadoghq.com";
|
|
5894
5894
|
exports.DATADOG_SITE_EU1 = "datadoghq.eu";
|
|
5895
5895
|
exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
|
|
5896
5896
|
exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
|
|
5897
5897
|
exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
|
|
5898
5898
|
exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
|
|
5899
|
+
exports.DATADOG_SITE_UK1 = "uk1.datadoghq.com";
|
|
5899
5900
|
exports.DATADOG_SITE_GOV = "ddog-gov.com";
|
|
5900
5901
|
exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
|
|
5901
5902
|
exports.DATADOG_SITES = [
|
|
@@ -5905,6 +5906,7 @@ var require_constants$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5905
5906
|
exports.DATADOG_SITE_US5,
|
|
5906
5907
|
exports.DATADOG_SITE_AP1,
|
|
5907
5908
|
exports.DATADOG_SITE_AP2,
|
|
5909
|
+
exports.DATADOG_SITE_UK1,
|
|
5908
5910
|
exports.DATADOG_SITE_GOV,
|
|
5909
5911
|
exports.DATADOG_SITE_US2_GOV
|
|
5910
5912
|
];
|
|
@@ -64723,11 +64725,38 @@ var require_tags = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
64723
64725
|
//#endregion
|
|
64724
64726
|
//#region ../base/dist/helpers/ci.js
|
|
64725
64727
|
var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
64728
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
64729
|
+
function adopt(value) {
|
|
64730
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
64731
|
+
resolve(value);
|
|
64732
|
+
});
|
|
64733
|
+
}
|
|
64734
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
64735
|
+
function fulfilled(value) {
|
|
64736
|
+
try {
|
|
64737
|
+
step(generator.next(value));
|
|
64738
|
+
} catch (e) {
|
|
64739
|
+
reject(e);
|
|
64740
|
+
}
|
|
64741
|
+
}
|
|
64742
|
+
function rejected(value) {
|
|
64743
|
+
try {
|
|
64744
|
+
step(generator["throw"](value));
|
|
64745
|
+
} catch (e) {
|
|
64746
|
+
reject(e);
|
|
64747
|
+
}
|
|
64748
|
+
}
|
|
64749
|
+
function step(result) {
|
|
64750
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
64751
|
+
}
|
|
64752
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64753
|
+
});
|
|
64754
|
+
};
|
|
64726
64755
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
64727
64756
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
64728
64757
|
};
|
|
64729
64758
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64730
|
-
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;
|
|
64759
|
+
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;
|
|
64731
64760
|
const fs_1$2 = __importDefault(require("fs"));
|
|
64732
64761
|
const chalk_1 = __importDefault(require_source$3());
|
|
64733
64762
|
const upath_1 = __importDefault(require_upath());
|
|
@@ -64785,7 +64814,31 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
64785
64814
|
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}]`;
|
|
64786
64815
|
};
|
|
64787
64816
|
exports.validateLevel = validateLevel;
|
|
64788
|
-
|
|
64817
|
+
/**
|
|
64818
|
+
* Parses an additive, comma-separated `--level` value (e.g. "pipeline,stage").
|
|
64819
|
+
* Trims each member, drops empties, dedupes, sorts by span depth, and validates
|
|
64820
|
+
* every member (known value + provider support). Returns the parsed levels or,
|
|
64821
|
+
* if anything is invalid or empty, a single aggregated error message.
|
|
64822
|
+
*/
|
|
64823
|
+
const parseLevels = (input) => {
|
|
64824
|
+
const unique = uniq((input !== null && input !== void 0 ? input : "").split(",").map((p) => p.trim()).filter((p) => p.length > 0));
|
|
64825
|
+
if (unique.length === 0) return {
|
|
64826
|
+
levels: [],
|
|
64827
|
+
error: `Level must be one of [${exports.VALID_LEVELS.join(", ")}]`
|
|
64828
|
+
};
|
|
64829
|
+
const errors = uniq(unique.map((p) => (0, exports.validateLevel)(p)).filter((e) => Boolean(e)));
|
|
64830
|
+
if (errors.length > 0) return {
|
|
64831
|
+
levels: [],
|
|
64832
|
+
error: errors.join("; ")
|
|
64833
|
+
};
|
|
64834
|
+
return { levels: unique.sort((a, b) => exports.LEVEL_TO_NUMBER[a] - exports.LEVEL_TO_NUMBER[b]) };
|
|
64835
|
+
};
|
|
64836
|
+
exports.parseLevels = parseLevels;
|
|
64837
|
+
exports.githubWellKnownDiagnosticDirsUnix = [
|
|
64838
|
+
"/home/runner/_diag",
|
|
64839
|
+
"/home/runner/actions-runner/_diag",
|
|
64840
|
+
"/opt/actions-runner/_diag"
|
|
64841
|
+
];
|
|
64789
64842
|
exports.githubWellKnownDiagnosticDirsWin = ["C:/actions-runner/_diag"];
|
|
64790
64843
|
exports.githubWellKnownDiagnosticDirPatternsUnix = ["/home/runner/actions-runner/*/_diag", "/home/runner/actions-runner/*/*/_diag"];
|
|
64791
64844
|
exports.githubWellKnownDiagnosticDirPatternsWin = ["C:/actions-runner/*/_diag", "C:/actions-runner/*/*/_diag"];
|
|
@@ -64826,6 +64879,11 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
64826
64879
|
dirs.push(`${runnerRoot}/actions-runner/*/*/_diag`);
|
|
64827
64880
|
dirs.push(upath_1.default.join(runnerRoot, "actions-runner", "_diag"));
|
|
64828
64881
|
}
|
|
64882
|
+
const home = process.env.HOME;
|
|
64883
|
+
if (home) {
|
|
64884
|
+
dirs.push(upath_1.default.join(home, "_diag"));
|
|
64885
|
+
dirs.push(upath_1.default.join(home, "actions-runner", "_diag"));
|
|
64886
|
+
}
|
|
64829
64887
|
return uniq(dirs.filter(Boolean));
|
|
64830
64888
|
};
|
|
64831
64889
|
/**
|
|
@@ -65102,7 +65160,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65102
65160
|
}
|
|
65103
65161
|
}
|
|
65104
65162
|
if (env.BITBUCKET_COMMIT) {
|
|
65105
|
-
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;
|
|
65163
|
+
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;
|
|
65106
65164
|
const url = `https://bitbucket.org/${BITBUCKET_REPO_FULL_NAME}/addon/pipelines/home#!/results/${BITBUCKET_BUILD_NUMBER}`;
|
|
65107
65165
|
tags = {
|
|
65108
65166
|
[tags_1.CI_PROVIDER_NAME]: exports.CI_ENGINES.BITBUCKET,
|
|
@@ -65120,6 +65178,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65120
65178
|
if (BITBUCKET_PR_ID) {
|
|
65121
65179
|
tags[tags_1.PR_NUMBER] = BITBUCKET_PR_ID;
|
|
65122
65180
|
tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH] = BITBUCKET_PR_DESTINATION_BRANCH;
|
|
65181
|
+
if (BITBUCKET_PR_DESTINATION_COMMIT) tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH_SHA] = BITBUCKET_PR_DESTINATION_COMMIT;
|
|
65123
65182
|
}
|
|
65124
65183
|
}
|
|
65125
65184
|
if (env.CF_BUILD_ID) {
|
|
@@ -65429,7 +65488,32 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65429
65488
|
return os.toLowerCase() === "windows";
|
|
65430
65489
|
};
|
|
65431
65490
|
exports.isGithubWindowsRunner = isGithubWindowsRunner;
|
|
65432
|
-
const
|
|
65491
|
+
const createGithubLogCache = () => ({
|
|
65492
|
+
workerLogFilesResolved: false,
|
|
65493
|
+
workerLogFiles: void 0,
|
|
65494
|
+
targetLogFilesResolved: false,
|
|
65495
|
+
targetLogFiles: [],
|
|
65496
|
+
fileContents: /* @__PURE__ */ new Map()
|
|
65497
|
+
});
|
|
65498
|
+
exports.createGithubLogCache = createGithubLogCache;
|
|
65499
|
+
/** Reads a diagnostic log file, serving from (and populating) `cache` when provided. */
|
|
65500
|
+
const readLogFile = (filePath, cache) => {
|
|
65501
|
+
const cached = cache === null || cache === void 0 ? void 0 : cache.fileContents.get(filePath);
|
|
65502
|
+
if (cached !== void 0) return cached;
|
|
65503
|
+
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
65504
|
+
cache === null || cache === void 0 || cache.fileContents.set(filePath, content);
|
|
65505
|
+
return content;
|
|
65506
|
+
};
|
|
65507
|
+
const getGithubWorkerLogFiles = (context, cache) => {
|
|
65508
|
+
if (cache === null || cache === void 0 ? void 0 : cache.workerLogFilesResolved) return cache.workerLogFiles;
|
|
65509
|
+
const result = computeGithubWorkerLogFiles(context);
|
|
65510
|
+
if (cache) {
|
|
65511
|
+
cache.workerLogFilesResolved = true;
|
|
65512
|
+
cache.workerLogFiles = result;
|
|
65513
|
+
}
|
|
65514
|
+
return result;
|
|
65515
|
+
};
|
|
65516
|
+
const computeGithubWorkerLogFiles = (context) => {
|
|
65433
65517
|
let foundDiagDir = "";
|
|
65434
65518
|
let workerLogFiles = [];
|
|
65435
65519
|
let wellKnownDirs = expandDiagnosticDirCandidates([
|
|
@@ -65486,13 +65570,21 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65486
65570
|
* which on a single-job runner is immediate, and on a multi-runner is the current
|
|
65487
65571
|
* job's (most recent) log.
|
|
65488
65572
|
*/
|
|
65489
|
-
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles) => {
|
|
65573
|
+
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
65574
|
+
if (cache === null || cache === void 0 ? void 0 : cache.targetLogFilesResolved) return cache.targetLogFiles;
|
|
65575
|
+
const result = computeTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
65576
|
+
if (cache) {
|
|
65577
|
+
cache.targetLogFilesResolved = true;
|
|
65578
|
+
cache.targetLogFiles = result;
|
|
65579
|
+
}
|
|
65580
|
+
return result;
|
|
65581
|
+
};
|
|
65582
|
+
const computeTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
65490
65583
|
const sortedNewestFirst = [...workerLogFiles].sort().reverse();
|
|
65491
65584
|
const orchestrationId = process.env.ACTIONS_ORCHESTRATION_ID;
|
|
65492
65585
|
if (orchestrationId) {
|
|
65493
65586
|
for (const logFile of sortedNewestFirst) {
|
|
65494
|
-
const
|
|
65495
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
65587
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
65496
65588
|
if (content.includes("\"system.orchestrationId\":") && content.includes(`"${orchestrationId}"`)) {
|
|
65497
65589
|
context.stdout.write(`Found Worker log via system.orchestrationId for ${orchestrationId}: ${logFile}\n`);
|
|
65498
65590
|
return [logFile];
|
|
@@ -65502,11 +65594,10 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65502
65594
|
}
|
|
65503
65595
|
return sortedNewestFirst;
|
|
65504
65596
|
};
|
|
65505
|
-
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex) => {
|
|
65506
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
65597
|
+
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex, cache) => {
|
|
65598
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
65507
65599
|
for (const logFile of logsToCheck) {
|
|
65508
|
-
const
|
|
65509
|
-
const match = fs_1$2.default.readFileSync(filePath, "utf-8").match(jobAttributeRegex);
|
|
65600
|
+
const match = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache).match(jobAttributeRegex);
|
|
65510
65601
|
if (match && match[1]) return unescapeJsonString(match[1]);
|
|
65511
65602
|
}
|
|
65512
65603
|
};
|
|
@@ -65526,13 +65617,13 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65526
65617
|
*
|
|
65527
65618
|
* @returns The job display name, or undefined if not found
|
|
65528
65619
|
*/
|
|
65529
|
-
const getGithubJobNameFromLogs = (context) => {
|
|
65620
|
+
const getGithubJobNameFromLogs = (context, cache) => {
|
|
65530
65621
|
if (!(0, exports.shouldGetGithubJobDisplayName)()) return;
|
|
65531
65622
|
context.stdout.write("Determining GitHub job name\n");
|
|
65532
|
-
const result = getGithubWorkerLogFiles(context);
|
|
65623
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
65533
65624
|
if (!result) return;
|
|
65534
65625
|
const [foundDiagDir, workerLogFiles] = result;
|
|
65535
|
-
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex);
|
|
65626
|
+
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex, cache);
|
|
65536
65627
|
if (!jobDisplayName) context.stderr.write(`${chalk_1.default.yellow.bold("[WARNING]")} could not find "jobDisplayName" attribute in GitHub diagnostic logs`);
|
|
65537
65628
|
else {
|
|
65538
65629
|
context.stdout.write(`Successfully extracted job name: ${jobDisplayName}\n`);
|
|
@@ -65546,16 +65637,16 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65546
65637
|
* - job: extracts job display name
|
|
65547
65638
|
* - pipeline/stage: no-op
|
|
65548
65639
|
*/
|
|
65549
|
-
const enrichCIEnvFromGithubLogs = (context, level, ciEnv) => {
|
|
65640
|
+
const enrichCIEnvFromGithubLogs = (context, level, ciEnv, cache) => {
|
|
65550
65641
|
switch (level) {
|
|
65551
65642
|
case exports.CI_LEVELS.STEP: {
|
|
65552
|
-
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context);
|
|
65643
|
+
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context, cache);
|
|
65553
65644
|
if (!ciEnv[exports.envDDGithubJobName]) ciEnv[exports.envDDGithubJobName] = stepInfo.jobDisplayName;
|
|
65554
65645
|
ciEnv[exports.envDDGithubStepIndex] = String(stepInfo.stepIndex);
|
|
65555
65646
|
break;
|
|
65556
65647
|
}
|
|
65557
65648
|
case exports.CI_LEVELS.JOB: {
|
|
65558
|
-
const jobName = (0, exports.getGithubJobNameFromLogs)(context);
|
|
65649
|
+
const jobName = (0, exports.getGithubJobNameFromLogs)(context, cache);
|
|
65559
65650
|
if (jobName) ciEnv[exports.envDDGithubJobName] = jobName;
|
|
65560
65651
|
break;
|
|
65561
65652
|
}
|
|
@@ -65564,6 +65655,48 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65564
65655
|
};
|
|
65565
65656
|
exports.enrichCIEnvFromGithubLogs = enrichCIEnvFromGithubLogs;
|
|
65566
65657
|
/**
|
|
65658
|
+
* Sends the same payload to each requested CI level, one request per level.
|
|
65659
|
+
*
|
|
65660
|
+
* Shared by the `tag` and `measure` commands. Each level is enriched on its own
|
|
65661
|
+
* copy of `ciEnv` (so e.g. the step index never leaks into the job request).
|
|
65662
|
+
*
|
|
65663
|
+
* Failure handling mirrors the original single-level behavior:
|
|
65664
|
+
* - A setup/config error — a missing API key, or GitHub diagnostic logs that
|
|
65665
|
+
* cannot be located — is thrown and propagates to the caller's outer catch,
|
|
65666
|
+
* making it fatal regardless of `--no-fail`. The thrown error is annotated
|
|
65667
|
+
* with the failing level so the report says which one broke.
|
|
65668
|
+
* - A request that completes but reports a non-zero status sets the returned
|
|
65669
|
+
* flag and the loop continues; the caller decides whether `--no-fail` turns
|
|
65670
|
+
* it into a success.
|
|
65671
|
+
*
|
|
65672
|
+
* A single `GithubLogCache` lives for the duration of the loop so the GitHub
|
|
65673
|
+
* diagnostic logs are located and read at most once even when several levels
|
|
65674
|
+
* need them (e.g. `--level job,step`).
|
|
65675
|
+
*
|
|
65676
|
+
* Returns `true` if any level reported a non-zero status. Callers own the
|
|
65677
|
+
* `--no-fail`/success messaging and exit code based on this flag.
|
|
65678
|
+
*/
|
|
65679
|
+
const processLevels = (context, levels, ciEnv, sendForLevel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65680
|
+
const cache = (0, exports.createGithubLogCache)();
|
|
65681
|
+
let anyFailed = false;
|
|
65682
|
+
for (const level of levels) {
|
|
65683
|
+
let exitStatus;
|
|
65684
|
+
try {
|
|
65685
|
+
const levelEnv = Object.assign({}, ciEnv);
|
|
65686
|
+
(0, exports.enrichCIEnvFromGithubLogs)(context, level, levelEnv, cache);
|
|
65687
|
+
exitStatus = yield sendForLevel(levelEnv, exports.LEVEL_TO_NUMBER[level]);
|
|
65688
|
+
} catch (error) {
|
|
65689
|
+
throw new Error(`level '${level}': ${error.message}`);
|
|
65690
|
+
}
|
|
65691
|
+
if (exitStatus !== 0) {
|
|
65692
|
+
anyFailed = true;
|
|
65693
|
+
context.stderr.write(`${chalk_1.default.red.bold("[ERROR]")} failed to send for level '${level}'\n`);
|
|
65694
|
+
}
|
|
65695
|
+
}
|
|
65696
|
+
return anyFailed;
|
|
65697
|
+
});
|
|
65698
|
+
exports.processLevels = processLevels;
|
|
65699
|
+
/**
|
|
65567
65700
|
* Extracts the job display name and step index from GitHub Actions diagnostic logs.
|
|
65568
65701
|
*
|
|
65569
65702
|
* To avoid parsing the full Job message JSON (~26KB), we:
|
|
@@ -65571,18 +65704,17 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
65571
65704
|
* 2. Extract only the `"steps": [...]` array from the Job message via bracket-depth tracking
|
|
65572
65705
|
* 3. Parse just that array and match `contextName` against `GITHUB_ACTION`
|
|
65573
65706
|
*/
|
|
65574
|
-
const getGithubStepInfoFromLogs = (context) => {
|
|
65707
|
+
const getGithubStepInfoFromLogs = (context, cache) => {
|
|
65575
65708
|
if ((0, exports.getCIProvider)() !== exports.CI_ENGINES.GITHUB) throw new Error("Step level is only supported for GitHub Actions");
|
|
65576
65709
|
const githubAction = process.env.GITHUB_ACTION;
|
|
65577
65710
|
if (!githubAction) throw new Error("GITHUB_ACTION environment variable is not set, cannot determine step index");
|
|
65578
65711
|
context.stdout.write("Determining GitHub step info from diagnostic logs\n");
|
|
65579
|
-
const result = getGithubWorkerLogFiles(context);
|
|
65712
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
65580
65713
|
if (!result) throw new Error("Could not find GitHub diagnostic log files, cannot determine step index");
|
|
65581
65714
|
const [foundDiagDir, workerLogFiles] = result;
|
|
65582
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
65715
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
65583
65716
|
for (const logFile of logsToCheck) {
|
|
65584
|
-
const
|
|
65585
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
65717
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
65586
65718
|
const displayNameMatch = content.match(githubJobDisplayNameRegex);
|
|
65587
65719
|
if (!displayNameMatch || !displayNameMatch[1]) continue;
|
|
65588
65720
|
const jobDisplayName = unescapeJsonString(displayNameMatch[1]);
|