Build outputs

This commit is contained in:
daz
2024-04-09 15:08:36 -06:00
parent aeb3156e6f
commit dec6c472c1
8 changed files with 1681 additions and 1175 deletions

View File

@@ -137375,7 +137375,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getCacheKeyBase = exports.generateCacheKey = exports.CacheKey = void 0;
const github = __importStar(__nccwpck_require__(95438));
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const cache_utils_1 = __nccwpck_require__(11044);
const CACHE_PROTOCOL_VERSION = 'v1';
const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX';
@@ -137420,7 +137420,7 @@ function getCacheKeyJobInstance() {
return override;
}
const workflowName = github.context.workflow;
const workflowJobContext = (0, input_params_1.getJobMatrix)();
const workflowJobContext = (0, configuration_1.getJobMatrix)();
return (0, cache_utils_1.hashStrings)([workflowName, workflowJobContext]);
}
function getCacheKeyJobExecution() {
@@ -138556,375 +138556,7 @@ exports.GradleUserHomeCache = GradleUserHomeCache;
/***/ }),
/***/ 85146:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DaemonController = void 0;
const core = __importStar(__nccwpck_require__(42186));
const exec = __importStar(__nccwpck_require__(71514));
const fs = __importStar(__nccwpck_require__(57147));
const path = __importStar(__nccwpck_require__(71017));
class DaemonController {
constructor(buildResults) {
const allHomes = buildResults.map(buildResult => buildResult.gradleHomeDir);
this.gradleHomes = Array.from(new Set(allHomes));
}
stopAllDaemons() {
return __awaiter(this, void 0, void 0, function* () {
core.info('Stopping all Gradle daemons before saving Gradle User Home state');
const executions = [];
const args = ['--stop'];
for (const gradleHome of this.gradleHomes) {
const executable = path.resolve(gradleHome, 'bin', 'gradle');
if (!fs.existsSync(executable)) {
core.warning(`Gradle executable not found at ${executable}. Could not stop Gradle daemons.`);
continue;
}
core.info(`Stopping Gradle daemons for ${gradleHome}`);
executions.push(exec.exec(executable, args, {
ignoreReturnCode: true
}));
}
yield Promise.all(executions);
});
}
}
exports.DaemonController = DaemonController;
/***/ }),
/***/ 80:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.complete = exports.setup = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const glob = __importStar(__nccwpck_require__(28090));
const artifact_1 = __nccwpck_require__(79450);
const request_error_1 = __nccwpck_require__(10537);
const path = __importStar(__nccwpck_require__(71017));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const errors_1 = __nccwpck_require__(36976);
const input_params_1 = __nccwpck_require__(23885);
const DEPENDENCY_GRAPH_PREFIX = 'dependency-graph_';
function setup(config) {
return __awaiter(this, void 0, void 0, function* () {
const option = config.getDependencyGraphOption();
if (option === input_params_1.DependencyGraphOption.Disabled) {
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'false');
return;
}
if (option === input_params_1.DependencyGraphOption.DownloadAndSubmit) {
yield downloadAndSubmitDependencyGraphs(config);
return;
}
core.info('Enabling dependency graph generation');
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'true');
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_CONTINUE_ON_FAILURE', config.getDependencyGraphContinueOnFailure());
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR', config.getJobCorrelator());
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId);
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_REF', github.context.ref);
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_SHA', getShaFromContext());
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_WORKSPACE', (0, input_params_1.getWorkspaceDirectory)());
maybeExportVariable('DEPENDENCY_GRAPH_REPORT_DIR', path.resolve((0, input_params_1.getWorkspaceDirectory)(), 'dependency-graph-reports'));
if (option === input_params_1.DependencyGraphOption.Clear) {
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_PROJECTS', '');
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS', '');
}
});
}
exports.setup = setup;
function maybeExportVariable(variableName, value) {
if (!process.env[variableName]) {
core.exportVariable(variableName, value);
}
}
function complete(config) {
return __awaiter(this, void 0, void 0, function* () {
const option = config.getDependencyGraphOption();
try {
switch (option) {
case input_params_1.DependencyGraphOption.Disabled:
case input_params_1.DependencyGraphOption.Generate:
case input_params_1.DependencyGraphOption.DownloadAndSubmit:
return;
case input_params_1.DependencyGraphOption.GenerateAndSubmit:
case input_params_1.DependencyGraphOption.Clear:
yield submitDependencyGraphs(yield findGeneratedDependencyGraphFiles());
return;
case input_params_1.DependencyGraphOption.GenerateAndUpload:
yield uploadDependencyGraphs(yield findGeneratedDependencyGraphFiles(), config);
}
}
catch (e) {
warnOrFail(config, option, e);
}
});
}
exports.complete = complete;
function findGeneratedDependencyGraphFiles() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
return yield findDependencyGraphFiles(workspaceDirectory);
});
}
function uploadDependencyGraphs(dependencyGraphFiles, config) {
return __awaiter(this, void 0, void 0, function* () {
if (isRunningInActEnvironment()) {
core.info('Dependency graph upload not supported in the ACT environment.');
core.info(`Would upload: ${dependencyGraphFiles.join(', ')}`);
return;
}
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const artifactClient = new artifact_1.DefaultArtifactClient();
for (const dependencyGraphFile of dependencyGraphFiles) {
const relativePath = getRelativePathFromWorkspace(dependencyGraphFile);
core.info(`Uploading dependency graph file: ${relativePath}`);
const artifactName = `${DEPENDENCY_GRAPH_PREFIX}${path.basename(dependencyGraphFile)}`;
yield artifactClient.uploadArtifact(artifactName, [dependencyGraphFile], workspaceDirectory, {
retentionDays: config.getArtifactRetentionDays()
});
}
});
}
function downloadAndSubmitDependencyGraphs(config) {
return __awaiter(this, void 0, void 0, function* () {
if (isRunningInActEnvironment()) {
core.info('Dependency graph download and submit not supported in the ACT environment.');
return;
}
try {
yield submitDependencyGraphs(yield downloadDependencyGraphs());
}
catch (e) {
warnOrFail(config, input_params_1.DependencyGraphOption.DownloadAndSubmit, e);
}
});
}
function submitDependencyGraphs(dependencyGraphFiles) {
return __awaiter(this, void 0, void 0, function* () {
if (isRunningInActEnvironment()) {
core.info('Dependency graph submit not supported in the ACT environment.');
core.info(`Would submit: ${dependencyGraphFiles.join(', ')}`);
return;
}
for (const dependencyGraphFile of dependencyGraphFiles) {
try {
yield submitDependencyGraphFile(dependencyGraphFile);
}
catch (error) {
if (error instanceof request_error_1.RequestError) {
throw new Error(translateErrorMessage(dependencyGraphFile, error));
}
else {
throw error;
}
}
}
});
}
function translateErrorMessage(jsonFile, error) {
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${String(error)}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'contents: write' permission is available for the workflow job.
Note that this permission is never available for a 'pull_request' trigger from a repository fork.
`;
}
return mainWarning;
}
function submitDependencyGraphFile(jsonFile) {
return __awaiter(this, void 0, void 0, function* () {
const octokit = getOctokit();
const jsonContent = fs_1.default.readFileSync(jsonFile, 'utf8');
const jsonObject = JSON.parse(jsonContent);
jsonObject.owner = github.context.repo.owner;
jsonObject.repo = github.context.repo.repo;
const response = yield octokit.request('POST /repos/{owner}/{repo}/dependency-graph/snapshots', jsonObject);
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
core.notice(`Submitted ${relativeJsonFile}: ${response.data.message}`);
});
}
function downloadDependencyGraphs() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const findBy = github.context.payload.workflow_run
? {
token: (0, input_params_1.getGithubToken)(),
workflowRunId: github.context.payload.workflow_run.id,
repositoryName: github.context.repo.repo,
repositoryOwner: github.context.repo.owner
}
: undefined;
const artifactClient = new artifact_1.DefaultArtifactClient();
const downloadPath = path.resolve(workspaceDirectory, 'dependency-graph');
const dependencyGraphArtifacts = (yield artifactClient.listArtifacts({
latest: true,
findBy
})).artifacts.filter(candidate => candidate.name.startsWith(DEPENDENCY_GRAPH_PREFIX));
for (const artifact of dependencyGraphArtifacts) {
const downloadedArtifact = yield artifactClient.downloadArtifact(artifact.id, {
path: downloadPath,
findBy
});
core.info(`Downloading dependency-graph artifact ${artifact.name} to ${downloadedArtifact.downloadPath}`);
}
return findDependencyGraphFiles(downloadPath);
});
}
function findDependencyGraphFiles(dir) {
return __awaiter(this, void 0, void 0, function* () {
const globber = yield glob.create(`${dir}/dependency-graph-reports/*.json`);
const allFiles = yield globber.glob();
const unprocessedFiles = allFiles.filter(file => !isProcessed(file));
unprocessedFiles.forEach(markProcessed);
return unprocessedFiles;
});
}
function isProcessed(dependencyGraphFile) {
const markerFile = `${dependencyGraphFile}.processed`;
return fs_1.default.existsSync(markerFile);
}
function markProcessed(dependencyGraphFile) {
const markerFile = `${dependencyGraphFile}.processed`;
fs_1.default.writeFileSync(markerFile, '');
}
function warnOrFail(config, option, error) {
if (!config.getDependencyGraphContinueOnFailure()) {
throw new errors_1.PostActionJobFailure(error);
}
core.warning(`Failed to ${option} dependency graph. Will continue.\n${String(error)}`);
}
function getOctokit() {
return github.getOctokit((0, input_params_1.getGithubToken)());
}
function getRelativePathFromWorkspace(file) {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
return path.relative(workspaceDirectory, file);
}
function getShaFromContext() {
const context = github.context;
const pullRequestEvents = [
'pull_request',
'pull_request_comment',
'pull_request_review',
'pull_request_review_comment'
];
if (pullRequestEvents.includes(context.eventName)) {
const pr = context.payload.pull_request;
return pr.head.sha;
}
else {
return context.sha;
}
}
function isRunningInActEnvironment() {
return process.env.ACT !== undefined;
}
/***/ }),
/***/ 36976:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PostActionJobFailure = void 0;
class PostActionJobFailure extends Error {
constructor(error) {
if (error instanceof Error) {
super(error.message);
this.name = error.name;
this.stack = error.stack;
}
else {
super(String(error));
}
}
}
exports.PostActionJobFailure = PostActionJobFailure;
/***/ }),
/***/ 23885:
/***/ 15778:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
@@ -138956,13 +138588,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.GradleExecutionConfig = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
exports.parseNumericInput = exports.setActionId = exports.getActionId = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.GradleExecutionConfig = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const cache = __importStar(__nccwpck_require__(27799));
const deprecator = __importStar(__nccwpck_require__(22572));
const summary_1 = __nccwpck_require__(81327);
const string_argv_1 = __nccwpck_require__(19663);
const path_1 = __importDefault(__nccwpck_require__(71017));
const ACTION_ID_VAR = 'GRADLE_ACTION_ID';
class DependencyGraphConfig {
getDependencyGraphOption() {
const val = core.getInput('dependency-graph');
@@ -139131,6 +138765,11 @@ class BuildScanConfig {
if (newProp !== '') {
return newProp;
}
const oldProp = core.getInput(oldPropName);
if (oldProp !== '') {
deprecator.recordDeprecation('The `build-scan-terms-of-service` input parameters have been renamed');
return oldProp;
}
return core.getInput(oldPropName);
}
}
@@ -139149,6 +138788,9 @@ class GradleExecutionConfig {
}
getArguments() {
const input = core.getInput('arguments');
if (input.length !== 0) {
deprecator.recordDeprecation('Using the action to execute Gradle via the `arguments` parameter is deprecated');
}
return (0, string_argv_1.parseArgsStringToArgv)(input);
}
getDependencyResolutionTask() {
@@ -139171,6 +138813,14 @@ function getWorkspaceDirectory() {
return process.env[`GITHUB_WORKSPACE`] || '';
}
exports.getWorkspaceDirectory = getWorkspaceDirectory;
function getActionId() {
return process.env[ACTION_ID_VAR];
}
exports.getActionId = getActionId;
function setActionId(id) {
core.exportVariable(ACTION_ID_VAR, id);
}
exports.setActionId = setActionId;
function parseNumericInput(paramName, paramValue, paramDefault) {
if (paramValue.length === 0) {
return paramDefault;
@@ -139196,6 +138846,458 @@ function getBooleanInput(paramName, paramDefault = false) {
}
/***/ }),
/***/ 85146:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DaemonController = void 0;
const core = __importStar(__nccwpck_require__(42186));
const exec = __importStar(__nccwpck_require__(71514));
const fs = __importStar(__nccwpck_require__(57147));
const path = __importStar(__nccwpck_require__(71017));
class DaemonController {
constructor(buildResults) {
const allHomes = buildResults.map(buildResult => buildResult.gradleHomeDir);
this.gradleHomes = Array.from(new Set(allHomes));
}
stopAllDaemons() {
return __awaiter(this, void 0, void 0, function* () {
core.info('Stopping all Gradle daemons before saving Gradle User Home state');
const executions = [];
const args = ['--stop'];
for (const gradleHome of this.gradleHomes) {
const executable = path.resolve(gradleHome, 'bin', 'gradle');
if (!fs.existsSync(executable)) {
core.warning(`Gradle executable not found at ${executable}. Could not stop Gradle daemons.`);
continue;
}
core.info(`Stopping Gradle daemons for ${gradleHome}`);
executions.push(exec.exec(executable, args, {
ignoreReturnCode: true
}));
}
yield Promise.all(executions);
});
}
}
exports.DaemonController = DaemonController;
/***/ }),
/***/ 80:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.complete = exports.setup = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const glob = __importStar(__nccwpck_require__(28090));
const artifact_1 = __nccwpck_require__(79450);
const request_error_1 = __nccwpck_require__(10537);
const path = __importStar(__nccwpck_require__(71017));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const errors_1 = __nccwpck_require__(36976);
const configuration_1 = __nccwpck_require__(15778);
const DEPENDENCY_GRAPH_PREFIX = 'dependency-graph_';
function setup(config) {
return __awaiter(this, void 0, void 0, function* () {
const option = config.getDependencyGraphOption();
if (option === configuration_1.DependencyGraphOption.Disabled) {
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'false');
return;
}
if (option === configuration_1.DependencyGraphOption.DownloadAndSubmit) {
yield downloadAndSubmitDependencyGraphs(config);
return;
}
core.info('Enabling dependency graph generation');
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'true');
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_CONTINUE_ON_FAILURE', config.getDependencyGraphContinueOnFailure());
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR', config.getJobCorrelator());
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId);
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_REF', github.context.ref);
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_SHA', getShaFromContext());
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_WORKSPACE', (0, configuration_1.getWorkspaceDirectory)());
maybeExportVariable('DEPENDENCY_GRAPH_REPORT_DIR', path.resolve((0, configuration_1.getWorkspaceDirectory)(), 'dependency-graph-reports'));
if (option === configuration_1.DependencyGraphOption.Clear) {
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_PROJECTS', '');
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS', '');
}
});
}
exports.setup = setup;
function maybeExportVariable(variableName, value) {
if (!process.env[variableName]) {
core.exportVariable(variableName, value);
}
}
function complete(config) {
return __awaiter(this, void 0, void 0, function* () {
const option = config.getDependencyGraphOption();
try {
switch (option) {
case configuration_1.DependencyGraphOption.Disabled:
case configuration_1.DependencyGraphOption.Generate:
case configuration_1.DependencyGraphOption.DownloadAndSubmit:
return;
case configuration_1.DependencyGraphOption.GenerateAndSubmit:
case configuration_1.DependencyGraphOption.Clear:
yield submitDependencyGraphs(yield findGeneratedDependencyGraphFiles());
return;
case configuration_1.DependencyGraphOption.GenerateAndUpload:
yield uploadDependencyGraphs(yield findGeneratedDependencyGraphFiles(), config);
}
}
catch (e) {
warnOrFail(config, option, e);
}
});
}
exports.complete = complete;
function findGeneratedDependencyGraphFiles() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
return yield findDependencyGraphFiles(workspaceDirectory);
});
}
function uploadDependencyGraphs(dependencyGraphFiles, config) {
return __awaiter(this, void 0, void 0, function* () {
if (isRunningInActEnvironment()) {
core.info('Dependency graph upload not supported in the ACT environment.');
core.info(`Would upload: ${dependencyGraphFiles.join(', ')}`);
return;
}
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
const artifactClient = new artifact_1.DefaultArtifactClient();
for (const dependencyGraphFile of dependencyGraphFiles) {
const relativePath = getRelativePathFromWorkspace(dependencyGraphFile);
core.info(`Uploading dependency graph file: ${relativePath}`);
const artifactName = `${DEPENDENCY_GRAPH_PREFIX}${path.basename(dependencyGraphFile)}`;
yield artifactClient.uploadArtifact(artifactName, [dependencyGraphFile], workspaceDirectory, {
retentionDays: config.getArtifactRetentionDays()
});
}
});
}
function downloadAndSubmitDependencyGraphs(config) {
return __awaiter(this, void 0, void 0, function* () {
if (isRunningInActEnvironment()) {
core.info('Dependency graph download and submit not supported in the ACT environment.');
return;
}
try {
yield submitDependencyGraphs(yield downloadDependencyGraphs());
}
catch (e) {
warnOrFail(config, configuration_1.DependencyGraphOption.DownloadAndSubmit, e);
}
});
}
function submitDependencyGraphs(dependencyGraphFiles) {
return __awaiter(this, void 0, void 0, function* () {
if (isRunningInActEnvironment()) {
core.info('Dependency graph submit not supported in the ACT environment.');
core.info(`Would submit: ${dependencyGraphFiles.join(', ')}`);
return;
}
for (const dependencyGraphFile of dependencyGraphFiles) {
try {
yield submitDependencyGraphFile(dependencyGraphFile);
}
catch (error) {
if (error instanceof request_error_1.RequestError) {
throw new Error(translateErrorMessage(dependencyGraphFile, error));
}
else {
throw error;
}
}
}
});
}
function translateErrorMessage(jsonFile, error) {
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${String(error)}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'contents: write' permission is available for the workflow job.
Note that this permission is never available for a 'pull_request' trigger from a repository fork.
`;
}
return mainWarning;
}
function submitDependencyGraphFile(jsonFile) {
return __awaiter(this, void 0, void 0, function* () {
const octokit = getOctokit();
const jsonContent = fs_1.default.readFileSync(jsonFile, 'utf8');
const jsonObject = JSON.parse(jsonContent);
jsonObject.owner = github.context.repo.owner;
jsonObject.repo = github.context.repo.repo;
const response = yield octokit.request('POST /repos/{owner}/{repo}/dependency-graph/snapshots', jsonObject);
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
core.notice(`Submitted ${relativeJsonFile}: ${response.data.message}`);
});
}
function downloadDependencyGraphs() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
const findBy = github.context.payload.workflow_run
? {
token: (0, configuration_1.getGithubToken)(),
workflowRunId: github.context.payload.workflow_run.id,
repositoryName: github.context.repo.repo,
repositoryOwner: github.context.repo.owner
}
: undefined;
const artifactClient = new artifact_1.DefaultArtifactClient();
const downloadPath = path.resolve(workspaceDirectory, 'dependency-graph');
const dependencyGraphArtifacts = (yield artifactClient.listArtifacts({
latest: true,
findBy
})).artifacts.filter(candidate => candidate.name.startsWith(DEPENDENCY_GRAPH_PREFIX));
for (const artifact of dependencyGraphArtifacts) {
const downloadedArtifact = yield artifactClient.downloadArtifact(artifact.id, {
path: downloadPath,
findBy
});
core.info(`Downloading dependency-graph artifact ${artifact.name} to ${downloadedArtifact.downloadPath}`);
}
return findDependencyGraphFiles(downloadPath);
});
}
function findDependencyGraphFiles(dir) {
return __awaiter(this, void 0, void 0, function* () {
const globber = yield glob.create(`${dir}/dependency-graph-reports/*.json`);
const allFiles = yield globber.glob();
const unprocessedFiles = allFiles.filter(file => !isProcessed(file));
unprocessedFiles.forEach(markProcessed);
return unprocessedFiles;
});
}
function isProcessed(dependencyGraphFile) {
const markerFile = `${dependencyGraphFile}.processed`;
return fs_1.default.existsSync(markerFile);
}
function markProcessed(dependencyGraphFile) {
const markerFile = `${dependencyGraphFile}.processed`;
fs_1.default.writeFileSync(markerFile, '');
}
function warnOrFail(config, option, error) {
if (!config.getDependencyGraphContinueOnFailure()) {
throw new errors_1.PostActionJobFailure(error);
}
core.warning(`Failed to ${option} dependency graph. Will continue.\n${String(error)}`);
}
function getOctokit() {
return github.getOctokit((0, configuration_1.getGithubToken)());
}
function getRelativePathFromWorkspace(file) {
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
return path.relative(workspaceDirectory, file);
}
function getShaFromContext() {
const context = github.context;
const pullRequestEvents = [
'pull_request',
'pull_request_comment',
'pull_request_review',
'pull_request_review_comment'
];
if (pullRequestEvents.includes(context.eventName)) {
const pr = context.payload.pull_request;
return pr.head.sha;
}
else {
return context.sha;
}
}
function isRunningInActEnvironment() {
return process.env.ACT !== undefined;
}
/***/ }),
/***/ 22572:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.restoreDeprecationState = exports.saveDeprecationState = exports.emitDeprecationWarnings = exports.getDeprecations = exports.recordDeprecation = exports.Deprecation = void 0;
const core = __importStar(__nccwpck_require__(42186));
const configuration_1 = __nccwpck_require__(15778);
const DEPRECATION_UPGRADE_PAGE = 'https://github.com/gradle/actions/blob/main/docs/deprecation-upgrade-guide.md';
const recordedDeprecations = [];
class Deprecation {
constructor(message) {
this.message = message;
}
getDocumentationLink() {
const deprecationAnchor = this.message
.toLowerCase()
.replace(/[^\w\s-]|_/g, '')
.replace(/ /g, '-');
return `${DEPRECATION_UPGRADE_PAGE}#${deprecationAnchor}`;
}
}
exports.Deprecation = Deprecation;
function recordDeprecation(message) {
if (!recordedDeprecations.some(deprecation => deprecation.message === message)) {
recordedDeprecations.push(new Deprecation(message));
}
}
exports.recordDeprecation = recordDeprecation;
function getDeprecations() {
return recordedDeprecations;
}
exports.getDeprecations = getDeprecations;
function emitDeprecationWarnings() {
if (recordedDeprecations.length > 0) {
core.warning(`This job uses deprecated functionality from the '${(0, configuration_1.getActionId)()}' action. Consult the Job Summary for more details.`);
for (const deprecation of recordedDeprecations) {
core.info(`DEPRECATION: ${deprecation.message}. See ${deprecation.getDocumentationLink()}`);
}
}
}
exports.emitDeprecationWarnings = emitDeprecationWarnings;
function saveDeprecationState() {
core.saveState('deprecations', JSON.stringify(recordedDeprecations));
}
exports.saveDeprecationState = saveDeprecationState;
function restoreDeprecationState() {
const stringRep = core.getState('deprecations');
if (stringRep === '') {
return;
}
JSON.parse(stringRep).forEach((obj) => {
recordedDeprecations.push(new Deprecation(obj.message));
});
}
exports.restoreDeprecationState = restoreDeprecationState;
/***/ }),
/***/ 36976:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PostActionJobFailure = void 0;
class PostActionJobFailure extends Error {
constructor(error) {
if (error instanceof Error) {
super(error.message);
this.name = error.name;
this.stack = error.stack;
}
else {
super(String(error));
}
}
}
exports.PostActionJobFailure = PostActionJobFailure;
/***/ }),
/***/ 87345:
@@ -139240,7 +139342,8 @@ exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const request_error_1 = __nccwpck_require__(10537);
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const deprecation_collector_1 = __nccwpck_require__(22572);
function generateJobSummary(buildResults, cachingReport, config) {
return __awaiter(this, void 0, void 0, function* () {
const summaryTable = renderSummaryTable(buildResults);
@@ -139279,7 +139382,7 @@ function addPRComment(jobSummary) {
</a>
${jobSummary}`;
const github_token = (0, input_params_1.getGithubToken)();
const github_token = (0, configuration_1.getGithubToken)();
const octokit = github.getOctokit(github_token);
try {
yield octokit.rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: pull_request_number, body: prComment }));
@@ -139305,8 +139408,28 @@ Note that this permission is never available for a workflow triggered from a rep
return mainWarning;
}
function renderSummaryTable(results) {
return `${renderDeprecations()}\n${renderBuildResults(results)}`;
}
function renderDeprecations() {
const deprecations = (0, deprecation_collector_1.getDeprecations)();
if (deprecations.length === 0) {
return '';
}
return `
<h4>Deprecation warnings</h4>
This job uses deprecated functionality from the <code>${(0, configuration_1.getActionId)()}</code> action. Follow the links for upgrade details.
<ul>
${deprecations.map(deprecation => `<li>${getDeprecationHtml(deprecation)}</li>`).join('')}
</ul>
<h4>Gradle Build Results</h4>`;
}
function getDeprecationHtml(deprecation) {
return `<a href="${deprecation.getDocumentationLink()}" target="_blank">${deprecation.message}</a>`;
}
function renderBuildResults(results) {
if (results.length === 0) {
return 'No Gradle build results detected.';
return '<b>No Gradle build results detected.</b>';
}
return `
<table>
@@ -139408,7 +139531,7 @@ const buildScan = __importStar(__nccwpck_require__(85772));
const build_results_1 = __nccwpck_require__(82107);
const cache_reporting_1 = __nccwpck_require__(7391);
const daemon_controller_1 = __nccwpck_require__(85146);
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
const USER_HOME = 'USER_HOME';
const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
@@ -139458,7 +139581,7 @@ function determineGradleUserHome() {
return __awaiter(this, void 0, void 0, function* () {
const customGradleUserHome = process.env['GRADLE_USER_HOME'];
if (customGradleUserHome) {
const rootDir = (0, input_params_1.getWorkspaceDirectory)();
const rootDir = (0, configuration_1.getWorkspaceDirectory)();
return path.resolve(rootDir, customGradleUserHome);
}
return path.resolve(yield determineUserHome(), '.gradle');
@@ -139524,14 +139647,17 @@ exports.run = void 0;
const core = __importStar(__nccwpck_require__(42186));
const setupGradle = __importStar(__nccwpck_require__(18652));
const dependencyGraph = __importStar(__nccwpck_require__(80));
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const errors_1 = __nccwpck_require__(36976);
const deprecation_collector_1 = __nccwpck_require__(22572);
process.on('uncaughtException', e => handleFailure(e));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
if (yield setupGradle.complete(new input_params_1.CacheConfig(), new input_params_1.SummaryConfig())) {
yield dependencyGraph.complete(new input_params_1.DependencyGraphConfig());
(0, deprecation_collector_1.restoreDeprecationState)();
(0, deprecation_collector_1.emitDeprecationWarnings)();
if (yield setupGradle.complete(new configuration_1.CacheConfig(), new configuration_1.SummaryConfig())) {
yield dependencyGraph.complete(new configuration_1.DependencyGraphConfig());
}
}
catch (error) {

File diff suppressed because one or more lines are too long