@datadog/datadog-ci-plugin-container-app 5.20.1 → 5.21.0
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/README.md +1 -1
- package/dist/bundle.js +146 -23
- package/dist/bundle.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ You must expose these environment variables in the environment where you are run
|
|
|
95
95
|
| Environment Variable | Description | Example |
|
|
96
96
|
| -------------------- | ----------- | ------- |
|
|
97
97
|
| `DD_API_KEY` | **Required**. Datadog API Key. Sets the `DD_API_KEY` environment variable on your Container App. For more information about getting a Datadog API key, see the [API key documentation][1]. | `export DD_API_KEY=<API_KEY>` |
|
|
98
|
-
| `DD_SITE` | Set which Datadog site to send data to. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, `ap1.datadoghq.com`, `ap2.datadoghq.com`, `ddog-gov.com`, and `us2.ddog-gov.com`. The default is `datadoghq.com`. | `export DD_SITE=datadoghq.com` |
|
|
98
|
+
| `DD_SITE` | Set which Datadog site to send data to. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, `ap1.datadoghq.com`, `ap2.datadoghq.com`, `uk1.datadoghq.com`, `ddog-gov.com`, and `us2.ddog-gov.com`. The default is `datadoghq.com`. | `export DD_SITE=datadoghq.com` |
|
|
99
99
|
|
|
100
100
|
### Arguments
|
|
101
101
|
|
package/dist/bundle.js
CHANGED
|
@@ -53125,7 +53125,7 @@ var require_source$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
53125
53125
|
var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
53126
53126
|
module.exports = {
|
|
53127
53127
|
"name": "@datadog/datadog-ci-base",
|
|
53128
|
-
"version": "5.
|
|
53128
|
+
"version": "5.21.0",
|
|
53129
53129
|
"description": "Base package for Datadog CI",
|
|
53130
53130
|
"license": "Apache-2.0",
|
|
53131
53131
|
"keywords": ["datadog", "datadog-ci"],
|
|
@@ -53253,13 +53253,14 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
53253
53253
|
//#region ../base/dist/constants.js
|
|
53254
53254
|
var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
53255
53255
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53256
|
-
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;
|
|
53256
|
+
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;
|
|
53257
53257
|
exports.DATADOG_SITE_US1 = "datadoghq.com";
|
|
53258
53258
|
exports.DATADOG_SITE_EU1 = "datadoghq.eu";
|
|
53259
53259
|
exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
|
|
53260
53260
|
exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
|
|
53261
53261
|
exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
|
|
53262
53262
|
exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
|
|
53263
|
+
exports.DATADOG_SITE_UK1 = "uk1.datadoghq.com";
|
|
53263
53264
|
exports.DATADOG_SITE_GOV = "ddog-gov.com";
|
|
53264
53265
|
exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
|
|
53265
53266
|
exports.DATADOG_SITES = [
|
|
@@ -53269,6 +53270,7 @@ var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
53269
53270
|
exports.DATADOG_SITE_US5,
|
|
53270
53271
|
exports.DATADOG_SITE_AP1,
|
|
53271
53272
|
exports.DATADOG_SITE_AP2,
|
|
53273
|
+
exports.DATADOG_SITE_UK1,
|
|
53272
53274
|
exports.DATADOG_SITE_GOV,
|
|
53273
53275
|
exports.DATADOG_SITE_US2_GOV
|
|
53274
53276
|
];
|
|
@@ -115989,11 +115991,38 @@ var require_tags = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
115989
115991
|
//#endregion
|
|
115990
115992
|
//#region ../base/dist/helpers/ci.js
|
|
115991
115993
|
var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
115994
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
115995
|
+
function adopt(value) {
|
|
115996
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
115997
|
+
resolve(value);
|
|
115998
|
+
});
|
|
115999
|
+
}
|
|
116000
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
116001
|
+
function fulfilled(value) {
|
|
116002
|
+
try {
|
|
116003
|
+
step(generator.next(value));
|
|
116004
|
+
} catch (e) {
|
|
116005
|
+
reject(e);
|
|
116006
|
+
}
|
|
116007
|
+
}
|
|
116008
|
+
function rejected(value) {
|
|
116009
|
+
try {
|
|
116010
|
+
step(generator["throw"](value));
|
|
116011
|
+
} catch (e) {
|
|
116012
|
+
reject(e);
|
|
116013
|
+
}
|
|
116014
|
+
}
|
|
116015
|
+
function step(result) {
|
|
116016
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
116017
|
+
}
|
|
116018
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
116019
|
+
});
|
|
116020
|
+
};
|
|
115992
116021
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
115993
116022
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
115994
116023
|
};
|
|
115995
116024
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
115996
|
-
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;
|
|
116025
|
+
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;
|
|
115997
116026
|
const fs_1$2 = __importDefault(require("fs"));
|
|
115998
116027
|
const chalk_1 = __importDefault(require_source$1());
|
|
115999
116028
|
const upath_1 = __importDefault(require_upath());
|
|
@@ -116051,6 +116080,26 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116051
116080
|
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}]`;
|
|
116052
116081
|
};
|
|
116053
116082
|
exports.validateLevel = validateLevel;
|
|
116083
|
+
/**
|
|
116084
|
+
* Parses an additive, comma-separated `--level` value (e.g. "pipeline,stage").
|
|
116085
|
+
* Trims each member, drops empties, dedupes, sorts by span depth, and validates
|
|
116086
|
+
* every member (known value + provider support). Returns the parsed levels or,
|
|
116087
|
+
* if anything is invalid or empty, a single aggregated error message.
|
|
116088
|
+
*/
|
|
116089
|
+
const parseLevels = (input) => {
|
|
116090
|
+
const unique = uniq((input !== null && input !== void 0 ? input : "").split(",").map((p) => p.trim()).filter((p) => p.length > 0));
|
|
116091
|
+
if (unique.length === 0) return {
|
|
116092
|
+
levels: [],
|
|
116093
|
+
error: `Level must be one of [${exports.VALID_LEVELS.join(", ")}]`
|
|
116094
|
+
};
|
|
116095
|
+
const errors = uniq(unique.map((p) => (0, exports.validateLevel)(p)).filter((e) => Boolean(e)));
|
|
116096
|
+
if (errors.length > 0) return {
|
|
116097
|
+
levels: [],
|
|
116098
|
+
error: errors.join("; ")
|
|
116099
|
+
};
|
|
116100
|
+
return { levels: unique.sort((a, b) => exports.LEVEL_TO_NUMBER[a] - exports.LEVEL_TO_NUMBER[b]) };
|
|
116101
|
+
};
|
|
116102
|
+
exports.parseLevels = parseLevels;
|
|
116054
116103
|
exports.githubWellKnownDiagnosticDirsUnix = ["/home/runner/actions-runner/_diag", "/opt/actions-runner/_diag"];
|
|
116055
116104
|
exports.githubWellKnownDiagnosticDirsWin = ["C:/actions-runner/_diag"];
|
|
116056
116105
|
exports.githubWellKnownDiagnosticDirPatternsUnix = ["/home/runner/actions-runner/*/_diag", "/home/runner/actions-runner/*/*/_diag"];
|
|
@@ -116368,7 +116417,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116368
116417
|
}
|
|
116369
116418
|
}
|
|
116370
116419
|
if (env.BITBUCKET_COMMIT) {
|
|
116371
|
-
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;
|
|
116420
|
+
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;
|
|
116372
116421
|
const url = `https://bitbucket.org/${BITBUCKET_REPO_FULL_NAME}/addon/pipelines/home#!/results/${BITBUCKET_BUILD_NUMBER}`;
|
|
116373
116422
|
tags = {
|
|
116374
116423
|
[tags_1.CI_PROVIDER_NAME]: exports.CI_ENGINES.BITBUCKET,
|
|
@@ -116386,6 +116435,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116386
116435
|
if (BITBUCKET_PR_ID) {
|
|
116387
116436
|
tags[tags_1.PR_NUMBER] = BITBUCKET_PR_ID;
|
|
116388
116437
|
tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH] = BITBUCKET_PR_DESTINATION_BRANCH;
|
|
116438
|
+
if (BITBUCKET_PR_DESTINATION_COMMIT) tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH_SHA] = BITBUCKET_PR_DESTINATION_COMMIT;
|
|
116389
116439
|
}
|
|
116390
116440
|
}
|
|
116391
116441
|
if (env.CF_BUILD_ID) {
|
|
@@ -116695,7 +116745,32 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116695
116745
|
return os.toLowerCase() === "windows";
|
|
116696
116746
|
};
|
|
116697
116747
|
exports.isGithubWindowsRunner = isGithubWindowsRunner;
|
|
116698
|
-
const
|
|
116748
|
+
const createGithubLogCache = () => ({
|
|
116749
|
+
workerLogFilesResolved: false,
|
|
116750
|
+
workerLogFiles: void 0,
|
|
116751
|
+
targetLogFilesResolved: false,
|
|
116752
|
+
targetLogFiles: [],
|
|
116753
|
+
fileContents: /* @__PURE__ */ new Map()
|
|
116754
|
+
});
|
|
116755
|
+
exports.createGithubLogCache = createGithubLogCache;
|
|
116756
|
+
/** Reads a diagnostic log file, serving from (and populating) `cache` when provided. */
|
|
116757
|
+
const readLogFile = (filePath, cache) => {
|
|
116758
|
+
const cached = cache === null || cache === void 0 ? void 0 : cache.fileContents.get(filePath);
|
|
116759
|
+
if (cached !== void 0) return cached;
|
|
116760
|
+
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
116761
|
+
cache === null || cache === void 0 || cache.fileContents.set(filePath, content);
|
|
116762
|
+
return content;
|
|
116763
|
+
};
|
|
116764
|
+
const getGithubWorkerLogFiles = (context, cache) => {
|
|
116765
|
+
if (cache === null || cache === void 0 ? void 0 : cache.workerLogFilesResolved) return cache.workerLogFiles;
|
|
116766
|
+
const result = computeGithubWorkerLogFiles(context);
|
|
116767
|
+
if (cache) {
|
|
116768
|
+
cache.workerLogFilesResolved = true;
|
|
116769
|
+
cache.workerLogFiles = result;
|
|
116770
|
+
}
|
|
116771
|
+
return result;
|
|
116772
|
+
};
|
|
116773
|
+
const computeGithubWorkerLogFiles = (context) => {
|
|
116699
116774
|
let foundDiagDir = "";
|
|
116700
116775
|
let workerLogFiles = [];
|
|
116701
116776
|
let wellKnownDirs = expandDiagnosticDirCandidates([
|
|
@@ -116752,13 +116827,21 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116752
116827
|
* which on a single-job runner is immediate, and on a multi-runner is the current
|
|
116753
116828
|
* job's (most recent) log.
|
|
116754
116829
|
*/
|
|
116755
|
-
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles) => {
|
|
116830
|
+
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
116831
|
+
if (cache === null || cache === void 0 ? void 0 : cache.targetLogFilesResolved) return cache.targetLogFiles;
|
|
116832
|
+
const result = computeTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
116833
|
+
if (cache) {
|
|
116834
|
+
cache.targetLogFilesResolved = true;
|
|
116835
|
+
cache.targetLogFiles = result;
|
|
116836
|
+
}
|
|
116837
|
+
return result;
|
|
116838
|
+
};
|
|
116839
|
+
const computeTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
116756
116840
|
const sortedNewestFirst = [...workerLogFiles].sort().reverse();
|
|
116757
116841
|
const orchestrationId = process.env.ACTIONS_ORCHESTRATION_ID;
|
|
116758
116842
|
if (orchestrationId) {
|
|
116759
116843
|
for (const logFile of sortedNewestFirst) {
|
|
116760
|
-
const
|
|
116761
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
116844
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
116762
116845
|
if (content.includes("\"system.orchestrationId\":") && content.includes(`"${orchestrationId}"`)) {
|
|
116763
116846
|
context.stdout.write(`Found Worker log via system.orchestrationId for ${orchestrationId}: ${logFile}\n`);
|
|
116764
116847
|
return [logFile];
|
|
@@ -116768,11 +116851,10 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116768
116851
|
}
|
|
116769
116852
|
return sortedNewestFirst;
|
|
116770
116853
|
};
|
|
116771
|
-
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex) => {
|
|
116772
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
116854
|
+
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex, cache) => {
|
|
116855
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
116773
116856
|
for (const logFile of logsToCheck) {
|
|
116774
|
-
const
|
|
116775
|
-
const match = fs_1$2.default.readFileSync(filePath, "utf-8").match(jobAttributeRegex);
|
|
116857
|
+
const match = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache).match(jobAttributeRegex);
|
|
116776
116858
|
if (match && match[1]) return unescapeJsonString(match[1]);
|
|
116777
116859
|
}
|
|
116778
116860
|
};
|
|
@@ -116792,13 +116874,13 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116792
116874
|
*
|
|
116793
116875
|
* @returns The job display name, or undefined if not found
|
|
116794
116876
|
*/
|
|
116795
|
-
const getGithubJobNameFromLogs = (context) => {
|
|
116877
|
+
const getGithubJobNameFromLogs = (context, cache) => {
|
|
116796
116878
|
if (!(0, exports.shouldGetGithubJobDisplayName)()) return;
|
|
116797
116879
|
context.stdout.write("Determining GitHub job name\n");
|
|
116798
|
-
const result = getGithubWorkerLogFiles(context);
|
|
116880
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
116799
116881
|
if (!result) return;
|
|
116800
116882
|
const [foundDiagDir, workerLogFiles] = result;
|
|
116801
|
-
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex);
|
|
116883
|
+
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex, cache);
|
|
116802
116884
|
if (!jobDisplayName) context.stderr.write(`${chalk_1.default.yellow.bold("[WARNING]")} could not find "jobDisplayName" attribute in GitHub diagnostic logs`);
|
|
116803
116885
|
else {
|
|
116804
116886
|
context.stdout.write(`Successfully extracted job name: ${jobDisplayName}\n`);
|
|
@@ -116812,16 +116894,16 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116812
116894
|
* - job: extracts job display name
|
|
116813
116895
|
* - pipeline/stage: no-op
|
|
116814
116896
|
*/
|
|
116815
|
-
const enrichCIEnvFromGithubLogs = (context, level, ciEnv) => {
|
|
116897
|
+
const enrichCIEnvFromGithubLogs = (context, level, ciEnv, cache) => {
|
|
116816
116898
|
switch (level) {
|
|
116817
116899
|
case exports.CI_LEVELS.STEP: {
|
|
116818
|
-
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context);
|
|
116900
|
+
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context, cache);
|
|
116819
116901
|
if (!ciEnv[exports.envDDGithubJobName]) ciEnv[exports.envDDGithubJobName] = stepInfo.jobDisplayName;
|
|
116820
116902
|
ciEnv[exports.envDDGithubStepIndex] = String(stepInfo.stepIndex);
|
|
116821
116903
|
break;
|
|
116822
116904
|
}
|
|
116823
116905
|
case exports.CI_LEVELS.JOB: {
|
|
116824
|
-
const jobName = (0, exports.getGithubJobNameFromLogs)(context);
|
|
116906
|
+
const jobName = (0, exports.getGithubJobNameFromLogs)(context, cache);
|
|
116825
116907
|
if (jobName) ciEnv[exports.envDDGithubJobName] = jobName;
|
|
116826
116908
|
break;
|
|
116827
116909
|
}
|
|
@@ -116830,6 +116912,48 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116830
116912
|
};
|
|
116831
116913
|
exports.enrichCIEnvFromGithubLogs = enrichCIEnvFromGithubLogs;
|
|
116832
116914
|
/**
|
|
116915
|
+
* Sends the same payload to each requested CI level, one request per level.
|
|
116916
|
+
*
|
|
116917
|
+
* Shared by the `tag` and `measure` commands. Each level is enriched on its own
|
|
116918
|
+
* copy of `ciEnv` (so e.g. the step index never leaks into the job request).
|
|
116919
|
+
*
|
|
116920
|
+
* Failure handling mirrors the original single-level behavior:
|
|
116921
|
+
* - A setup/config error — a missing API key, or GitHub diagnostic logs that
|
|
116922
|
+
* cannot be located — is thrown and propagates to the caller's outer catch,
|
|
116923
|
+
* making it fatal regardless of `--no-fail`. The thrown error is annotated
|
|
116924
|
+
* with the failing level so the report says which one broke.
|
|
116925
|
+
* - A request that completes but reports a non-zero status sets the returned
|
|
116926
|
+
* flag and the loop continues; the caller decides whether `--no-fail` turns
|
|
116927
|
+
* it into a success.
|
|
116928
|
+
*
|
|
116929
|
+
* A single `GithubLogCache` lives for the duration of the loop so the GitHub
|
|
116930
|
+
* diagnostic logs are located and read at most once even when several levels
|
|
116931
|
+
* need them (e.g. `--level job,step`).
|
|
116932
|
+
*
|
|
116933
|
+
* Returns `true` if any level reported a non-zero status. Callers own the
|
|
116934
|
+
* `--no-fail`/success messaging and exit code based on this flag.
|
|
116935
|
+
*/
|
|
116936
|
+
const processLevels = (context, levels, ciEnv, sendForLevel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
116937
|
+
const cache = (0, exports.createGithubLogCache)();
|
|
116938
|
+
let anyFailed = false;
|
|
116939
|
+
for (const level of levels) {
|
|
116940
|
+
let exitStatus;
|
|
116941
|
+
try {
|
|
116942
|
+
const levelEnv = Object.assign({}, ciEnv);
|
|
116943
|
+
(0, exports.enrichCIEnvFromGithubLogs)(context, level, levelEnv, cache);
|
|
116944
|
+
exitStatus = yield sendForLevel(levelEnv, exports.LEVEL_TO_NUMBER[level]);
|
|
116945
|
+
} catch (error) {
|
|
116946
|
+
throw new Error(`level '${level}': ${error.message}`);
|
|
116947
|
+
}
|
|
116948
|
+
if (exitStatus !== 0) {
|
|
116949
|
+
anyFailed = true;
|
|
116950
|
+
context.stderr.write(`${chalk_1.default.red.bold("[ERROR]")} failed to send for level '${level}'\n`);
|
|
116951
|
+
}
|
|
116952
|
+
}
|
|
116953
|
+
return anyFailed;
|
|
116954
|
+
});
|
|
116955
|
+
exports.processLevels = processLevels;
|
|
116956
|
+
/**
|
|
116833
116957
|
* Extracts the job display name and step index from GitHub Actions diagnostic logs.
|
|
116834
116958
|
*
|
|
116835
116959
|
* To avoid parsing the full Job message JSON (~26KB), we:
|
|
@@ -116837,18 +116961,17 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116837
116961
|
* 2. Extract only the `"steps": [...]` array from the Job message via bracket-depth tracking
|
|
116838
116962
|
* 3. Parse just that array and match `contextName` against `GITHUB_ACTION`
|
|
116839
116963
|
*/
|
|
116840
|
-
const getGithubStepInfoFromLogs = (context) => {
|
|
116964
|
+
const getGithubStepInfoFromLogs = (context, cache) => {
|
|
116841
116965
|
if ((0, exports.getCIProvider)() !== exports.CI_ENGINES.GITHUB) throw new Error("Step level is only supported for GitHub Actions");
|
|
116842
116966
|
const githubAction = process.env.GITHUB_ACTION;
|
|
116843
116967
|
if (!githubAction) throw new Error("GITHUB_ACTION environment variable is not set, cannot determine step index");
|
|
116844
116968
|
context.stdout.write("Determining GitHub step info from diagnostic logs\n");
|
|
116845
|
-
const result = getGithubWorkerLogFiles(context);
|
|
116969
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
116846
116970
|
if (!result) throw new Error("Could not find GitHub diagnostic log files, cannot determine step index");
|
|
116847
116971
|
const [foundDiagDir, workerLogFiles] = result;
|
|
116848
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
116972
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
116849
116973
|
for (const logFile of logsToCheck) {
|
|
116850
|
-
const
|
|
116851
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
116974
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
116852
116975
|
const displayNameMatch = content.match(githubJobDisplayNameRegex);
|
|
116853
116976
|
if (!displayNameMatch || !displayNameMatch[1]) continue;
|
|
116854
116977
|
const jobDisplayName = unescapeJsonString(displayNameMatch[1]);
|