Build outputs

This commit is contained in:
daz 2024-01-01 13:23:00 -07:00
parent 72abd931ce
commit 45ed60450e
No known key found for this signature in database
4 changed files with 278 additions and 156 deletions

223
dist/main/index.js vendored
View file

@ -139284,8 +139284,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.logCachingReport = exports.writeCachingReport = exports.CacheEntryListener = exports.CacheListener = void 0; exports.generateCachingReport = exports.CacheEntryListener = exports.CacheListener = void 0;
const core = __importStar(__nccwpck_require__(42186));
const cache = __importStar(__nccwpck_require__(27799)); const cache = __importStar(__nccwpck_require__(27799));
class CacheListener { class CacheListener {
constructor() { constructor() {
@ -139373,37 +139372,36 @@ class CacheEntryListener {
} }
} }
exports.CacheEntryListener = CacheEntryListener; exports.CacheEntryListener = CacheEntryListener;
function writeCachingReport(listener) { function generateCachingReport(listener) {
const entries = listener.cacheEntries; const entries = listener.cacheEntries;
core.summary.addRaw(`\n<details><summary><h4>Caching for gradle-build-action was ${listener.cacheStatus} - expand for details</h4></summary>\n`); return `
core.summary.addTable([ <details>
[ <summary><h4>Caching for gradle-build-action was ${listener.cacheStatus} - expand for details</h4></summary>
{ data: '', header: true }, ${renderEntryTable(entries)}
{ data: 'Count', header: true },
{ data: 'Total Size (Mb)', header: true } <h5>Cache Entry Details</h5>
], <pre>
['Entries Restored', `${getCount(entries, e => e.restoredSize)}`, `${getSize(entries, e => e.restoredSize)}`], ${renderEntryDetails(listener)}
['Entries Saved', `${getCount(entries, e => e.savedSize)}`, `${getSize(entries, e => e.savedSize)}`]
]);
core.summary.addHeading('Cache Entry Details', 5);
const entryDetails = renderEntryDetails(listener);
core.summary.addRaw(`<pre>
${entryDetails}
</pre> </pre>
</details> </details>
`); `;
} }
exports.writeCachingReport = writeCachingReport; exports.generateCachingReport = generateCachingReport;
function logCachingReport(listener) { function renderEntryTable(entries) {
const entries = listener.cacheEntries; return `
core.startGroup(`Caching for gradle-build-action was ${listener.cacheStatus} - expand for details`); <table>
core.info(`Entries Restored: ${getCount(entries, e => e.restoredSize)} (${getSize(entries, e => e.restoredSize)} Mb)`); <tr><td></td><th>Count</th><th>Total Size (Mb)</th></tr>
core.info(`Entries Saved : ${getCount(entries, e => e.savedSize)} (${getSize(entries, e => e.savedSize)} Mb)`); <tr><td>Entries Restored</td>
core.info(`Cache Entry Details`); <td>${getCount(entries, e => e.restoredSize)}</td>
core.info(renderEntryDetails(listener)); <td>${getSize(entries, e => e.restoredSize)}</td>
core.endGroup(); </tr>
<tr><td>Entries Saved</td>
<td>${getCount(entries, e => e.savedSize)}</td>
<td>${getSize(entries, e => e.savedSize)}</td>
</tr>
</table>
`;
} }
exports.logCachingReport = logCachingReport;
function renderEntryDetails(listener) { function renderEntryDetails(listener) {
return listener.cacheEntries return listener.cacheEntries
.map(entry => { .map(entry => {
@ -140344,7 +140342,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0; exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphOption = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(42186)); const core = __importStar(__nccwpck_require__(42186));
const string_argv_1 = __nccwpck_require__(19663); const string_argv_1 = __nccwpck_require__(19663);
function isCacheDisabled() { function isCacheDisabled() {
@ -140416,10 +140414,26 @@ function isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true); return getBooleanInput('generate-job-summary', true);
} }
exports.isJobSummaryEnabled = isJobSummaryEnabled; exports.isJobSummaryEnabled = isJobSummaryEnabled;
function isDependencyGraphEnabled() { function getJobSummaryOption() {
return getBooleanInput('generate-dependency-graph', true); return parseJobSummaryOption('add-job-summary');
}
exports.getJobSummaryOption = getJobSummaryOption;
function getPRCommentOption() {
return parseJobSummaryOption('add-job-summary-as-pr-comment');
}
exports.getPRCommentOption = getPRCommentOption;
function 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.isDependencyGraphEnabled = isDependencyGraphEnabled;
function getDependencyGraphOption() { function getDependencyGraphOption() {
const val = core.getInput('dependency-graph'); const val = core.getInput('dependency-graph');
switch (val.toLowerCase().trim()) { switch (val.toLowerCase().trim()) {
@ -140434,7 +140448,7 @@ function getDependencyGraphOption() {
case 'download-and-submit': case 'download-and-submit':
return DependencyGraphOption.DownloadAndSubmit; return DependencyGraphOption.DownloadAndSubmit;
} }
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]. The default value is 'disabled'.`); 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]. The default value is 'disabled'.`);
} }
exports.getDependencyGraphOption = getDependencyGraphOption; exports.getDependencyGraphOption = getDependencyGraphOption;
function getArtifactRetentionDays() { function getArtifactRetentionDays() {
@ -140473,6 +140487,12 @@ var DependencyGraphOption;
DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload"; DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload";
DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit"; DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit";
})(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {})); })(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {}));
var JobSummaryOption;
(function (JobSummaryOption) {
JobSummaryOption["Never"] = "never";
JobSummaryOption["Always"] = "always";
JobSummaryOption["OnFailure"] = "on-failure";
})(JobSummaryOption || (exports.JobSummaryOption = JobSummaryOption = {}));
/***/ }), /***/ }),
@ -140515,48 +140535,89 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.logJobSummary = exports.writeJobSummary = void 0; exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186)); const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const summary_1 = __nccwpck_require__(81327);
const request_error_1 = __nccwpck_require__(10537);
const params = __importStar(__nccwpck_require__(23885));
const cache_reporting_1 = __nccwpck_require__(66674); const cache_reporting_1 = __nccwpck_require__(66674);
function writeJobSummary(buildResults, cacheListener) { function generateJobSummary(buildResults, cacheListener) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info('Writing job summary'); const summaryTable = renderSummaryTable(buildResults);
if (buildResults.length === 0) { const cachingReport = (0, cache_reporting_1.generateCachingReport)(cacheListener);
core.debug('No Gradle build results found. Summary table will not be generated.'); if (shouldGenerateJobSummary(buildResults)) {
} core.info('Generating Job Summary');
else { core.summary.addRaw(summaryTable);
writeSummaryTable(buildResults); core.summary.addRaw(cachingReport);
}
(0, cache_reporting_1.writeCachingReport)(cacheListener);
yield core.summary.write(); yield core.summary.write();
});
}
exports.writeJobSummary = writeJobSummary;
function logJobSummary(buildResults, cacheListener) {
return __awaiter(this, void 0, void 0, function* () {
if (buildResults.length === 0) {
core.debug('No Gradle build results found. Summary table will not be logged.');
} }
else { else {
logSummaryTable(buildResults); core.info('============================');
core.info(summaryTable);
core.info('============================');
core.info(cachingReport);
core.info('============================');
}
if (shouldAddPRComment(buildResults)) {
yield addPRComment(summaryTable);
} }
(0, cache_reporting_1.logCachingReport)(cacheListener);
}); });
} }
exports.logJobSummary = logJobSummary; exports.generateJobSummary = generateJobSummary;
function writeSummaryTable(results) { function addPRComment(jobSummary) {
core.summary.addHeading('Gradle Builds', 3); return __awaiter(this, void 0, void 0, function* () {
core.summary.addRaw(` const context = github.context;
if (context.payload.pull_request == null) {
core.info('No pull_request trigger: not adding PR comment');
return;
}
const pull_request_number = context.payload.pull_request.number;
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
const prComment = `<h3>Job Summary for gradle-build-action</h3>
<h5>${github.context.workflow} :: <em>${github.context.job}</em></h5>
${jobSummary}`;
const github_token = params.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 }));
}
catch (error) {
if (error instanceof request_error_1.RequestError) {
core.warning(buildWarningMessage(error));
}
else {
throw error;
}
}
});
}
function buildWarningMessage(error) {
const mainWarning = `Failed to generate PR comment.\n${String(error)}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'pull-requests: write' permission is available for the workflow job.
Note that this permission is never available for a workflow triggered from a repository fork.
`;
}
return mainWarning;
}
function renderSummaryTable(results) {
if (results.length === 0) {
return 'No Gradle build results detected.';
}
return `
<table> <table>
<tr> <tr>
<th>Root Project</th> <th>Gradle Root Project</th>
<th>Requested Tasks</th> <th>Requested Tasks</th>
<th>Gradle Version</th> <th>Gradle Version</th>
<th>Build Outcome</th> <th>Build Outcome</th>
<th>Build Scan®</th> <th>Build Scan®</th>
</tr>${results.map(result => renderBuildResultRow(result)).join('')} </tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table> </table>
`); `;
} }
function renderBuildResultRow(result) { function renderBuildResultRow(result) {
return ` return `
@ -140585,16 +140646,28 @@ function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`; const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`; return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`;
} }
function logSummaryTable(results) { function shouldGenerateJobSummary(buildResults) {
core.info('============================'); if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
core.info('Gradle Builds'); return false;
core.info('----------------------------'); }
core.info('Root Project | Requested Tasks | Gradle Version | Build Outcome | Build Scan®'); if (!params.isJobSummaryEnabled()) {
core.info('----------------------------'); return false;
for (const result of results) { }
core.info(`${result.rootProjectName} | ${result.requestedTasks} | ${result.gradleVersion} | ${result.buildFailed ? 'FAILED' : 'SUCCESS'} | ${result.buildScanFailed ? 'Publish failed' : result.buildScanUri}`); return shouldAddJobSummary(params.getJobSummaryOption(), buildResults);
}
function shouldAddPRComment(buildResults) {
return shouldAddJobSummary(params.getPRCommentOption(), buildResults);
}
function shouldAddJobSummary(option, buildResults) {
switch (option) {
case params.JobSummaryOption.Always:
return true;
case params.JobSummaryOption.Never:
return false;
case params.JobSummaryOption.OnFailure:
core.info(`Got these build results: ${JSON.stringify(buildResults)}`);
return buildResults.some(result => result.buildFailed);
} }
core.info('============================');
} }
@ -140990,14 +141063,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.complete = exports.setup = void 0; exports.complete = exports.setup = void 0;
const core = __importStar(__nccwpck_require__(42186)); const core = __importStar(__nccwpck_require__(42186));
const exec = __importStar(__nccwpck_require__(71514)); const exec = __importStar(__nccwpck_require__(71514));
const summary_1 = __nccwpck_require__(81327);
const path = __importStar(__nccwpck_require__(71017)); const path = __importStar(__nccwpck_require__(71017));
const os = __importStar(__nccwpck_require__(22037)); const os = __importStar(__nccwpck_require__(22037));
const caches = __importStar(__nccwpck_require__(23800)); const caches = __importStar(__nccwpck_require__(23800));
const layout = __importStar(__nccwpck_require__(28182)); const layout = __importStar(__nccwpck_require__(28182));
const params = __importStar(__nccwpck_require__(23885)); const params = __importStar(__nccwpck_require__(23885));
const dependencyGraph = __importStar(__nccwpck_require__(80)); const dependencyGraph = __importStar(__nccwpck_require__(80));
const job_summary_1 = __nccwpck_require__(87345); const jobSummary = __importStar(__nccwpck_require__(87345));
const build_results_1 = __nccwpck_require__(82107); const build_results_1 = __nccwpck_require__(82107);
const cache_reporting_1 = __nccwpck_require__(66674); const cache_reporting_1 = __nccwpck_require__(66674);
const daemon_controller_1 = __nccwpck_require__(85146); const daemon_controller_1 = __nccwpck_require__(85146);
@ -141033,12 +141105,7 @@ function complete() {
const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER)); const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER));
const daemonController = new daemon_controller_1.DaemonController(buildResults); const daemonController = new daemon_controller_1.DaemonController(buildResults);
yield caches.save(gradleUserHome, cacheListener, daemonController); yield caches.save(gradleUserHome, cacheListener, daemonController);
if (shouldGenerateJobSummary()) { yield jobSummary.generateJobSummary(buildResults, cacheListener);
yield (0, job_summary_1.writeJobSummary)(buildResults, cacheListener);
}
else {
(0, job_summary_1.logJobSummary)(buildResults, cacheListener);
}
yield dependencyGraph.complete(params.getDependencyGraphOption()); yield dependencyGraph.complete(params.getDependencyGraphOption());
core.info('Completed post-action step'); core.info('Completed post-action step');
}); });
@ -141068,12 +141135,6 @@ function determineUserHome() {
return userHome; return userHome;
}); });
} }
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return params.isJobSummaryEnabled();
}
/***/ }), /***/ }),

File diff suppressed because one or more lines are too long

223
dist/post/index.js vendored
View file

@ -136737,8 +136737,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.logCachingReport = exports.writeCachingReport = exports.CacheEntryListener = exports.CacheListener = void 0; exports.generateCachingReport = exports.CacheEntryListener = exports.CacheListener = void 0;
const core = __importStar(__nccwpck_require__(42186));
const cache = __importStar(__nccwpck_require__(27799)); const cache = __importStar(__nccwpck_require__(27799));
class CacheListener { class CacheListener {
constructor() { constructor() {
@ -136826,37 +136825,36 @@ class CacheEntryListener {
} }
} }
exports.CacheEntryListener = CacheEntryListener; exports.CacheEntryListener = CacheEntryListener;
function writeCachingReport(listener) { function generateCachingReport(listener) {
const entries = listener.cacheEntries; const entries = listener.cacheEntries;
core.summary.addRaw(`\n<details><summary><h4>Caching for gradle-build-action was ${listener.cacheStatus} - expand for details</h4></summary>\n`); return `
core.summary.addTable([ <details>
[ <summary><h4>Caching for gradle-build-action was ${listener.cacheStatus} - expand for details</h4></summary>
{ data: '', header: true }, ${renderEntryTable(entries)}
{ data: 'Count', header: true },
{ data: 'Total Size (Mb)', header: true } <h5>Cache Entry Details</h5>
], <pre>
['Entries Restored', `${getCount(entries, e => e.restoredSize)}`, `${getSize(entries, e => e.restoredSize)}`], ${renderEntryDetails(listener)}
['Entries Saved', `${getCount(entries, e => e.savedSize)}`, `${getSize(entries, e => e.savedSize)}`]
]);
core.summary.addHeading('Cache Entry Details', 5);
const entryDetails = renderEntryDetails(listener);
core.summary.addRaw(`<pre>
${entryDetails}
</pre> </pre>
</details> </details>
`); `;
} }
exports.writeCachingReport = writeCachingReport; exports.generateCachingReport = generateCachingReport;
function logCachingReport(listener) { function renderEntryTable(entries) {
const entries = listener.cacheEntries; return `
core.startGroup(`Caching for gradle-build-action was ${listener.cacheStatus} - expand for details`); <table>
core.info(`Entries Restored: ${getCount(entries, e => e.restoredSize)} (${getSize(entries, e => e.restoredSize)} Mb)`); <tr><td></td><th>Count</th><th>Total Size (Mb)</th></tr>
core.info(`Entries Saved : ${getCount(entries, e => e.savedSize)} (${getSize(entries, e => e.savedSize)} Mb)`); <tr><td>Entries Restored</td>
core.info(`Cache Entry Details`); <td>${getCount(entries, e => e.restoredSize)}</td>
core.info(renderEntryDetails(listener)); <td>${getSize(entries, e => e.restoredSize)}</td>
core.endGroup(); </tr>
<tr><td>Entries Saved</td>
<td>${getCount(entries, e => e.savedSize)}</td>
<td>${getSize(entries, e => e.savedSize)}</td>
</tr>
</table>
`;
} }
exports.logCachingReport = logCachingReport;
function renderEntryDetails(listener) { function renderEntryDetails(listener) {
return listener.cacheEntries return listener.cacheEntries
.map(entry => { .map(entry => {
@ -137665,7 +137663,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0; exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphOption = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(42186)); const core = __importStar(__nccwpck_require__(42186));
const string_argv_1 = __nccwpck_require__(19663); const string_argv_1 = __nccwpck_require__(19663);
function isCacheDisabled() { function isCacheDisabled() {
@ -137737,10 +137735,26 @@ function isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true); return getBooleanInput('generate-job-summary', true);
} }
exports.isJobSummaryEnabled = isJobSummaryEnabled; exports.isJobSummaryEnabled = isJobSummaryEnabled;
function isDependencyGraphEnabled() { function getJobSummaryOption() {
return getBooleanInput('generate-dependency-graph', true); return parseJobSummaryOption('add-job-summary');
}
exports.getJobSummaryOption = getJobSummaryOption;
function getPRCommentOption() {
return parseJobSummaryOption('add-job-summary-as-pr-comment');
}
exports.getPRCommentOption = getPRCommentOption;
function 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.isDependencyGraphEnabled = isDependencyGraphEnabled;
function getDependencyGraphOption() { function getDependencyGraphOption() {
const val = core.getInput('dependency-graph'); const val = core.getInput('dependency-graph');
switch (val.toLowerCase().trim()) { switch (val.toLowerCase().trim()) {
@ -137755,7 +137769,7 @@ function getDependencyGraphOption() {
case 'download-and-submit': case 'download-and-submit':
return DependencyGraphOption.DownloadAndSubmit; return DependencyGraphOption.DownloadAndSubmit;
} }
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]. The default value is 'disabled'.`); 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]. The default value is 'disabled'.`);
} }
exports.getDependencyGraphOption = getDependencyGraphOption; exports.getDependencyGraphOption = getDependencyGraphOption;
function getArtifactRetentionDays() { function getArtifactRetentionDays() {
@ -137794,6 +137808,12 @@ var DependencyGraphOption;
DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload"; DependencyGraphOption["GenerateAndUpload"] = "generate-and-upload";
DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit"; DependencyGraphOption["DownloadAndSubmit"] = "download-and-submit";
})(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {})); })(DependencyGraphOption || (exports.DependencyGraphOption = DependencyGraphOption = {}));
var JobSummaryOption;
(function (JobSummaryOption) {
JobSummaryOption["Never"] = "never";
JobSummaryOption["Always"] = "always";
JobSummaryOption["OnFailure"] = "on-failure";
})(JobSummaryOption || (exports.JobSummaryOption = JobSummaryOption = {}));
/***/ }), /***/ }),
@ -137836,48 +137856,89 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.logJobSummary = exports.writeJobSummary = void 0; exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186)); const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const summary_1 = __nccwpck_require__(81327);
const request_error_1 = __nccwpck_require__(10537);
const params = __importStar(__nccwpck_require__(23885));
const cache_reporting_1 = __nccwpck_require__(66674); const cache_reporting_1 = __nccwpck_require__(66674);
function writeJobSummary(buildResults, cacheListener) { function generateJobSummary(buildResults, cacheListener) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info('Writing job summary'); const summaryTable = renderSummaryTable(buildResults);
if (buildResults.length === 0) { const cachingReport = (0, cache_reporting_1.generateCachingReport)(cacheListener);
core.debug('No Gradle build results found. Summary table will not be generated.'); if (shouldGenerateJobSummary(buildResults)) {
} core.info('Generating Job Summary');
else { core.summary.addRaw(summaryTable);
writeSummaryTable(buildResults); core.summary.addRaw(cachingReport);
}
(0, cache_reporting_1.writeCachingReport)(cacheListener);
yield core.summary.write(); yield core.summary.write();
});
}
exports.writeJobSummary = writeJobSummary;
function logJobSummary(buildResults, cacheListener) {
return __awaiter(this, void 0, void 0, function* () {
if (buildResults.length === 0) {
core.debug('No Gradle build results found. Summary table will not be logged.');
} }
else { else {
logSummaryTable(buildResults); core.info('============================');
core.info(summaryTable);
core.info('============================');
core.info(cachingReport);
core.info('============================');
}
if (shouldAddPRComment(buildResults)) {
yield addPRComment(summaryTable);
} }
(0, cache_reporting_1.logCachingReport)(cacheListener);
}); });
} }
exports.logJobSummary = logJobSummary; exports.generateJobSummary = generateJobSummary;
function writeSummaryTable(results) { function addPRComment(jobSummary) {
core.summary.addHeading('Gradle Builds', 3); return __awaiter(this, void 0, void 0, function* () {
core.summary.addRaw(` const context = github.context;
if (context.payload.pull_request == null) {
core.info('No pull_request trigger: not adding PR comment');
return;
}
const pull_request_number = context.payload.pull_request.number;
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
const prComment = `<h3>Job Summary for gradle-build-action</h3>
<h5>${github.context.workflow} :: <em>${github.context.job}</em></h5>
${jobSummary}`;
const github_token = params.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 }));
}
catch (error) {
if (error instanceof request_error_1.RequestError) {
core.warning(buildWarningMessage(error));
}
else {
throw error;
}
}
});
}
function buildWarningMessage(error) {
const mainWarning = `Failed to generate PR comment.\n${String(error)}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'pull-requests: write' permission is available for the workflow job.
Note that this permission is never available for a workflow triggered from a repository fork.
`;
}
return mainWarning;
}
function renderSummaryTable(results) {
if (results.length === 0) {
return 'No Gradle build results detected.';
}
return `
<table> <table>
<tr> <tr>
<th>Root Project</th> <th>Gradle Root Project</th>
<th>Requested Tasks</th> <th>Requested Tasks</th>
<th>Gradle Version</th> <th>Gradle Version</th>
<th>Build Outcome</th> <th>Build Outcome</th>
<th>Build Scan®</th> <th>Build Scan®</th>
</tr>${results.map(result => renderBuildResultRow(result)).join('')} </tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table> </table>
`); `;
} }
function renderBuildResultRow(result) { function renderBuildResultRow(result) {
return ` return `
@ -137906,16 +137967,28 @@ function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`; const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`; return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`;
} }
function logSummaryTable(results) { function shouldGenerateJobSummary(buildResults) {
core.info('============================'); if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
core.info('Gradle Builds'); return false;
core.info('----------------------------'); }
core.info('Root Project | Requested Tasks | Gradle Version | Build Outcome | Build Scan®'); if (!params.isJobSummaryEnabled()) {
core.info('----------------------------'); return false;
for (const result of results) { }
core.info(`${result.rootProjectName} | ${result.requestedTasks} | ${result.gradleVersion} | ${result.buildFailed ? 'FAILED' : 'SUCCESS'} | ${result.buildScanFailed ? 'Publish failed' : result.buildScanUri}`); return shouldAddJobSummary(params.getJobSummaryOption(), buildResults);
}
function shouldAddPRComment(buildResults) {
return shouldAddJobSummary(params.getPRCommentOption(), buildResults);
}
function shouldAddJobSummary(option, buildResults) {
switch (option) {
case params.JobSummaryOption.Always:
return true;
case params.JobSummaryOption.Never:
return false;
case params.JobSummaryOption.OnFailure:
core.info(`Got these build results: ${JSON.stringify(buildResults)}`);
return buildResults.some(result => result.buildFailed);
} }
core.info('============================');
} }
@ -138075,14 +138148,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.complete = exports.setup = void 0; exports.complete = exports.setup = void 0;
const core = __importStar(__nccwpck_require__(42186)); const core = __importStar(__nccwpck_require__(42186));
const exec = __importStar(__nccwpck_require__(71514)); const exec = __importStar(__nccwpck_require__(71514));
const summary_1 = __nccwpck_require__(81327);
const path = __importStar(__nccwpck_require__(71017)); const path = __importStar(__nccwpck_require__(71017));
const os = __importStar(__nccwpck_require__(22037)); const os = __importStar(__nccwpck_require__(22037));
const caches = __importStar(__nccwpck_require__(23800)); const caches = __importStar(__nccwpck_require__(23800));
const layout = __importStar(__nccwpck_require__(28182)); const layout = __importStar(__nccwpck_require__(28182));
const params = __importStar(__nccwpck_require__(23885)); const params = __importStar(__nccwpck_require__(23885));
const dependencyGraph = __importStar(__nccwpck_require__(80)); const dependencyGraph = __importStar(__nccwpck_require__(80));
const job_summary_1 = __nccwpck_require__(87345); const jobSummary = __importStar(__nccwpck_require__(87345));
const build_results_1 = __nccwpck_require__(82107); const build_results_1 = __nccwpck_require__(82107);
const cache_reporting_1 = __nccwpck_require__(66674); const cache_reporting_1 = __nccwpck_require__(66674);
const daemon_controller_1 = __nccwpck_require__(85146); const daemon_controller_1 = __nccwpck_require__(85146);
@ -138118,12 +138190,7 @@ function complete() {
const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER)); const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER));
const daemonController = new daemon_controller_1.DaemonController(buildResults); const daemonController = new daemon_controller_1.DaemonController(buildResults);
yield caches.save(gradleUserHome, cacheListener, daemonController); yield caches.save(gradleUserHome, cacheListener, daemonController);
if (shouldGenerateJobSummary()) { yield jobSummary.generateJobSummary(buildResults, cacheListener);
yield (0, job_summary_1.writeJobSummary)(buildResults, cacheListener);
}
else {
(0, job_summary_1.logJobSummary)(buildResults, cacheListener);
}
yield dependencyGraph.complete(params.getDependencyGraphOption()); yield dependencyGraph.complete(params.getDependencyGraphOption());
core.info('Completed post-action step'); core.info('Completed post-action step');
}); });
@ -138153,12 +138220,6 @@ function determineUserHome() {
return userHome; return userHome;
}); });
} }
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return params.isJobSummaryEnabled();
}
/***/ }), /***/ }),

File diff suppressed because one or more lines are too long