Emit warnings when using deprecated inputs / actions (#139)

Fixes #108
This commit is contained in:
Daz DeBoer 2024-04-09 15:51:21 -06:00 committed by GitHub
commit 1824c01ad8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 1931 additions and 1193 deletions

View file

@ -139922,7 +139922,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';
@ -139967,7 +139967,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() {
@ -141101,6 +141101,298 @@ class GradleUserHomeCache {
exports.GradleUserHomeCache = GradleUserHomeCache;
/***/ }),
/***/ 15778:
/***/ (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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
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');
switch (val.toLowerCase().trim()) {
case 'disabled':
return DependencyGraphOption.Disabled;
case 'generate':
return DependencyGraphOption.Generate;
case 'generate-and-submit':
return DependencyGraphOption.GenerateAndSubmit;
case 'generate-and-upload':
return DependencyGraphOption.GenerateAndUpload;
case 'download-and-submit':
return DependencyGraphOption.DownloadAndSubmit;
case 'clear':
return DependencyGraphOption.Clear;
}
throw TypeError(`The value '${val}' is not valid for 'dependency-graph'. Valid values are: [disabled, generate, generate-and-submit, generate-and-upload, download-and-submit, clear]. The default value is 'disabled'.`);
}
getDependencyGraphContinueOnFailure() {
return getBooleanInput('dependency-graph-continue-on-failure', true);
}
getArtifactRetentionDays() {
const val = core.getInput('artifact-retention-days');
return parseNumericInput('artifact-retention-days', val, 0);
}
getJobCorrelator() {
return DependencyGraphConfig.constructJobCorrelator(github.context.workflow, github.context.job, getJobMatrix());
}
static constructJobCorrelator(workflow, jobId, matrixJson) {
const matrixString = this.describeMatrix(matrixJson);
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`;
return this.sanitize(label);
}
static describeMatrix(matrixJson) {
core.debug(`Got matrix json: ${matrixJson}`);
const matrix = JSON.parse(matrixJson);
if (matrix) {
return Object.values(matrix).join('-');
}
return '';
}
static sanitize(value) {
return value
.replace(/[^a-zA-Z0-9_-\s]/g, '')
.replace(/\s+/g, '_')
.toLowerCase();
}
}
exports.DependencyGraphConfig = DependencyGraphConfig;
var DependencyGraphOption;
(function (DependencyGraphOption) {
DependencyGraphOption["Disabled"] = "disabled";
DependencyGraphOption["Generate"] = "generate";
DependencyGraphOption["GenerateAndSubmit"] = "generate-and-submit";
DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload";
DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit";
DependencyGraphOption["Clear"] = "clear";
})(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {}));
class CacheConfig {
isCacheDisabled() {
if (!cache.isFeatureAvailable()) {
return true;
}
return getBooleanInput('cache-disabled');
}
isCacheReadOnly() {
return !this.isCacheWriteOnly() && getBooleanInput('cache-read-only');
}
isCacheWriteOnly() {
return getBooleanInput('cache-write-only');
}
isCacheOverwriteExisting() {
return getBooleanInput('cache-overwrite-existing');
}
isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match');
}
isCacheCleanupEnabled() {
return getBooleanInput('gradle-home-cache-cleanup') && !this.isCacheReadOnly();
}
getCacheEncryptionKey() {
return core.getInput('cache-encryption-key');
}
getCacheIncludes() {
return core.getMultilineInput('gradle-home-cache-includes');
}
getCacheExcludes() {
return core.getMultilineInput('gradle-home-cache-excludes');
}
}
exports.CacheConfig = CacheConfig;
class SummaryConfig {
shouldGenerateJobSummary(hasFailure) {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
if (!this.isJobSummaryEnabled()) {
return false;
}
return this.shouldAddJobSummary(this.getJobSummaryOption(), hasFailure);
}
shouldAddPRComment(hasFailure) {
return this.shouldAddJobSummary(this.getPRCommentOption(), hasFailure);
}
shouldAddJobSummary(option, hasFailure) {
switch (option) {
case JobSummaryOption.Always:
return true;
case JobSummaryOption.Never:
return false;
case JobSummaryOption.OnFailure:
return hasFailure;
}
}
isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true);
}
getJobSummaryOption() {
return this.parseJobSummaryOption('add-job-summary');
}
getPRCommentOption() {
return this.parseJobSummaryOption('add-job-summary-as-pr-comment');
}
parseJobSummaryOption(paramName) {
const val = core.getInput(paramName);
switch (val.toLowerCase().trim()) {
case 'never':
return JobSummaryOption.Never;
case 'always':
return JobSummaryOption.Always;
case 'on-failure':
return JobSummaryOption.OnFailure;
}
throw TypeError(`The value '${val}' is not valid for ${paramName}. Valid values are: [never, always, on-failure].`);
}
}
exports.SummaryConfig = SummaryConfig;
var JobSummaryOption;
(function (JobSummaryOption) {
JobSummaryOption["Never"] = "never";
JobSummaryOption["Always"] = "always";
JobSummaryOption["OnFailure"] = "on-failure";
})(JobSummaryOption || (exports.JobSummaryOption = JobSummaryOption = {}));
class BuildScanConfig {
getBuildScanPublishEnabled() {
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement();
}
getBuildScanTermsOfUseUrl() {
return this.getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url');
}
getBuildScanTermsOfUseAgree() {
return this.getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree');
}
verifyTermsOfUseAgreement() {
if ((this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/terms-of-service' &&
this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/help/legal-terms-of-use') ||
this.getBuildScanTermsOfUseAgree() !== 'yes') {
core.warning(`Terms of use at 'https://gradle.com/help/legal-terms-of-use' must be agreed in order to publish build scans.`);
return false;
}
return true;
}
getTermsOfUseProp(newPropName, oldPropName) {
const newProp = core.getInput(newPropName);
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);
}
}
exports.BuildScanConfig = BuildScanConfig;
class GradleExecutionConfig {
getGradleVersion() {
return core.getInput('gradle-version');
}
getBuildRootDirectory() {
const baseDirectory = getWorkspaceDirectory();
const buildRootDirectoryInput = core.getInput('build-root-directory');
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
? path_1.default.resolve(baseDirectory)
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
return resolvedBuildRootDirectory;
}
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() {
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
}
getAdditionalArguments() {
return core.getInput('additional-arguments');
}
}
exports.GradleExecutionConfig = GradleExecutionConfig;
function getJobMatrix() {
return core.getInput('workflow-job-context');
}
exports.getJobMatrix = getJobMatrix;
function getGithubToken() {
return core.getInput('github-token', { required: true });
}
exports.getGithubToken = getGithubToken;
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;
}
const numericValue = parseInt(paramValue);
if (isNaN(numericValue)) {
throw TypeError(`The value '${paramValue}' is not a valid numeric value for '${paramName}'.`);
}
return numericValue;
}
exports.parseNumericInput = parseNumericInput;
function getBooleanInput(paramName, paramDefault = false) {
const paramValue = core.getInput(paramName);
switch (paramValue.toLowerCase().trim()) {
case '':
return paramDefault;
case 'false':
return false;
case 'true':
return true;
}
throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`);
}
/***/ }),
/***/ 85146:
@ -141226,16 +141518,16 @@ 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 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 === input_params_1.DependencyGraphOption.Disabled) {
if (option === configuration_1.DependencyGraphOption.Disabled) {
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'false');
return;
}
if (option === input_params_1.DependencyGraphOption.DownloadAndSubmit) {
if (option === configuration_1.DependencyGraphOption.DownloadAndSubmit) {
yield downloadAndSubmitDependencyGraphs(config);
return;
}
@ -141246,9 +141538,9 @@ function setup(config) {
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) {
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', '');
}
@ -141265,15 +141557,15 @@ function complete(config) {
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:
case configuration_1.DependencyGraphOption.Disabled:
case configuration_1.DependencyGraphOption.Generate:
case configuration_1.DependencyGraphOption.DownloadAndSubmit:
return;
case input_params_1.DependencyGraphOption.GenerateAndSubmit:
case input_params_1.DependencyGraphOption.Clear:
case configuration_1.DependencyGraphOption.GenerateAndSubmit:
case configuration_1.DependencyGraphOption.Clear:
yield submitDependencyGraphs(yield findGeneratedDependencyGraphFiles());
return;
case input_params_1.DependencyGraphOption.GenerateAndUpload:
case configuration_1.DependencyGraphOption.GenerateAndUpload:
yield uploadDependencyGraphs(yield findGeneratedDependencyGraphFiles(), config);
}
}
@ -141285,7 +141577,7 @@ function complete(config) {
exports.complete = complete;
function findGeneratedDependencyGraphFiles() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
return yield findDependencyGraphFiles(workspaceDirectory);
});
}
@ -141296,7 +141588,7 @@ function uploadDependencyGraphs(dependencyGraphFiles, config) {
core.info(`Would upload: ${dependencyGraphFiles.join(', ')}`);
return;
}
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
const artifactClient = new artifact_1.DefaultArtifactClient();
for (const dependencyGraphFile of dependencyGraphFiles) {
const relativePath = getRelativePathFromWorkspace(dependencyGraphFile);
@ -141318,7 +141610,7 @@ function downloadAndSubmitDependencyGraphs(config) {
yield submitDependencyGraphs(yield downloadDependencyGraphs());
}
catch (e) {
warnOrFail(config, input_params_1.DependencyGraphOption.DownloadAndSubmit, e);
warnOrFail(config, configuration_1.DependencyGraphOption.DownloadAndSubmit, e);
}
});
}
@ -141369,10 +141661,10 @@ function submitDependencyGraphFile(jsonFile) {
}
function downloadDependencyGraphs() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
const findBy = github.context.payload.workflow_run
? {
token: (0, input_params_1.getGithubToken)(),
token: (0, configuration_1.getGithubToken)(),
workflowRunId: github.context.payload.workflow_run.id,
repositoryName: github.context.repo.repo,
repositoryOwner: github.context.repo.owner
@ -141418,10 +141710,10 @@ function warnOrFail(config, option, error) {
core.warning(`Failed to ${option} dependency graph. Will continue.\n${String(error)}`);
}
function getOctokit() {
return github.getOctokit((0, input_params_1.getGithubToken)());
return github.getOctokit((0, configuration_1.getGithubToken)());
}
function getRelativePathFromWorkspace(file) {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
return path.relative(workspaceDirectory, file);
}
function getShaFromContext() {
@ -141491,17 +141783,19 @@ const setupGradle = __importStar(__nccwpck_require__(18652));
const gradle = __importStar(__nccwpck_require__(94475));
const dependencyGraph = __importStar(__nccwpck_require__(80));
const string_argv_1 = __nccwpck_require__(19663);
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const deprecation_collector_1 = __nccwpck_require__(22572);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield setupGradle.setup(new input_params_1.CacheConfig(), new input_params_1.BuildScanConfig());
const config = new input_params_1.DependencyGraphConfig();
(0, configuration_1.setActionId)('gradle/actions/dependency-submission');
yield setupGradle.setup(new configuration_1.CacheConfig(), new configuration_1.BuildScanConfig());
const config = new configuration_1.DependencyGraphConfig();
yield dependencyGraph.setup(config);
if (config.getDependencyGraphOption() === input_params_1.DependencyGraphOption.DownloadAndSubmit) {
if (config.getDependencyGraphOption() === configuration_1.DependencyGraphOption.DownloadAndSubmit) {
return;
}
const executionConfig = new input_params_1.GradleExecutionConfig();
const executionConfig = new configuration_1.GradleExecutionConfig();
const taskList = executionConfig.getDependencyResolutionTask();
const additionalArgs = executionConfig.getAdditionalArguments();
const executionArgs = `
@ -141514,6 +141808,7 @@ function run() {
const args = (0, string_argv_1.parseArgsStringToArgv)(executionArgs);
yield gradle.provisionAndMaybeExecute(executionConfig.getGradleVersion(), executionConfig.getBuildRootDirectory(), args);
yield dependencyGraph.complete(config);
(0, deprecation_collector_1.saveDeprecationState)();
}
catch (error) {
core.setFailed(String(error));
@ -141528,6 +141823,90 @@ exports.run = run;
run();
/***/ }),
/***/ 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:
@ -141745,7 +142124,7 @@ const cache = __importStar(__nccwpck_require__(27799));
const toolCache = __importStar(__nccwpck_require__(27784));
const gradlew = __importStar(__nccwpck_require__(46807));
const cache_utils_1 = __nccwpck_require__(11044);
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions';
function provisionGradle(gradleVersion) {
return __awaiter(this, void 0, void 0, function* () {
@ -141862,7 +142241,7 @@ function locateGradleAndDownloadIfRequired(versionInfo) {
function downloadAndCacheGradleDistribution(versionInfo) {
return __awaiter(this, void 0, void 0, function* () {
const downloadPath = path.join(os.homedir(), `gradle-installations/downloads/gradle-${versionInfo.version}-bin.zip`);
const cacheConfig = new input_params_1.CacheConfig();
const cacheConfig = new configuration_1.CacheConfig();
if (cacheConfig.isCacheDisabled()) {
yield downloadGradleDistribution(versionInfo, downloadPath);
return downloadPath;
@ -141919,280 +142298,6 @@ function httpGetString(url) {
}
/***/ }),
/***/ 23885:
/***/ (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 __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;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const cache = __importStar(__nccwpck_require__(27799));
const summary_1 = __nccwpck_require__(81327);
const string_argv_1 = __nccwpck_require__(19663);
const path_1 = __importDefault(__nccwpck_require__(71017));
class DependencyGraphConfig {
getDependencyGraphOption() {
const val = core.getInput('dependency-graph');
switch (val.toLowerCase().trim()) {
case 'disabled':
return DependencyGraphOption.Disabled;
case 'generate':
return DependencyGraphOption.Generate;
case 'generate-and-submit':
return DependencyGraphOption.GenerateAndSubmit;
case 'generate-and-upload':
return DependencyGraphOption.GenerateAndUpload;
case 'download-and-submit':
return DependencyGraphOption.DownloadAndSubmit;
case 'clear':
return DependencyGraphOption.Clear;
}
throw TypeError(`The value '${val}' is not valid for 'dependency-graph'. Valid values are: [disabled, generate, generate-and-submit, generate-and-upload, download-and-submit, clear]. The default value is 'disabled'.`);
}
getDependencyGraphContinueOnFailure() {
return getBooleanInput('dependency-graph-continue-on-failure', true);
}
getArtifactRetentionDays() {
const val = core.getInput('artifact-retention-days');
return parseNumericInput('artifact-retention-days', val, 0);
}
getJobCorrelator() {
return DependencyGraphConfig.constructJobCorrelator(github.context.workflow, github.context.job, getJobMatrix());
}
static constructJobCorrelator(workflow, jobId, matrixJson) {
const matrixString = this.describeMatrix(matrixJson);
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`;
return this.sanitize(label);
}
static describeMatrix(matrixJson) {
core.debug(`Got matrix json: ${matrixJson}`);
const matrix = JSON.parse(matrixJson);
if (matrix) {
return Object.values(matrix).join('-');
}
return '';
}
static sanitize(value) {
return value
.replace(/[^a-zA-Z0-9_-\s]/g, '')
.replace(/\s+/g, '_')
.toLowerCase();
}
}
exports.DependencyGraphConfig = DependencyGraphConfig;
var DependencyGraphOption;
(function (DependencyGraphOption) {
DependencyGraphOption["Disabled"] = "disabled";
DependencyGraphOption["Generate"] = "generate";
DependencyGraphOption["GenerateAndSubmit"] = "generate-and-submit";
DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload";
DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit";
DependencyGraphOption["Clear"] = "clear";
})(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {}));
class CacheConfig {
isCacheDisabled() {
if (!cache.isFeatureAvailable()) {
return true;
}
return getBooleanInput('cache-disabled');
}
isCacheReadOnly() {
return !this.isCacheWriteOnly() && getBooleanInput('cache-read-only');
}
isCacheWriteOnly() {
return getBooleanInput('cache-write-only');
}
isCacheOverwriteExisting() {
return getBooleanInput('cache-overwrite-existing');
}
isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match');
}
isCacheCleanupEnabled() {
return getBooleanInput('gradle-home-cache-cleanup') && !this.isCacheReadOnly();
}
getCacheEncryptionKey() {
return core.getInput('cache-encryption-key');
}
getCacheIncludes() {
return core.getMultilineInput('gradle-home-cache-includes');
}
getCacheExcludes() {
return core.getMultilineInput('gradle-home-cache-excludes');
}
}
exports.CacheConfig = CacheConfig;
class SummaryConfig {
shouldGenerateJobSummary(hasFailure) {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
if (!this.isJobSummaryEnabled()) {
return false;
}
return this.shouldAddJobSummary(this.getJobSummaryOption(), hasFailure);
}
shouldAddPRComment(hasFailure) {
return this.shouldAddJobSummary(this.getPRCommentOption(), hasFailure);
}
shouldAddJobSummary(option, hasFailure) {
switch (option) {
case JobSummaryOption.Always:
return true;
case JobSummaryOption.Never:
return false;
case JobSummaryOption.OnFailure:
return hasFailure;
}
}
isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true);
}
getJobSummaryOption() {
return this.parseJobSummaryOption('add-job-summary');
}
getPRCommentOption() {
return this.parseJobSummaryOption('add-job-summary-as-pr-comment');
}
parseJobSummaryOption(paramName) {
const val = core.getInput(paramName);
switch (val.toLowerCase().trim()) {
case 'never':
return JobSummaryOption.Never;
case 'always':
return JobSummaryOption.Always;
case 'on-failure':
return JobSummaryOption.OnFailure;
}
throw TypeError(`The value '${val}' is not valid for ${paramName}. Valid values are: [never, always, on-failure].`);
}
}
exports.SummaryConfig = SummaryConfig;
var JobSummaryOption;
(function (JobSummaryOption) {
JobSummaryOption["Never"] = "never";
JobSummaryOption["Always"] = "always";
JobSummaryOption["OnFailure"] = "on-failure";
})(JobSummaryOption || (exports.JobSummaryOption = JobSummaryOption = {}));
class BuildScanConfig {
getBuildScanPublishEnabled() {
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement();
}
getBuildScanTermsOfUseUrl() {
return this.getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url');
}
getBuildScanTermsOfUseAgree() {
return this.getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree');
}
verifyTermsOfUseAgreement() {
if ((this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/terms-of-service' &&
this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/help/legal-terms-of-use') ||
this.getBuildScanTermsOfUseAgree() !== 'yes') {
core.warning(`Terms of use at 'https://gradle.com/help/legal-terms-of-use' must be agreed in order to publish build scans.`);
return false;
}
return true;
}
getTermsOfUseProp(newPropName, oldPropName) {
const newProp = core.getInput(newPropName);
if (newProp !== '') {
return newProp;
}
return core.getInput(oldPropName);
}
}
exports.BuildScanConfig = BuildScanConfig;
class GradleExecutionConfig {
getGradleVersion() {
return core.getInput('gradle-version');
}
getBuildRootDirectory() {
const baseDirectory = getWorkspaceDirectory();
const buildRootDirectoryInput = core.getInput('build-root-directory');
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
? path_1.default.resolve(baseDirectory)
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
return resolvedBuildRootDirectory;
}
getArguments() {
const input = core.getInput('arguments');
return (0, string_argv_1.parseArgsStringToArgv)(input);
}
getDependencyResolutionTask() {
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
}
getAdditionalArguments() {
return core.getInput('additional-arguments');
}
}
exports.GradleExecutionConfig = GradleExecutionConfig;
function getJobMatrix() {
return core.getInput('workflow-job-context');
}
exports.getJobMatrix = getJobMatrix;
function getGithubToken() {
return core.getInput('github-token', { required: true });
}
exports.getGithubToken = getGithubToken;
function getWorkspaceDirectory() {
return process.env[`GITHUB_WORKSPACE`] || '';
}
exports.getWorkspaceDirectory = getWorkspaceDirectory;
function parseNumericInput(paramName, paramValue, paramDefault) {
if (paramValue.length === 0) {
return paramDefault;
}
const numericValue = parseInt(paramValue);
if (isNaN(numericValue)) {
throw TypeError(`The value '${paramValue}' is not a valid numeric value for '${paramName}'.`);
}
return numericValue;
}
exports.parseNumericInput = parseNumericInput;
function getBooleanInput(paramName, paramDefault = false) {
const paramValue = core.getInput(paramName);
switch (paramValue.toLowerCase().trim()) {
case '':
return paramDefault;
case 'false':
return false;
case 'true':
return true;
}
throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`);
}
/***/ }),
/***/ 87345:
@ -142237,7 +142342,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);
@ -142276,7 +142382,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 }));
@ -142302,8 +142408,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>
@ -142405,7 +142531,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';
@ -142455,7 +142581,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');

File diff suppressed because one or more lines are too long

View file

@ -91350,7 +91350,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__(5438));
const input_params_1 = __nccwpck_require__(3885);
const configuration_1 = __nccwpck_require__(5778);
const cache_utils_1 = __nccwpck_require__(1044);
const CACHE_PROTOCOL_VERSION = 'v1';
const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX';
@ -91395,7 +91395,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() {
@ -92531,176 +92531,7 @@ exports.GradleUserHomeCache = GradleUserHomeCache;
/***/ }),
/***/ 5146:
/***/ (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__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
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;
/***/ }),
/***/ 8594:
/***/ (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.run = void 0;
const core = __importStar(__nccwpck_require__(2186));
const setupGradle = __importStar(__nccwpck_require__(8652));
const input_params_1 = __nccwpck_require__(3885);
const errors_1 = __nccwpck_require__(6976);
process.on('uncaughtException', e => handleFailure(e));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield setupGradle.complete(new input_params_1.CacheConfig(), new input_params_1.SummaryConfig());
}
catch (error) {
if (error instanceof errors_1.PostActionJobFailure) {
core.setFailed(String(error));
}
else {
handleFailure(error);
}
}
process.exit();
});
}
exports.run = run;
function handleFailure(error) {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`);
if (error instanceof Error && error.stack) {
core.info(error.stack);
}
}
run();
/***/ }),
/***/ 6976:
/***/ ((__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;
/***/ }),
/***/ 3885:
/***/ 5778:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
@ -92732,13 +92563,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__(2186));
const github = __importStar(__nccwpck_require__(5438));
const cache = __importStar(__nccwpck_require__(7799));
const deprecator = __importStar(__nccwpck_require__(2572));
const summary_1 = __nccwpck_require__(1327);
const string_argv_1 = __nccwpck_require__(9663);
const path_1 = __importDefault(__nccwpck_require__(1017));
const ACTION_ID_VAR = 'GRADLE_ACTION_ID';
class DependencyGraphConfig {
getDependencyGraphOption() {
const val = core.getInput('dependency-graph');
@ -92907,6 +92740,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);
}
}
@ -92925,6 +92763,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() {
@ -92947,6 +92788,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;
@ -92972,6 +92821,259 @@ function getBooleanInput(paramName, paramDefault = false) {
}
/***/ }),
/***/ 5146:
/***/ (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__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
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;
/***/ }),
/***/ 8594:
/***/ (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.run = void 0;
const core = __importStar(__nccwpck_require__(2186));
const setupGradle = __importStar(__nccwpck_require__(8652));
const configuration_1 = __nccwpck_require__(5778);
const errors_1 = __nccwpck_require__(6976);
process.on('uncaughtException', e => handleFailure(e));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield setupGradle.complete(new configuration_1.CacheConfig(), new configuration_1.SummaryConfig());
}
catch (error) {
if (error instanceof errors_1.PostActionJobFailure) {
core.setFailed(String(error));
}
else {
handleFailure(error);
}
}
process.exit();
});
}
exports.run = run;
function handleFailure(error) {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`);
if (error instanceof Error && error.stack) {
core.info(error.stack);
}
}
run();
/***/ }),
/***/ 2572:
/***/ (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__(2186));
const configuration_1 = __nccwpck_require__(5778);
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;
/***/ }),
/***/ 6976:
/***/ ((__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;
/***/ }),
/***/ 7345:
@ -93016,7 +93118,8 @@ exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(2186));
const github = __importStar(__nccwpck_require__(5438));
const request_error_1 = __nccwpck_require__(537);
const input_params_1 = __nccwpck_require__(3885);
const configuration_1 = __nccwpck_require__(5778);
const deprecation_collector_1 = __nccwpck_require__(2572);
function generateJobSummary(buildResults, cachingReport, config) {
return __awaiter(this, void 0, void 0, function* () {
const summaryTable = renderSummaryTable(buildResults);
@ -93055,7 +93158,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 }));
@ -93081,8 +93184,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>
@ -93184,7 +93307,7 @@ const buildScan = __importStar(__nccwpck_require__(5772));
const build_results_1 = __nccwpck_require__(2107);
const cache_reporting_1 = __nccwpck_require__(7391);
const daemon_controller_1 = __nccwpck_require__(5146);
const input_params_1 = __nccwpck_require__(3885);
const configuration_1 = __nccwpck_require__(5778);
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
const USER_HOME = 'USER_HOME';
const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
@ -93234,7 +93357,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');

File diff suppressed because one or more lines are too long

View file

@ -139922,7 +139922,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';
@ -139967,7 +139967,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() {
@ -141101,6 +141101,298 @@ class GradleUserHomeCache {
exports.GradleUserHomeCache = GradleUserHomeCache;
/***/ }),
/***/ 15778:
/***/ (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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
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');
switch (val.toLowerCase().trim()) {
case 'disabled':
return DependencyGraphOption.Disabled;
case 'generate':
return DependencyGraphOption.Generate;
case 'generate-and-submit':
return DependencyGraphOption.GenerateAndSubmit;
case 'generate-and-upload':
return DependencyGraphOption.GenerateAndUpload;
case 'download-and-submit':
return DependencyGraphOption.DownloadAndSubmit;
case 'clear':
return DependencyGraphOption.Clear;
}
throw TypeError(`The value '${val}' is not valid for 'dependency-graph'. Valid values are: [disabled, generate, generate-and-submit, generate-and-upload, download-and-submit, clear]. The default value is 'disabled'.`);
}
getDependencyGraphContinueOnFailure() {
return getBooleanInput('dependency-graph-continue-on-failure', true);
}
getArtifactRetentionDays() {
const val = core.getInput('artifact-retention-days');
return parseNumericInput('artifact-retention-days', val, 0);
}
getJobCorrelator() {
return DependencyGraphConfig.constructJobCorrelator(github.context.workflow, github.context.job, getJobMatrix());
}
static constructJobCorrelator(workflow, jobId, matrixJson) {
const matrixString = this.describeMatrix(matrixJson);
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`;
return this.sanitize(label);
}
static describeMatrix(matrixJson) {
core.debug(`Got matrix json: ${matrixJson}`);
const matrix = JSON.parse(matrixJson);
if (matrix) {
return Object.values(matrix).join('-');
}
return '';
}
static sanitize(value) {
return value
.replace(/[^a-zA-Z0-9_-\s]/g, '')
.replace(/\s+/g, '_')
.toLowerCase();
}
}
exports.DependencyGraphConfig = DependencyGraphConfig;
var DependencyGraphOption;
(function (DependencyGraphOption) {
DependencyGraphOption["Disabled"] = "disabled";
DependencyGraphOption["Generate"] = "generate";
DependencyGraphOption["GenerateAndSubmit"] = "generate-and-submit";
DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload";
DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit";
DependencyGraphOption["Clear"] = "clear";
})(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {}));
class CacheConfig {
isCacheDisabled() {
if (!cache.isFeatureAvailable()) {
return true;
}
return getBooleanInput('cache-disabled');
}
isCacheReadOnly() {
return !this.isCacheWriteOnly() && getBooleanInput('cache-read-only');
}
isCacheWriteOnly() {
return getBooleanInput('cache-write-only');
}
isCacheOverwriteExisting() {
return getBooleanInput('cache-overwrite-existing');
}
isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match');
}
isCacheCleanupEnabled() {
return getBooleanInput('gradle-home-cache-cleanup') && !this.isCacheReadOnly();
}
getCacheEncryptionKey() {
return core.getInput('cache-encryption-key');
}
getCacheIncludes() {
return core.getMultilineInput('gradle-home-cache-includes');
}
getCacheExcludes() {
return core.getMultilineInput('gradle-home-cache-excludes');
}
}
exports.CacheConfig = CacheConfig;
class SummaryConfig {
shouldGenerateJobSummary(hasFailure) {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
if (!this.isJobSummaryEnabled()) {
return false;
}
return this.shouldAddJobSummary(this.getJobSummaryOption(), hasFailure);
}
shouldAddPRComment(hasFailure) {
return this.shouldAddJobSummary(this.getPRCommentOption(), hasFailure);
}
shouldAddJobSummary(option, hasFailure) {
switch (option) {
case JobSummaryOption.Always:
return true;
case JobSummaryOption.Never:
return false;
case JobSummaryOption.OnFailure:
return hasFailure;
}
}
isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true);
}
getJobSummaryOption() {
return this.parseJobSummaryOption('add-job-summary');
}
getPRCommentOption() {
return this.parseJobSummaryOption('add-job-summary-as-pr-comment');
}
parseJobSummaryOption(paramName) {
const val = core.getInput(paramName);
switch (val.toLowerCase().trim()) {
case 'never':
return JobSummaryOption.Never;
case 'always':
return JobSummaryOption.Always;
case 'on-failure':
return JobSummaryOption.OnFailure;
}
throw TypeError(`The value '${val}' is not valid for ${paramName}. Valid values are: [never, always, on-failure].`);
}
}
exports.SummaryConfig = SummaryConfig;
var JobSummaryOption;
(function (JobSummaryOption) {
JobSummaryOption["Never"] = "never";
JobSummaryOption["Always"] = "always";
JobSummaryOption["OnFailure"] = "on-failure";
})(JobSummaryOption || (exports.JobSummaryOption = JobSummaryOption = {}));
class BuildScanConfig {
getBuildScanPublishEnabled() {
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement();
}
getBuildScanTermsOfUseUrl() {
return this.getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url');
}
getBuildScanTermsOfUseAgree() {
return this.getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree');
}
verifyTermsOfUseAgreement() {
if ((this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/terms-of-service' &&
this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/help/legal-terms-of-use') ||
this.getBuildScanTermsOfUseAgree() !== 'yes') {
core.warning(`Terms of use at 'https://gradle.com/help/legal-terms-of-use' must be agreed in order to publish build scans.`);
return false;
}
return true;
}
getTermsOfUseProp(newPropName, oldPropName) {
const newProp = core.getInput(newPropName);
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);
}
}
exports.BuildScanConfig = BuildScanConfig;
class GradleExecutionConfig {
getGradleVersion() {
return core.getInput('gradle-version');
}
getBuildRootDirectory() {
const baseDirectory = getWorkspaceDirectory();
const buildRootDirectoryInput = core.getInput('build-root-directory');
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
? path_1.default.resolve(baseDirectory)
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
return resolvedBuildRootDirectory;
}
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() {
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
}
getAdditionalArguments() {
return core.getInput('additional-arguments');
}
}
exports.GradleExecutionConfig = GradleExecutionConfig;
function getJobMatrix() {
return core.getInput('workflow-job-context');
}
exports.getJobMatrix = getJobMatrix;
function getGithubToken() {
return core.getInput('github-token', { required: true });
}
exports.getGithubToken = getGithubToken;
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;
}
const numericValue = parseInt(paramValue);
if (isNaN(numericValue)) {
throw TypeError(`The value '${paramValue}' is not a valid numeric value for '${paramName}'.`);
}
return numericValue;
}
exports.parseNumericInput = parseNumericInput;
function getBooleanInput(paramName, paramDefault = false) {
const paramValue = core.getInput(paramName);
switch (paramValue.toLowerCase().trim()) {
case '':
return paramDefault;
case 'false':
return false;
case 'true':
return true;
}
throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`);
}
/***/ }),
/***/ 85146:
@ -141226,16 +141518,16 @@ 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 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 === input_params_1.DependencyGraphOption.Disabled) {
if (option === configuration_1.DependencyGraphOption.Disabled) {
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'false');
return;
}
if (option === input_params_1.DependencyGraphOption.DownloadAndSubmit) {
if (option === configuration_1.DependencyGraphOption.DownloadAndSubmit) {
yield downloadAndSubmitDependencyGraphs(config);
return;
}
@ -141246,9 +141538,9 @@ function setup(config) {
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) {
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', '');
}
@ -141265,15 +141557,15 @@ function complete(config) {
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:
case configuration_1.DependencyGraphOption.Disabled:
case configuration_1.DependencyGraphOption.Generate:
case configuration_1.DependencyGraphOption.DownloadAndSubmit:
return;
case input_params_1.DependencyGraphOption.GenerateAndSubmit:
case input_params_1.DependencyGraphOption.Clear:
case configuration_1.DependencyGraphOption.GenerateAndSubmit:
case configuration_1.DependencyGraphOption.Clear:
yield submitDependencyGraphs(yield findGeneratedDependencyGraphFiles());
return;
case input_params_1.DependencyGraphOption.GenerateAndUpload:
case configuration_1.DependencyGraphOption.GenerateAndUpload:
yield uploadDependencyGraphs(yield findGeneratedDependencyGraphFiles(), config);
}
}
@ -141285,7 +141577,7 @@ function complete(config) {
exports.complete = complete;
function findGeneratedDependencyGraphFiles() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
return yield findDependencyGraphFiles(workspaceDirectory);
});
}
@ -141296,7 +141588,7 @@ function uploadDependencyGraphs(dependencyGraphFiles, config) {
core.info(`Would upload: ${dependencyGraphFiles.join(', ')}`);
return;
}
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
const artifactClient = new artifact_1.DefaultArtifactClient();
for (const dependencyGraphFile of dependencyGraphFiles) {
const relativePath = getRelativePathFromWorkspace(dependencyGraphFile);
@ -141318,7 +141610,7 @@ function downloadAndSubmitDependencyGraphs(config) {
yield submitDependencyGraphs(yield downloadDependencyGraphs());
}
catch (e) {
warnOrFail(config, input_params_1.DependencyGraphOption.DownloadAndSubmit, e);
warnOrFail(config, configuration_1.DependencyGraphOption.DownloadAndSubmit, e);
}
});
}
@ -141369,10 +141661,10 @@ function submitDependencyGraphFile(jsonFile) {
}
function downloadDependencyGraphs() {
return __awaiter(this, void 0, void 0, function* () {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
const findBy = github.context.payload.workflow_run
? {
token: (0, input_params_1.getGithubToken)(),
token: (0, configuration_1.getGithubToken)(),
workflowRunId: github.context.payload.workflow_run.id,
repositoryName: github.context.repo.repo,
repositoryOwner: github.context.repo.owner
@ -141418,10 +141710,10 @@ function warnOrFail(config, option, error) {
core.warning(`Failed to ${option} dependency graph. Will continue.\n${String(error)}`);
}
function getOctokit() {
return github.getOctokit((0, input_params_1.getGithubToken)());
return github.getOctokit((0, configuration_1.getGithubToken)());
}
function getRelativePathFromWorkspace(file) {
const workspaceDirectory = (0, input_params_1.getWorkspaceDirectory)();
const workspaceDirectory = (0, configuration_1.getWorkspaceDirectory)();
return path.relative(workspaceDirectory, file);
}
function getShaFromContext() {
@ -141445,6 +141737,90 @@ function isRunningInActEnvironment() {
}
/***/ }),
/***/ 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:
@ -141662,7 +142038,7 @@ const cache = __importStar(__nccwpck_require__(27799));
const toolCache = __importStar(__nccwpck_require__(27784));
const gradlew = __importStar(__nccwpck_require__(46807));
const cache_utils_1 = __nccwpck_require__(11044);
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions';
function provisionGradle(gradleVersion) {
return __awaiter(this, void 0, void 0, function* () {
@ -141779,7 +142155,7 @@ function locateGradleAndDownloadIfRequired(versionInfo) {
function downloadAndCacheGradleDistribution(versionInfo) {
return __awaiter(this, void 0, void 0, function* () {
const downloadPath = path.join(os.homedir(), `gradle-installations/downloads/gradle-${versionInfo.version}-bin.zip`);
const cacheConfig = new input_params_1.CacheConfig();
const cacheConfig = new configuration_1.CacheConfig();
if (cacheConfig.isCacheDisabled()) {
yield downloadGradleDistribution(versionInfo, downloadPath);
return downloadPath;
@ -141836,280 +142212,6 @@ function httpGetString(url) {
}
/***/ }),
/***/ 23885:
/***/ (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 __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;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const cache = __importStar(__nccwpck_require__(27799));
const summary_1 = __nccwpck_require__(81327);
const string_argv_1 = __nccwpck_require__(19663);
const path_1 = __importDefault(__nccwpck_require__(71017));
class DependencyGraphConfig {
getDependencyGraphOption() {
const val = core.getInput('dependency-graph');
switch (val.toLowerCase().trim()) {
case 'disabled':
return DependencyGraphOption.Disabled;
case 'generate':
return DependencyGraphOption.Generate;
case 'generate-and-submit':
return DependencyGraphOption.GenerateAndSubmit;
case 'generate-and-upload':
return DependencyGraphOption.GenerateAndUpload;
case 'download-and-submit':
return DependencyGraphOption.DownloadAndSubmit;
case 'clear':
return DependencyGraphOption.Clear;
}
throw TypeError(`The value '${val}' is not valid for 'dependency-graph'. Valid values are: [disabled, generate, generate-and-submit, generate-and-upload, download-and-submit, clear]. The default value is 'disabled'.`);
}
getDependencyGraphContinueOnFailure() {
return getBooleanInput('dependency-graph-continue-on-failure', true);
}
getArtifactRetentionDays() {
const val = core.getInput('artifact-retention-days');
return parseNumericInput('artifact-retention-days', val, 0);
}
getJobCorrelator() {
return DependencyGraphConfig.constructJobCorrelator(github.context.workflow, github.context.job, getJobMatrix());
}
static constructJobCorrelator(workflow, jobId, matrixJson) {
const matrixString = this.describeMatrix(matrixJson);
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`;
return this.sanitize(label);
}
static describeMatrix(matrixJson) {
core.debug(`Got matrix json: ${matrixJson}`);
const matrix = JSON.parse(matrixJson);
if (matrix) {
return Object.values(matrix).join('-');
}
return '';
}
static sanitize(value) {
return value
.replace(/[^a-zA-Z0-9_-\s]/g, '')
.replace(/\s+/g, '_')
.toLowerCase();
}
}
exports.DependencyGraphConfig = DependencyGraphConfig;
var DependencyGraphOption;
(function (DependencyGraphOption) {
DependencyGraphOption["Disabled"] = "disabled";
DependencyGraphOption["Generate"] = "generate";
DependencyGraphOption["GenerateAndSubmit"] = "generate-and-submit";
DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload";
DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit";
DependencyGraphOption["Clear"] = "clear";
})(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {}));
class CacheConfig {
isCacheDisabled() {
if (!cache.isFeatureAvailable()) {
return true;
}
return getBooleanInput('cache-disabled');
}
isCacheReadOnly() {
return !this.isCacheWriteOnly() && getBooleanInput('cache-read-only');
}
isCacheWriteOnly() {
return getBooleanInput('cache-write-only');
}
isCacheOverwriteExisting() {
return getBooleanInput('cache-overwrite-existing');
}
isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match');
}
isCacheCleanupEnabled() {
return getBooleanInput('gradle-home-cache-cleanup') && !this.isCacheReadOnly();
}
getCacheEncryptionKey() {
return core.getInput('cache-encryption-key');
}
getCacheIncludes() {
return core.getMultilineInput('gradle-home-cache-includes');
}
getCacheExcludes() {
return core.getMultilineInput('gradle-home-cache-excludes');
}
}
exports.CacheConfig = CacheConfig;
class SummaryConfig {
shouldGenerateJobSummary(hasFailure) {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
if (!this.isJobSummaryEnabled()) {
return false;
}
return this.shouldAddJobSummary(this.getJobSummaryOption(), hasFailure);
}
shouldAddPRComment(hasFailure) {
return this.shouldAddJobSummary(this.getPRCommentOption(), hasFailure);
}
shouldAddJobSummary(option, hasFailure) {
switch (option) {
case JobSummaryOption.Always:
return true;
case JobSummaryOption.Never:
return false;
case JobSummaryOption.OnFailure:
return hasFailure;
}
}
isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true);
}
getJobSummaryOption() {
return this.parseJobSummaryOption('add-job-summary');
}
getPRCommentOption() {
return this.parseJobSummaryOption('add-job-summary-as-pr-comment');
}
parseJobSummaryOption(paramName) {
const val = core.getInput(paramName);
switch (val.toLowerCase().trim()) {
case 'never':
return JobSummaryOption.Never;
case 'always':
return JobSummaryOption.Always;
case 'on-failure':
return JobSummaryOption.OnFailure;
}
throw TypeError(`The value '${val}' is not valid for ${paramName}. Valid values are: [never, always, on-failure].`);
}
}
exports.SummaryConfig = SummaryConfig;
var JobSummaryOption;
(function (JobSummaryOption) {
JobSummaryOption["Never"] = "never";
JobSummaryOption["Always"] = "always";
JobSummaryOption["OnFailure"] = "on-failure";
})(JobSummaryOption || (exports.JobSummaryOption = JobSummaryOption = {}));
class BuildScanConfig {
getBuildScanPublishEnabled() {
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement();
}
getBuildScanTermsOfUseUrl() {
return this.getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url');
}
getBuildScanTermsOfUseAgree() {
return this.getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree');
}
verifyTermsOfUseAgreement() {
if ((this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/terms-of-service' &&
this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/help/legal-terms-of-use') ||
this.getBuildScanTermsOfUseAgree() !== 'yes') {
core.warning(`Terms of use at 'https://gradle.com/help/legal-terms-of-use' must be agreed in order to publish build scans.`);
return false;
}
return true;
}
getTermsOfUseProp(newPropName, oldPropName) {
const newProp = core.getInput(newPropName);
if (newProp !== '') {
return newProp;
}
return core.getInput(oldPropName);
}
}
exports.BuildScanConfig = BuildScanConfig;
class GradleExecutionConfig {
getGradleVersion() {
return core.getInput('gradle-version');
}
getBuildRootDirectory() {
const baseDirectory = getWorkspaceDirectory();
const buildRootDirectoryInput = core.getInput('build-root-directory');
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
? path_1.default.resolve(baseDirectory)
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
return resolvedBuildRootDirectory;
}
getArguments() {
const input = core.getInput('arguments');
return (0, string_argv_1.parseArgsStringToArgv)(input);
}
getDependencyResolutionTask() {
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
}
getAdditionalArguments() {
return core.getInput('additional-arguments');
}
}
exports.GradleExecutionConfig = GradleExecutionConfig;
function getJobMatrix() {
return core.getInput('workflow-job-context');
}
exports.getJobMatrix = getJobMatrix;
function getGithubToken() {
return core.getInput('github-token', { required: true });
}
exports.getGithubToken = getGithubToken;
function getWorkspaceDirectory() {
return process.env[`GITHUB_WORKSPACE`] || '';
}
exports.getWorkspaceDirectory = getWorkspaceDirectory;
function parseNumericInput(paramName, paramValue, paramDefault) {
if (paramValue.length === 0) {
return paramDefault;
}
const numericValue = parseInt(paramValue);
if (isNaN(numericValue)) {
throw TypeError(`The value '${paramValue}' is not a valid numeric value for '${paramName}'.`);
}
return numericValue;
}
exports.parseNumericInput = parseNumericInput;
function getBooleanInput(paramName, paramDefault = false) {
const paramValue = core.getInput(paramName);
switch (paramValue.toLowerCase().trim()) {
case '':
return paramDefault;
case 'false':
return false;
case 'true':
return true;
}
throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`);
}
/***/ }),
/***/ 87345:
@ -142154,7 +142256,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);
@ -142193,7 +142296,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 }));
@ -142219,8 +142322,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>
@ -142322,7 +142445,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';
@ -142372,7 +142495,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');
@ -142439,14 +142562,22 @@ const core = __importStar(__nccwpck_require__(42186));
const setupGradle = __importStar(__nccwpck_require__(18652));
const gradle = __importStar(__nccwpck_require__(94475));
const dependencyGraph = __importStar(__nccwpck_require__(80));
const input_params_1 = __nccwpck_require__(23885);
const configuration_1 = __nccwpck_require__(15778);
const deprecation_collector_1 = __nccwpck_require__(22572);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield setupGradle.setup(new input_params_1.CacheConfig(), new input_params_1.BuildScanConfig());
yield dependencyGraph.setup(new input_params_1.DependencyGraphConfig());
const config = new input_params_1.GradleExecutionConfig();
if ((0, configuration_1.getActionId)() === 'gradle/gradle-build-action') {
(0, deprecation_collector_1.recordDeprecation)('The action `gradle/gradle-build-action` has been replaced by `gradle/actions/setup-gradle`');
}
else {
(0, configuration_1.setActionId)('gradle/actions/setup-gradle');
}
yield setupGradle.setup(new configuration_1.CacheConfig(), new configuration_1.BuildScanConfig());
yield dependencyGraph.setup(new configuration_1.DependencyGraphConfig());
const config = new configuration_1.GradleExecutionConfig();
yield gradle.provisionAndMaybeExecute(config.getGradleVersion(), config.getBuildRootDirectory(), config.getArguments());
(0, deprecation_collector_1.saveDeprecationState)();
}
catch (error) {
core.setFailed(String(error));

File diff suppressed because one or more lines are too long

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

View file

@ -0,0 +1,105 @@
# Deprecation upgrade guide
As these actions evolve, certain inputs, behaviour and usages are deprecated for removal.
Deprecated functionality will be fully supported during the current major release, and will be
removed in the next major release.
Users will receive a deprecation warning when they rely on deprecated functionality,
prompting them to update their workflows.
## Deprecated in v3.x
### The action `gradle/gradle-build-action` has been replaced by `gradle/actions/setup-gradle`
The `gradle-build-action` action has evolved, so that the core functionality is now to configure the
Gradle environment for GitHub Actions. For clarity and consistency with other action (eg `setup-java`, `setup-node`), the `gradle-build-action` has been replaced by the `setup-gradle` action.
As of `v3.x`, the `setup-gradle` and `gradle-build-action` actions are functionally identical,
and are released with the same versions.
To convert your workflows, simply replace:
```
uses: gradle/gradle-build-action@v3
```
with
```
uses: gradle/actions/setup-gradle@v3
```
### Using the action to execute Gradle via the `arguments` parameter is deprecated
The core functionality of the `setup-gradle` (and `gradle-build-action`) actions is to configure your
Gradle environment for GitHub Actions. Once the action has run, any subsequent Gradle executions will
benefit from caching, reporting and other features of the action.
Using the `arguments` parameter to execute Gradle directly is not necessary to benefit from this action.
This input is deprecated, and will be removed in the `v4` major release of the action.
To convert your workflows, replace any steps using the `arguments` parameter with 2 steps: one to `setup-gradle` and another that runs your Gradle build.
For example, if your workflow looks like this:
```
steps:
- name: Assemble the project
uses: gradle/actions/setup-gradle@v3
with:
arguments: 'assemble'
- name: Run the tests
uses: gradle/actions/setup-gradle@v3
with:
arguments: 'test'
- name: Run build in a subdirectory
uses: gradle/actions/setup-gradle@v3
with:
build-root-directory: another-build
arguments: 'build'
```
Then replace this with a single call to `setup-gradle` together with separate `run` steps to execute your build.
```
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Assemble the project
run: ./gradlew assemble
- name: Run the tests
run: ./gradlew test
- name: Run build in a subdirectory
working-directory: another-build
run: ./gradlew build
```
Using the action in this way gives you more control over how Gradle is executed, while still giving you
all of the benefits of the `setup-gradle` action.
The `arguments` parameter is scheduled to be removed in `setup-gradle@v4`.
Note: if you are using the `gradle-build-action`, [see here](#the-action-gradlegradle-build-action-has-been-replaced-by-gradleactionssetup-gradle) for more details on how to migrate.
### The `build-scan-terms-of-service` input parameters have been renamed
With recent releases of the `com.gradle.develocity` plugin, key input parameters have been renamed.
- `build-scan-terms-of-service-url` is now `build-scan-terms-of-use-url`
- `build-scan-terms-of-service-agree` is now `build-scan-terms-of-use-agree`
The standard URL for the terms of use has also changed to https://gradle.com/help/legal-terms-of-use
To convert your workflows, change:
```
build-scan-publish: true
build-scan-terms-of-service-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-service-agree: "yes"
```
to this:
```
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"
```
These deprecated build-scan parameters are scheduled to be removed in `setup-gradle@v4` and `dependency-submission@v4`.

View file

@ -1,5 +1,5 @@
import * as core from '@actions/core'
import {BuildScanConfig} from './input-params'
import {BuildScanConfig} from './configuration'
export function setup(config: BuildScanConfig): void {
maybeExportVariable('DEVELOCITY_INJECTION_INIT_SCRIPT_NAME', 'gradle-actions.inject-develocity.init.gradle')

View file

@ -1,6 +1,6 @@
import * as github from '@actions/github'
import {CacheConfig, getJobMatrix} from '../input-params'
import {CacheConfig, getJobMatrix} from '../configuration'
import {hashStrings} from './cache-utils'
const CACHE_PROTOCOL_VERSION = 'v1'

View file

@ -3,7 +3,7 @@ import {CacheListener} from './cache-reporting'
import {GradleUserHomeCache} from './gradle-user-home-cache'
import {CacheCleaner} from './cache-cleaner'
import {DaemonController} from '../daemon-controller'
import {CacheConfig} from '../input-params'
import {CacheConfig} from '../configuration'
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED'

View file

@ -9,7 +9,7 @@ import {CacheEntryListener, CacheListener} from './cache-reporting'
import {cacheDebug, hashFileNames, isCacheDebuggingEnabled, restoreCache, saveCache, tryDelete} from './cache-utils'
import {BuildResult, loadBuildResults} from '../build-results'
import {CacheConfig} from '../input-params'
import {CacheConfig} from '../configuration'
import {getCacheKeyBase} from './cache-key'
const SKIP_RESTORE_VAR = 'GRADLE_BUILD_ACTION_SKIP_RESTORE'

View file

@ -8,7 +8,7 @@ import {generateCacheKey} from './cache-key'
import {CacheListener} from './cache-reporting'
import {saveCache, restoreCache, cacheDebug, isCacheDebuggingEnabled, tryDelete} from './cache-utils'
import {GradleHomeEntryExtractor, ConfigurationCacheEntryExtractor} from './gradle-home-extry-extractor'
import {CacheConfig} from '../input-params'
import {CacheConfig} from '../configuration'
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key'

View file

@ -1,11 +1,14 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import * as cache from '@actions/cache'
import * as deprecator from './deprecation-collector'
import {SUMMARY_ENV_VAR} from '@actions/core/lib/summary'
import {parseArgsStringToArgv} from 'string-argv'
import path from 'path'
const ACTION_ID_VAR = 'GRADLE_ACTION_ID'
export class DependencyGraphConfig {
getDependencyGraphOption(): DependencyGraphOption {
const val = core.getInput('dependency-graph')
@ -215,6 +218,11 @@ export 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)
}
}
@ -236,6 +244,11 @@ export class GradleExecutionConfig {
getArguments(): string[] {
const input = core.getInput('arguments')
if (input.length !== 0) {
deprecator.recordDeprecation(
'Using the action to execute Gradle via the `arguments` parameter is deprecated'
)
}
return parseArgsStringToArgv(input)
}
@ -261,6 +274,14 @@ export function getWorkspaceDirectory(): string {
return process.env[`GITHUB_WORKSPACE`] || ''
}
export function getActionId(): string | undefined {
return process.env[ACTION_ID_VAR]
}
export function setActionId(id: string): void {
core.exportVariable(ACTION_ID_VAR, id)
}
export function parseNumericInput(paramName: string, paramValue: string, paramDefault: number): number {
if (paramValue.length === 0) {
return paramDefault

View file

@ -10,7 +10,7 @@ import * as path from 'path'
import fs from 'fs'
import {PostActionJobFailure} from './errors'
import {DependencyGraphConfig, DependencyGraphOption, getGithubToken, getWorkspaceDirectory} from './input-params'
import {DependencyGraphConfig, DependencyGraphOption, getGithubToken, getWorkspaceDirectory} from './configuration'
const DEPENDENCY_GRAPH_PREFIX = 'dependency-graph_'

View file

@ -10,14 +10,18 @@ import {
CacheConfig,
DependencyGraphConfig,
DependencyGraphOption,
GradleExecutionConfig
} from '../input-params'
GradleExecutionConfig,
setActionId
} from '../configuration'
import {saveDeprecationState} from '../deprecation-collector'
/**
* The main entry point for the action, called by Github Actions for the step.
*/
export async function run(): Promise<void> {
try {
setActionId('gradle/actions/dependency-submission')
// Configure Gradle environment (Gradle User Home)
await setupGradle.setup(new CacheConfig(), new BuildScanConfig())
@ -49,6 +53,8 @@ export async function run(): Promise<void> {
)
await dependencyGraph.complete(config)
saveDeprecationState()
} catch (error) {
core.setFailed(String(error))
if (error instanceof Error && error.stack) {

View file

@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as setupGradle from '../setup-gradle'
import {CacheConfig, SummaryConfig} from '../input-params'
import {CacheConfig, SummaryConfig} from '../configuration'
import {PostActionJobFailure} from '../errors'
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in

View file

@ -0,0 +1,54 @@
import * as core from '@actions/core'
import {getActionId} from './configuration'
const DEPRECATION_UPGRADE_PAGE = 'https://github.com/gradle/actions/blob/main/docs/deprecation-upgrade-guide.md'
const recordedDeprecations: Deprecation[] = []
export class Deprecation {
constructor(readonly message: string) {}
getDocumentationLink(): string {
const deprecationAnchor = this.message
.toLowerCase()
.replace(/[^\w\s-]|_/g, '')
.replace(/ /g, '-')
return `${DEPRECATION_UPGRADE_PAGE}#${deprecationAnchor}`
}
}
export function recordDeprecation(message: string): void {
if (!recordedDeprecations.some(deprecation => deprecation.message === message)) {
recordedDeprecations.push(new Deprecation(message))
}
}
export function getDeprecations(): Deprecation[] {
return recordedDeprecations
}
export function emitDeprecationWarnings(): void {
if (recordedDeprecations.length > 0) {
core.warning(
`This job uses deprecated functionality from the '${getActionId()}' action. Consult the Job Summary for more details.`
)
for (const deprecation of recordedDeprecations) {
core.info(`DEPRECATION: ${deprecation.message}. See ${deprecation.getDocumentationLink()}`)
}
}
}
export function saveDeprecationState(): void {
core.saveState('deprecations', JSON.stringify(recordedDeprecations))
}
export function restoreDeprecationState(): void {
const stringRep = core.getState('deprecations')
if (stringRep === '') {
return
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
JSON.parse(stringRep).forEach((obj: any) => {
recordedDeprecations.push(new Deprecation(obj.message))
})
}

View file

@ -8,7 +8,7 @@ import * as toolCache from '@actions/tool-cache'
import * as gradlew from './gradlew'
import {handleCacheFailure} from '../caching/cache-utils'
import {CacheConfig} from '../input-params'
import {CacheConfig} from '../configuration'
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'

View file

@ -3,7 +3,8 @@ import * as github from '@actions/github'
import {RequestError} from '@octokit/request-error'
import {BuildResult} from './build-results'
import {SummaryConfig, getGithubToken} from './input-params'
import {SummaryConfig, getActionId, getGithubToken} from './configuration'
import {Deprecation, getDeprecations} from './deprecation-collector'
export async function generateJobSummary(
buildResults: BuildResult[],
@ -78,8 +79,31 @@ Note that this permission is never available for a workflow triggered from a rep
}
function renderSummaryTable(results: BuildResult[]): string {
return `${renderDeprecations()}\n${renderBuildResults(results)}`
}
function renderDeprecations(): string {
const deprecations = getDeprecations()
if (deprecations.length === 0) {
return ''
}
return `
<h4>Deprecation warnings</h4>
This job uses deprecated functionality from the <code>${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: Deprecation): string {
return `<a href="${deprecation.getDocumentationLink()}" target="_blank">${deprecation.message}</a>`
}
function renderBuildResults(results: BuildResult[]): string {
if (results.length === 0) {
return 'No Gradle build results detected.'
return '<b>No Gradle build results detected.</b>'
}
return `

View file

@ -9,7 +9,7 @@ import * as buildScan from './build-scan'
import {loadBuildResults, markBuildResultsProcessed} from './build-results'
import {CacheListener, generateCachingReport} from './caching/cache-reporting'
import {DaemonController} from './daemon-controller'
import {BuildScanConfig, CacheConfig, SummaryConfig, getWorkspaceDirectory} from './input-params'
import {BuildScanConfig, CacheConfig, SummaryConfig, getWorkspaceDirectory} from './configuration'
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
const USER_HOME = 'USER_HOME'

View file

@ -3,13 +3,29 @@ import * as core from '@actions/core'
import * as setupGradle from '../setup-gradle'
import * as gradle from '../execution/gradle'
import * as dependencyGraph from '../dependency-graph'
import {BuildScanConfig, CacheConfig, DependencyGraphConfig, GradleExecutionConfig} from '../input-params'
import {
BuildScanConfig,
CacheConfig,
DependencyGraphConfig,
GradleExecutionConfig,
getActionId,
setActionId
} from '../configuration'
import {recordDeprecation, saveDeprecationState} from '../deprecation-collector'
/**
* The main entry point for the action, called by Github Actions for the step.
*/
export async function run(): Promise<void> {
try {
if (getActionId() === 'gradle/gradle-build-action') {
recordDeprecation(
'The action `gradle/gradle-build-action` has been replaced by `gradle/actions/setup-gradle`'
)
} else {
setActionId('gradle/actions/setup-gradle')
}
// Configure Gradle environment (Gradle User Home)
await setupGradle.setup(new CacheConfig(), new BuildScanConfig())
@ -22,6 +38,8 @@ export async function run(): Promise<void> {
config.getBuildRootDirectory(),
config.getArguments()
)
saveDeprecationState()
} catch (error) {
core.setFailed(String(error))
if (error instanceof Error && error.stack) {

View file

@ -2,8 +2,9 @@ import * as core from '@actions/core'
import * as setupGradle from '../setup-gradle'
import * as dependencyGraph from '../dependency-graph'
import {CacheConfig, DependencyGraphConfig, SummaryConfig} from '../input-params'
import {CacheConfig, DependencyGraphConfig, SummaryConfig} from '../configuration'
import {PostActionJobFailure} from '../errors'
import {emitDeprecationWarnings, restoreDeprecationState} from '../deprecation-collector'
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
@ -15,6 +16,9 @@ process.on('uncaughtException', e => handleFailure(e))
*/
export async function run(): Promise<void> {
try {
restoreDeprecationState()
emitDeprecationWarnings()
if (await setupGradle.complete(new CacheConfig(), new SummaryConfig())) {
// Only submit the dependency graphs once per job
await dependencyGraph.complete(new DependencyGraphConfig())

View file

@ -1,7 +1,7 @@
import * as path from 'path'
import * as fs from 'fs'
import {GradleUserHomeCache} from "../../src/caching/gradle-user-home-cache"
import {CacheConfig} from "../../src/input-params"
import {CacheConfig} from "../../src/configuration"
const testTmp = 'test/jest/tmp'
fs.rmSync(testTmp, {recursive: true, force: true})

View file

@ -1,4 +1,4 @@
import * as inputParams from '../../src/input-params'
import * as inputParams from '../../src/configuration'
describe('input params', () => {
describe('parses numeric input', () => {

View file

@ -1,4 +1,4 @@
import { DependencyGraphConfig } from "../../src/input-params"
import { DependencyGraphConfig } from "../../src/configuration"
describe('dependency-graph', () => {
describe('constructs job correlator', () => {