@datadog/datadog-ci-plugin-container-app 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/README.md +1 -1
- package/dist/bundle.js +156 -24
- 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.1",
|
|
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,7 +116080,31 @@ 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;
|
|
116054
|
-
|
|
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;
|
|
116103
|
+
exports.githubWellKnownDiagnosticDirsUnix = [
|
|
116104
|
+
"/home/runner/_diag",
|
|
116105
|
+
"/home/runner/actions-runner/_diag",
|
|
116106
|
+
"/opt/actions-runner/_diag"
|
|
116107
|
+
];
|
|
116055
116108
|
exports.githubWellKnownDiagnosticDirsWin = ["C:/actions-runner/_diag"];
|
|
116056
116109
|
exports.githubWellKnownDiagnosticDirPatternsUnix = ["/home/runner/actions-runner/*/_diag", "/home/runner/actions-runner/*/*/_diag"];
|
|
116057
116110
|
exports.githubWellKnownDiagnosticDirPatternsWin = ["C:/actions-runner/*/_diag", "C:/actions-runner/*/*/_diag"];
|
|
@@ -116092,6 +116145,11 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116092
116145
|
dirs.push(`${runnerRoot}/actions-runner/*/*/_diag`);
|
|
116093
116146
|
dirs.push(upath_1.default.join(runnerRoot, "actions-runner", "_diag"));
|
|
116094
116147
|
}
|
|
116148
|
+
const home = process.env.HOME;
|
|
116149
|
+
if (home) {
|
|
116150
|
+
dirs.push(upath_1.default.join(home, "_diag"));
|
|
116151
|
+
dirs.push(upath_1.default.join(home, "actions-runner", "_diag"));
|
|
116152
|
+
}
|
|
116095
116153
|
return uniq(dirs.filter(Boolean));
|
|
116096
116154
|
};
|
|
116097
116155
|
/**
|
|
@@ -116368,7 +116426,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116368
116426
|
}
|
|
116369
116427
|
}
|
|
116370
116428
|
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;
|
|
116429
|
+
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
116430
|
const url = `https://bitbucket.org/${BITBUCKET_REPO_FULL_NAME}/addon/pipelines/home#!/results/${BITBUCKET_BUILD_NUMBER}`;
|
|
116373
116431
|
tags = {
|
|
116374
116432
|
[tags_1.CI_PROVIDER_NAME]: exports.CI_ENGINES.BITBUCKET,
|
|
@@ -116386,6 +116444,7 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116386
116444
|
if (BITBUCKET_PR_ID) {
|
|
116387
116445
|
tags[tags_1.PR_NUMBER] = BITBUCKET_PR_ID;
|
|
116388
116446
|
tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH] = BITBUCKET_PR_DESTINATION_BRANCH;
|
|
116447
|
+
if (BITBUCKET_PR_DESTINATION_COMMIT) tags[tags_1.GIT_PULL_REQUEST_BASE_BRANCH_SHA] = BITBUCKET_PR_DESTINATION_COMMIT;
|
|
116389
116448
|
}
|
|
116390
116449
|
}
|
|
116391
116450
|
if (env.CF_BUILD_ID) {
|
|
@@ -116695,7 +116754,32 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116695
116754
|
return os.toLowerCase() === "windows";
|
|
116696
116755
|
};
|
|
116697
116756
|
exports.isGithubWindowsRunner = isGithubWindowsRunner;
|
|
116698
|
-
const
|
|
116757
|
+
const createGithubLogCache = () => ({
|
|
116758
|
+
workerLogFilesResolved: false,
|
|
116759
|
+
workerLogFiles: void 0,
|
|
116760
|
+
targetLogFilesResolved: false,
|
|
116761
|
+
targetLogFiles: [],
|
|
116762
|
+
fileContents: /* @__PURE__ */ new Map()
|
|
116763
|
+
});
|
|
116764
|
+
exports.createGithubLogCache = createGithubLogCache;
|
|
116765
|
+
/** Reads a diagnostic log file, serving from (and populating) `cache` when provided. */
|
|
116766
|
+
const readLogFile = (filePath, cache) => {
|
|
116767
|
+
const cached = cache === null || cache === void 0 ? void 0 : cache.fileContents.get(filePath);
|
|
116768
|
+
if (cached !== void 0) return cached;
|
|
116769
|
+
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
116770
|
+
cache === null || cache === void 0 || cache.fileContents.set(filePath, content);
|
|
116771
|
+
return content;
|
|
116772
|
+
};
|
|
116773
|
+
const getGithubWorkerLogFiles = (context, cache) => {
|
|
116774
|
+
if (cache === null || cache === void 0 ? void 0 : cache.workerLogFilesResolved) return cache.workerLogFiles;
|
|
116775
|
+
const result = computeGithubWorkerLogFiles(context);
|
|
116776
|
+
if (cache) {
|
|
116777
|
+
cache.workerLogFilesResolved = true;
|
|
116778
|
+
cache.workerLogFiles = result;
|
|
116779
|
+
}
|
|
116780
|
+
return result;
|
|
116781
|
+
};
|
|
116782
|
+
const computeGithubWorkerLogFiles = (context) => {
|
|
116699
116783
|
let foundDiagDir = "";
|
|
116700
116784
|
let workerLogFiles = [];
|
|
116701
116785
|
let wellKnownDirs = expandDiagnosticDirCandidates([
|
|
@@ -116752,13 +116836,21 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116752
116836
|
* which on a single-job runner is immediate, and on a multi-runner is the current
|
|
116753
116837
|
* job's (most recent) log.
|
|
116754
116838
|
*/
|
|
116755
|
-
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles) => {
|
|
116839
|
+
const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
116840
|
+
if (cache === null || cache === void 0 ? void 0 : cache.targetLogFilesResolved) return cache.targetLogFiles;
|
|
116841
|
+
const result = computeTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
116842
|
+
if (cache) {
|
|
116843
|
+
cache.targetLogFilesResolved = true;
|
|
116844
|
+
cache.targetLogFiles = result;
|
|
116845
|
+
}
|
|
116846
|
+
return result;
|
|
116847
|
+
};
|
|
116848
|
+
const computeTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles, cache) => {
|
|
116756
116849
|
const sortedNewestFirst = [...workerLogFiles].sort().reverse();
|
|
116757
116850
|
const orchestrationId = process.env.ACTIONS_ORCHESTRATION_ID;
|
|
116758
116851
|
if (orchestrationId) {
|
|
116759
116852
|
for (const logFile of sortedNewestFirst) {
|
|
116760
|
-
const
|
|
116761
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
116853
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
116762
116854
|
if (content.includes("\"system.orchestrationId\":") && content.includes(`"${orchestrationId}"`)) {
|
|
116763
116855
|
context.stdout.write(`Found Worker log via system.orchestrationId for ${orchestrationId}: ${logFile}\n`);
|
|
116764
116856
|
return [logFile];
|
|
@@ -116768,11 +116860,10 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116768
116860
|
}
|
|
116769
116861
|
return sortedNewestFirst;
|
|
116770
116862
|
};
|
|
116771
|
-
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex) => {
|
|
116772
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
116863
|
+
const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex, cache) => {
|
|
116864
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
116773
116865
|
for (const logFile of logsToCheck) {
|
|
116774
|
-
const
|
|
116775
|
-
const match = fs_1$2.default.readFileSync(filePath, "utf-8").match(jobAttributeRegex);
|
|
116866
|
+
const match = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache).match(jobAttributeRegex);
|
|
116776
116867
|
if (match && match[1]) return unescapeJsonString(match[1]);
|
|
116777
116868
|
}
|
|
116778
116869
|
};
|
|
@@ -116792,13 +116883,13 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116792
116883
|
*
|
|
116793
116884
|
* @returns The job display name, or undefined if not found
|
|
116794
116885
|
*/
|
|
116795
|
-
const getGithubJobNameFromLogs = (context) => {
|
|
116886
|
+
const getGithubJobNameFromLogs = (context, cache) => {
|
|
116796
116887
|
if (!(0, exports.shouldGetGithubJobDisplayName)()) return;
|
|
116797
116888
|
context.stdout.write("Determining GitHub job name\n");
|
|
116798
|
-
const result = getGithubWorkerLogFiles(context);
|
|
116889
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
116799
116890
|
if (!result) return;
|
|
116800
116891
|
const [foundDiagDir, workerLogFiles] = result;
|
|
116801
|
-
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex);
|
|
116892
|
+
const jobDisplayName = getGithubJobAttributeFromLogFiles(context, foundDiagDir, workerLogFiles, githubJobDisplayNameRegex, cache);
|
|
116802
116893
|
if (!jobDisplayName) context.stderr.write(`${chalk_1.default.yellow.bold("[WARNING]")} could not find "jobDisplayName" attribute in GitHub diagnostic logs`);
|
|
116803
116894
|
else {
|
|
116804
116895
|
context.stdout.write(`Successfully extracted job name: ${jobDisplayName}\n`);
|
|
@@ -116812,16 +116903,16 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116812
116903
|
* - job: extracts job display name
|
|
116813
116904
|
* - pipeline/stage: no-op
|
|
116814
116905
|
*/
|
|
116815
|
-
const enrichCIEnvFromGithubLogs = (context, level, ciEnv) => {
|
|
116906
|
+
const enrichCIEnvFromGithubLogs = (context, level, ciEnv, cache) => {
|
|
116816
116907
|
switch (level) {
|
|
116817
116908
|
case exports.CI_LEVELS.STEP: {
|
|
116818
|
-
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context);
|
|
116909
|
+
const stepInfo = (0, exports.getGithubStepInfoFromLogs)(context, cache);
|
|
116819
116910
|
if (!ciEnv[exports.envDDGithubJobName]) ciEnv[exports.envDDGithubJobName] = stepInfo.jobDisplayName;
|
|
116820
116911
|
ciEnv[exports.envDDGithubStepIndex] = String(stepInfo.stepIndex);
|
|
116821
116912
|
break;
|
|
116822
116913
|
}
|
|
116823
116914
|
case exports.CI_LEVELS.JOB: {
|
|
116824
|
-
const jobName = (0, exports.getGithubJobNameFromLogs)(context);
|
|
116915
|
+
const jobName = (0, exports.getGithubJobNameFromLogs)(context, cache);
|
|
116825
116916
|
if (jobName) ciEnv[exports.envDDGithubJobName] = jobName;
|
|
116826
116917
|
break;
|
|
116827
116918
|
}
|
|
@@ -116830,6 +116921,48 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116830
116921
|
};
|
|
116831
116922
|
exports.enrichCIEnvFromGithubLogs = enrichCIEnvFromGithubLogs;
|
|
116832
116923
|
/**
|
|
116924
|
+
* Sends the same payload to each requested CI level, one request per level.
|
|
116925
|
+
*
|
|
116926
|
+
* Shared by the `tag` and `measure` commands. Each level is enriched on its own
|
|
116927
|
+
* copy of `ciEnv` (so e.g. the step index never leaks into the job request).
|
|
116928
|
+
*
|
|
116929
|
+
* Failure handling mirrors the original single-level behavior:
|
|
116930
|
+
* - A setup/config error — a missing API key, or GitHub diagnostic logs that
|
|
116931
|
+
* cannot be located — is thrown and propagates to the caller's outer catch,
|
|
116932
|
+
* making it fatal regardless of `--no-fail`. The thrown error is annotated
|
|
116933
|
+
* with the failing level so the report says which one broke.
|
|
116934
|
+
* - A request that completes but reports a non-zero status sets the returned
|
|
116935
|
+
* flag and the loop continues; the caller decides whether `--no-fail` turns
|
|
116936
|
+
* it into a success.
|
|
116937
|
+
*
|
|
116938
|
+
* A single `GithubLogCache` lives for the duration of the loop so the GitHub
|
|
116939
|
+
* diagnostic logs are located and read at most once even when several levels
|
|
116940
|
+
* need them (e.g. `--level job,step`).
|
|
116941
|
+
*
|
|
116942
|
+
* Returns `true` if any level reported a non-zero status. Callers own the
|
|
116943
|
+
* `--no-fail`/success messaging and exit code based on this flag.
|
|
116944
|
+
*/
|
|
116945
|
+
const processLevels = (context, levels, ciEnv, sendForLevel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
116946
|
+
const cache = (0, exports.createGithubLogCache)();
|
|
116947
|
+
let anyFailed = false;
|
|
116948
|
+
for (const level of levels) {
|
|
116949
|
+
let exitStatus;
|
|
116950
|
+
try {
|
|
116951
|
+
const levelEnv = Object.assign({}, ciEnv);
|
|
116952
|
+
(0, exports.enrichCIEnvFromGithubLogs)(context, level, levelEnv, cache);
|
|
116953
|
+
exitStatus = yield sendForLevel(levelEnv, exports.LEVEL_TO_NUMBER[level]);
|
|
116954
|
+
} catch (error) {
|
|
116955
|
+
throw new Error(`level '${level}': ${error.message}`);
|
|
116956
|
+
}
|
|
116957
|
+
if (exitStatus !== 0) {
|
|
116958
|
+
anyFailed = true;
|
|
116959
|
+
context.stderr.write(`${chalk_1.default.red.bold("[ERROR]")} failed to send for level '${level}'\n`);
|
|
116960
|
+
}
|
|
116961
|
+
}
|
|
116962
|
+
return anyFailed;
|
|
116963
|
+
});
|
|
116964
|
+
exports.processLevels = processLevels;
|
|
116965
|
+
/**
|
|
116833
116966
|
* Extracts the job display name and step index from GitHub Actions diagnostic logs.
|
|
116834
116967
|
*
|
|
116835
116968
|
* To avoid parsing the full Job message JSON (~26KB), we:
|
|
@@ -116837,18 +116970,17 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
116837
116970
|
* 2. Extract only the `"steps": [...]` array from the Job message via bracket-depth tracking
|
|
116838
116971
|
* 3. Parse just that array and match `contextName` against `GITHUB_ACTION`
|
|
116839
116972
|
*/
|
|
116840
|
-
const getGithubStepInfoFromLogs = (context) => {
|
|
116973
|
+
const getGithubStepInfoFromLogs = (context, cache) => {
|
|
116841
116974
|
if ((0, exports.getCIProvider)() !== exports.CI_ENGINES.GITHUB) throw new Error("Step level is only supported for GitHub Actions");
|
|
116842
116975
|
const githubAction = process.env.GITHUB_ACTION;
|
|
116843
116976
|
if (!githubAction) throw new Error("GITHUB_ACTION environment variable is not set, cannot determine step index");
|
|
116844
116977
|
context.stdout.write("Determining GitHub step info from diagnostic logs\n");
|
|
116845
|
-
const result = getGithubWorkerLogFiles(context);
|
|
116978
|
+
const result = getGithubWorkerLogFiles(context, cache);
|
|
116846
116979
|
if (!result) throw new Error("Could not find GitHub diagnostic log files, cannot determine step index");
|
|
116847
116980
|
const [foundDiagDir, workerLogFiles] = result;
|
|
116848
|
-
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
|
|
116981
|
+
const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles, cache);
|
|
116849
116982
|
for (const logFile of logsToCheck) {
|
|
116850
|
-
const
|
|
116851
|
-
const content = fs_1$2.default.readFileSync(filePath, "utf-8");
|
|
116983
|
+
const content = readLogFile(upath_1.default.join(foundDiagDir, logFile), cache);
|
|
116852
116984
|
const displayNameMatch = content.match(githubJobDisplayNameRegex);
|
|
116853
116985
|
if (!displayNameMatch || !displayNameMatch[1]) continue;
|
|
116854
116986
|
const jobDisplayName = unescapeJsonString(displayNameMatch[1]);
|