Compare commits

...

13 Commits

Author SHA1 Message Date
bigdaz
db19848a5f [bot] Update dist directory 2024-04-25 20:24:26 +00:00
daz
941b289d84 Avoid running Gradle 3.5.1 on MacOS where Java 8 is not available 2024-04-25 21:23:15 +01:00
Daz DeBoer
bce7daca54 Improve build scan badge readability with long tasks (#200)
Improve readability of build scan when requested tasks is very long, as
agreed in #175. HTML diff for each case of job summary is clearer in
cd62d9c9ef.

- Ensure a minimum size for the badge, at least the size of "Build
scan®", by preventing a line break with ` `
- Reduce the size of the badge by tweaking the inner text

Also fix a typo in the build shell script.
2024-04-25 21:22:36 +01:00
daz
11eaed9738 Avoid Java 8 since it is not available on MacOS runners 2024-04-25 20:17:16 +01:00
Gabriel Feo
cd62d9c9ef Improve job summary readability with long tasks
Change tests for nbsp and concise badge

Make tests pass

Signed-off-by: Gabriel Feo <gabriel@gabrielfeo.com>
2024-04-25 19:40:04 +01:00
Gabriel Feo
a54fb6a5bb Add tests on current job-summary behavior
Signed-off-by: Gabriel Feo <gabriel@gabrielfeo.com>
2024-04-25 17:44:41 +01:00
Gabriel Feo
ef36f81b41 Fix typo in build shell script
Signed-off-by: Gabriel Feo <gabriel@gabrielfeo.com>
2024-04-25 17:42:29 +01:00
bigdaz
18998bc43e [bot] Update dist directory 2024-04-25 10:20:39 +00:00
daz
a772c14b33 Avoid updating real dependency graph in tests 2024-04-25 11:19:43 +01:00
daz
7763d71170 Set the report dir for download-and-submit
Fixes #196
2024-04-25 11:19:43 +01:00
bigdaz
9ab93ee864 [bot] Update dist directory 2024-04-19 16:25:39 +00:00
daz
d124ec149f Retain and log stacktrace for submission errors 2024-04-19 10:24:45 -06:00
Alex Serbin
6ccde15122 Use logger in dependency graph init script (#191)
Dependency graph init script now uses Gradle logger to emit warning/info messages.
This allows these messages to be suppressed using `--quiet`.
2024-04-19 07:03:17 -06:00
24 changed files with 410 additions and 86 deletions

View File

@@ -24,7 +24,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 11
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3 # Use a released version to avoid breakages
- name: Run integration tests

View File

@@ -34,7 +34,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 11
- name: Setup Gradle
id: setup-gradle
uses: ./setup-gradle

View File

@@ -18,6 +18,7 @@ permissions:
env:
SKIP_DIST: ${{ inputs.skip-dist }}
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: dependency-graph-${{ inputs.cache-key-prefix }}
GITHUB_DEPENDENCY_GRAPH_REF: 'refs/tags/v0.0.1' # Use a different ref to avoid updating the real dependency graph for the repository
jobs:
groovy-generate:

View File

@@ -15,6 +15,7 @@ on:
env:
SKIP_DIST: ${{ inputs.skip-dist }}
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: dependency-submission-failures-${{ inputs.cache-key-prefix }}
GITHUB_DEPENDENCY_GRAPH_REF: 'refs/tags/v0.0.1' # Use a different ref to avoid updating the real dependency graph for the repository
jobs:
failing-build:

View File

@@ -18,6 +18,7 @@ permissions:
env:
SKIP_DIST: ${{ inputs.skip-dist }}
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: dependency-submission-${{ inputs.cache-key-prefix }}
GITHUB_DEPENDENCY_GRAPH_REF: 'refs/tags/v0.0.1' # Use a different ref to avoid updating the real dependency graph for the repository
jobs:
groovy-generate-and-upload:
@@ -223,8 +224,6 @@ jobs:
with:
gradle-version: ${{ matrix.gradle }}
build-root-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}
env:
GITHUB_DEPENDENCY_GRAPH_REF: 'refs/tags/v0.0.1' # Use a different ref to avoid updating the real dependency graph for the repository
after-setup-gradle:
strategy:

View File

@@ -61,12 +61,17 @@ jobs:
gradle: [7.5.1, 6.9.2, 5.6.4, 4.10.3, 3.5.1]
os: ${{fromJSON(inputs.runner-os)}}
include:
- java-version: 11
- gradle: 5.6.4
build-root-suffix: -gradle-5
- gradle: 4.10.3
build-root-suffix: -gradle-4
- gradle: 3.5.1
build-root-suffix: -gradle-4
java-version: 8
exclude:
- os: macos-latest # Java 8 is not supported on macos-latest, so we cannot test Gradle 3.5.1
gradle: 3.5.1
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
@@ -78,7 +83,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: ${{ matrix.java-version }}
- name: Run Gradle build
uses: ./setup-gradle
id: gradle

View File

@@ -45,7 +45,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 11
- name: Setup Gradle
id: setup-gradle
uses: ./setup-gradle

View File

@@ -76,12 +76,17 @@ jobs:
gradle: [7.3, 6.9, 5.6.4, 4.10.3, 3.5.1]
os: ${{fromJSON(inputs.runner-os)}}
include:
- java-version: 11
- gradle: 5.6.4
build-root-suffix: -gradle-5
- gradle: 4.10.3
build-root-suffix: -gradle-4
- gradle: 3.5.1
build-root-suffix: -gradle-4
java-version: 8
exclude:
- os: macos-latest # Java 8 is not supported on macos-latest, so we cannot test Gradle 3.5.1
gradle: 3.5.1
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
@@ -93,7 +98,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: ${{ matrix.java-version }}
- name: Setup Gradle
id: setup-gradle
uses: ./setup-gradle

4
build
View File

@@ -5,7 +5,7 @@ cd sources
case "$1" in
all)
npm clean-install
nprm run all
npm run all
;;
act)
# Build and copy outputs to the dist directory
@@ -26,4 +26,4 @@ case "$1" in
npm install
npm run build
;;
esac
esac

View File

@@ -144686,6 +144686,7 @@ async function setup(config) {
return;
}
if (option === configuration_1.DependencyGraphOption.DownloadAndSubmit) {
maybeExportVariable('DEPENDENCY_GRAPH_REPORT_DIR', config.getReportDirectory());
await downloadAndSubmitDependencyGraphs(config);
return;
}
@@ -144779,17 +144780,15 @@ async function submitDependencyGraphs(dependencyGraphFiles) {
}
catch (error) {
if (error instanceof request_error_1.RequestError) {
throw new Error(translateErrorMessage(dependencyGraphFile, error));
}
else {
throw error;
error.message = translateErrorMessage(dependencyGraphFile, error);
}
throw error;
}
}
}
function translateErrorMessage(jsonFile, error) {
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${String(error)}`;
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${error.message}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'contents: write' permission is available for the workflow job.
@@ -145097,6 +145096,9 @@ function handleMainActionError(error) {
}
else if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.setFailed(String(error));
@@ -145109,6 +145111,9 @@ exports.handleMainActionError = handleMainActionError;
function handlePostActionError(error) {
if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`);
@@ -145460,7 +145465,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.generateJobSummary = void 0;
exports.renderSummaryTable = exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const request_error_1 = __nccwpck_require__(10537);
@@ -145532,6 +145537,7 @@ Note that this permission is never available for a workflow triggered from a rep
function renderSummaryTable(results) {
return `${renderDeprecations()}\n${renderBuildResults(results)}`;
}
exports.renderSummaryTable = renderSummaryTable;
function renderDeprecations() {
const deprecations = (0, deprecation_collector_1.getDeprecations)();
if (deprecations.length === 0) {
@@ -145560,7 +145566,7 @@ function renderBuildResults(results) {
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build Scan®</th>
<th>Build&nbsp;Scan®</th>
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table>
`;
@@ -145580,16 +145586,35 @@ function renderOutcome(result) {
}
function renderBuildScan(result) {
if (result.buildScanFailed) {
return renderBuildScanBadge('PUBLISH_FAILED', 'orange', 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting');
return renderBuildScanBadge({
text: 'Publish failed',
alt: 'Build Scan publish failed',
color: 'orange',
logo: false,
targetUrl: 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting'
});
}
if (result.buildScanUri) {
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri);
return renderBuildScanBadge({
text: 'Build Scan®',
alt: 'Build Scan published',
color: '06A0CE',
logo: true,
targetUrl: result.buildScanUri
});
}
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com');
return renderBuildScanBadge({
text: 'Not published',
alt: 'Build Scan not published',
color: 'lightgrey',
logo: false,
targetUrl: 'https://scans.gradle.com'
});
}
function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`;
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
function renderBuildScanBadge({ text, alt, color, logo, targetUrl }) {
const encodedText = encodeURIComponent(text);
const badgeUrl = `https://img.shields.io/badge/${encodedText}-${color}${logo ? '?logo=Gradle' : ''}`;
const badgeHtml = `<img src="${badgeUrl}" alt="${alt}" />`;
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`;
}
function truncateString(str, maxLength) {

File diff suppressed because one or more lines are too long

View File

@@ -96253,6 +96253,9 @@ function handleMainActionError(error) {
}
else if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.setFailed(String(error));
@@ -96265,6 +96268,9 @@ exports.handleMainActionError = handleMainActionError;
function handlePostActionError(error) {
if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`);
@@ -96307,7 +96313,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.generateJobSummary = void 0;
exports.renderSummaryTable = exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(2186));
const github = __importStar(__nccwpck_require__(5438));
const request_error_1 = __nccwpck_require__(537);
@@ -96379,6 +96385,7 @@ Note that this permission is never available for a workflow triggered from a rep
function renderSummaryTable(results) {
return `${renderDeprecations()}\n${renderBuildResults(results)}`;
}
exports.renderSummaryTable = renderSummaryTable;
function renderDeprecations() {
const deprecations = (0, deprecation_collector_1.getDeprecations)();
if (deprecations.length === 0) {
@@ -96407,7 +96414,7 @@ function renderBuildResults(results) {
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build Scan®</th>
<th>Build&nbsp;Scan®</th>
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table>
`;
@@ -96427,16 +96434,35 @@ function renderOutcome(result) {
}
function renderBuildScan(result) {
if (result.buildScanFailed) {
return renderBuildScanBadge('PUBLISH_FAILED', 'orange', 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting');
return renderBuildScanBadge({
text: 'Publish failed',
alt: 'Build Scan publish failed',
color: 'orange',
logo: false,
targetUrl: 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting'
});
}
if (result.buildScanUri) {
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri);
return renderBuildScanBadge({
text: 'Build Scan®',
alt: 'Build Scan published',
color: '06A0CE',
logo: true,
targetUrl: result.buildScanUri
});
}
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com');
return renderBuildScanBadge({
text: 'Not published',
alt: 'Build Scan not published',
color: 'lightgrey',
logo: false,
targetUrl: 'https://scans.gradle.com'
});
}
function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`;
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
function renderBuildScanBadge({ text, alt, color, logo, targetUrl }) {
const encodedText = encodeURIComponent(text);
const badgeUrl = `https://img.shields.io/badge/${encodedText}-${color}${logo ? '?logo=Gradle' : ''}`;
const badgeHtml = `<img src="${badgeUrl}" alt="${alt}" />`;
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`;
}
function truncateString(str, maxLength) {

File diff suppressed because one or more lines are too long

View File

@@ -144686,6 +144686,7 @@ async function setup(config) {
return;
}
if (option === configuration_1.DependencyGraphOption.DownloadAndSubmit) {
maybeExportVariable('DEPENDENCY_GRAPH_REPORT_DIR', config.getReportDirectory());
await downloadAndSubmitDependencyGraphs(config);
return;
}
@@ -144779,17 +144780,15 @@ async function submitDependencyGraphs(dependencyGraphFiles) {
}
catch (error) {
if (error instanceof request_error_1.RequestError) {
throw new Error(translateErrorMessage(dependencyGraphFile, error));
}
else {
throw error;
error.message = translateErrorMessage(dependencyGraphFile, error);
}
throw error;
}
}
}
function translateErrorMessage(jsonFile, error) {
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${String(error)}`;
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${error.message}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'contents: write' permission is available for the workflow job.
@@ -145025,6 +145024,9 @@ function handleMainActionError(error) {
}
else if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.setFailed(String(error));
@@ -145037,6 +145039,9 @@ exports.handleMainActionError = handleMainActionError;
function handlePostActionError(error) {
if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`);
@@ -145388,7 +145393,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.generateJobSummary = void 0;
exports.renderSummaryTable = exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const request_error_1 = __nccwpck_require__(10537);
@@ -145460,6 +145465,7 @@ Note that this permission is never available for a workflow triggered from a rep
function renderSummaryTable(results) {
return `${renderDeprecations()}\n${renderBuildResults(results)}`;
}
exports.renderSummaryTable = renderSummaryTable;
function renderDeprecations() {
const deprecations = (0, deprecation_collector_1.getDeprecations)();
if (deprecations.length === 0) {
@@ -145488,7 +145494,7 @@ function renderBuildResults(results) {
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build Scan®</th>
<th>Build&nbsp;Scan®</th>
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table>
`;
@@ -145508,16 +145514,35 @@ function renderOutcome(result) {
}
function renderBuildScan(result) {
if (result.buildScanFailed) {
return renderBuildScanBadge('PUBLISH_FAILED', 'orange', 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting');
return renderBuildScanBadge({
text: 'Publish failed',
alt: 'Build Scan publish failed',
color: 'orange',
logo: false,
targetUrl: 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting'
});
}
if (result.buildScanUri) {
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri);
return renderBuildScanBadge({
text: 'Build Scan®',
alt: 'Build Scan published',
color: '06A0CE',
logo: true,
targetUrl: result.buildScanUri
});
}
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com');
return renderBuildScanBadge({
text: 'Not published',
alt: 'Build Scan not published',
color: 'lightgrey',
logo: false,
targetUrl: 'https://scans.gradle.com'
});
}
function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`;
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
function renderBuildScanBadge({ text, alt, color, logo, targetUrl }) {
const encodedText = encodeURIComponent(text);
const badgeUrl = `https://img.shields.io/badge/${encodedText}-${color}${logo ? '?logo=Gradle' : ''}`;
const badgeHtml = `<img src="${badgeUrl}" alt="${alt}" />`;
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`;
}
function truncateString(str, maxLength) {

File diff suppressed because one or more lines are too long

View File

@@ -142139,6 +142139,7 @@ async function setup(config) {
return;
}
if (option === configuration_1.DependencyGraphOption.DownloadAndSubmit) {
maybeExportVariable('DEPENDENCY_GRAPH_REPORT_DIR', config.getReportDirectory());
await downloadAndSubmitDependencyGraphs(config);
return;
}
@@ -142232,17 +142233,15 @@ async function submitDependencyGraphs(dependencyGraphFiles) {
}
catch (error) {
if (error instanceof request_error_1.RequestError) {
throw new Error(translateErrorMessage(dependencyGraphFile, error));
}
else {
throw error;
error.message = translateErrorMessage(dependencyGraphFile, error);
}
throw error;
}
}
}
function translateErrorMessage(jsonFile, error) {
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${String(error)}`;
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${error.message}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'contents: write' permission is available for the workflow job.
@@ -142478,6 +142477,9 @@ function handleMainActionError(error) {
}
else if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.setFailed(String(error));
@@ -142490,6 +142492,9 @@ exports.handleMainActionError = handleMainActionError;
function handlePostActionError(error) {
if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`);
@@ -142532,7 +142537,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.generateJobSummary = void 0;
exports.renderSummaryTable = exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const request_error_1 = __nccwpck_require__(10537);
@@ -142604,6 +142609,7 @@ Note that this permission is never available for a workflow triggered from a rep
function renderSummaryTable(results) {
return `${renderDeprecations()}\n${renderBuildResults(results)}`;
}
exports.renderSummaryTable = renderSummaryTable;
function renderDeprecations() {
const deprecations = (0, deprecation_collector_1.getDeprecations)();
if (deprecations.length === 0) {
@@ -142632,7 +142638,7 @@ function renderBuildResults(results) {
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build Scan®</th>
<th>Build&nbsp;Scan®</th>
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table>
`;
@@ -142652,16 +142658,35 @@ function renderOutcome(result) {
}
function renderBuildScan(result) {
if (result.buildScanFailed) {
return renderBuildScanBadge('PUBLISH_FAILED', 'orange', 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting');
return renderBuildScanBadge({
text: 'Publish failed',
alt: 'Build Scan publish failed',
color: 'orange',
logo: false,
targetUrl: 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting'
});
}
if (result.buildScanUri) {
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri);
return renderBuildScanBadge({
text: 'Build Scan®',
alt: 'Build Scan published',
color: '06A0CE',
logo: true,
targetUrl: result.buildScanUri
});
}
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com');
return renderBuildScanBadge({
text: 'Not published',
alt: 'Build Scan not published',
color: 'lightgrey',
logo: false,
targetUrl: 'https://scans.gradle.com'
});
}
function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`;
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
function renderBuildScanBadge({ text, alt, color, logo, targetUrl }) {
const encodedText = encodeURIComponent(text);
const badgeUrl = `https://img.shields.io/badge/${encodedText}-${color}${logo ? '?logo=Gradle' : ''}`;
const badgeHtml = `<img src="${badgeUrl}" alt="${alt}" />`;
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`;
}
function truncateString(str, maxLength) {

File diff suppressed because one or more lines are too long

View File

@@ -90294,6 +90294,9 @@ function handleMainActionError(error) {
}
else if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.setFailed(String(error));
@@ -90306,6 +90309,9 @@ exports.handleMainActionError = handleMainActionError;
function handlePostActionError(error) {
if (error instanceof JobFailure) {
core.setFailed(String(error));
if (error.stack) {
core.info(error.stack);
}
}
else {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`);

File diff suppressed because one or more lines are too long

View File

@@ -22,6 +22,7 @@ export async function setup(config: DependencyGraphConfig): Promise<void> {
}
// Download and submit early, for compatability with dependency review.
if (option === DependencyGraphOption.DownloadAndSubmit) {
maybeExportVariable('DEPENDENCY_GRAPH_REPORT_DIR', config.getReportDirectory())
await downloadAndSubmitDependencyGraphs(config)
return
}
@@ -124,17 +125,16 @@ async function submitDependencyGraphs(dependencyGraphFiles: string[]): Promise<v
await submitDependencyGraphFile(dependencyGraphFile)
} catch (error) {
if (error instanceof RequestError) {
throw new Error(translateErrorMessage(dependencyGraphFile, error))
} else {
throw error
error.message = translateErrorMessage(dependencyGraphFile, error)
}
throw error
}
}
}
function translateErrorMessage(jsonFile: string, error: RequestError): string {
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile)
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${String(error)}`
const mainWarning = `Dependency submission failed for ${relativeJsonFile}.\n${error.message}`
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'contents: write' permission is available for the workflow job.

View File

@@ -22,7 +22,10 @@ export function handleMainActionError(error: unknown): void {
}
}
} else if (error instanceof JobFailure) {
core.setFailed(String(error)) // No stack trace for JobFailure: these are known errors
core.setFailed(String(error))
if (error.stack) {
core.info(error.stack)
}
} else {
core.setFailed(String(error))
if (error instanceof Error && error.stack) {
@@ -34,6 +37,9 @@ export function handleMainActionError(error: unknown): void {
export function handlePostActionError(error: unknown): void {
if (error instanceof JobFailure) {
core.setFailed(String(error))
if (error.stack) {
core.info(error.stack)
}
} else {
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`)
if (error instanceof Error && error.stack) {

View File

@@ -78,7 +78,7 @@ Note that this permission is never available for a workflow triggered from a rep
return mainWarning
}
function renderSummaryTable(results: BuildResult[]): string {
export function renderSummaryTable(results: BuildResult[]): string {
return `${renderDeprecations()}\n${renderBuildResults(results)}`
}
@@ -113,7 +113,7 @@ function renderBuildResults(results: BuildResult[]): string {
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build Scan®</th>
<th>Build&nbsp;Scan®</th>
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table>
`
@@ -134,23 +134,46 @@ function renderOutcome(result: BuildResult): string {
return result.buildFailed ? ':x:' : ':white_check_mark:'
}
function renderBuildScan(result: BuildResult): string {
if (result.buildScanFailed) {
return renderBuildScanBadge(
'PUBLISH_FAILED',
'orange',
'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting'
)
}
if (result.buildScanUri) {
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri)
}
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com')
interface BadgeSpec {
text: string
alt: string
color: string
logo: boolean
targetUrl: string
}
function renderBuildScanBadge(outcomeText: string, outcomeColor: string, targetUrl: string): string {
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`
function renderBuildScan(result: BuildResult): string {
if (result.buildScanFailed) {
return renderBuildScanBadge({
text: 'Publish failed',
alt: 'Build Scan publish failed',
color: 'orange',
logo: false,
targetUrl: 'https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting'
})
}
if (result.buildScanUri) {
return renderBuildScanBadge({
text: 'Build Scan®',
alt: 'Build Scan published',
color: '06A0CE',
logo: true,
targetUrl: result.buildScanUri
})
}
return renderBuildScanBadge({
text: 'Not published',
alt: 'Build Scan not published',
color: 'lightgrey',
logo: false,
targetUrl: 'https://scans.gradle.com'
})
}
function renderBuildScanBadge({text, alt, color, logo, targetUrl}: BadgeSpec): string {
const encodedText = encodeURIComponent(text)
const badgeUrl = `https://img.shields.io/badge/${encodedText}-${color}${logo ? '?logo=Gradle' : ''}`
const badgeHtml = `<img src="${badgeUrl}" alt="${alt}" />`
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`
}

View File

@@ -12,7 +12,7 @@ if (gradleVersion < GradleVersion.version("5.2") ||
if (getVariable('GITHUB_DEPENDENCY_GRAPH_CONTINUE_ON_FAILURE') != "true") {
throw new GradleException("Dependency Graph is not supported for ${gradleVersion}. No dependency snapshot will be generated.")
}
println "::warning::Dependency Graph is not supported for ${gradleVersion}. No dependency snapshot will be generated."
logger.warn("::warning::Dependency Graph is not supported for ${gradleVersion}. No dependency snapshot will be generated.")
return
}
@@ -23,11 +23,11 @@ if (isTopLevelBuild) {
def reportFile = getUniqueReportFile(getVariable('GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR'))
if (reportFile == null) {
println "::warning::No dependency snapshot generated for step. Could not determine unique job correlator - specify GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR var for this step."
logger.warn("::warning::No dependency snapshot generated for step. Could not determine unique job correlator - specify GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR var for this step.")
return
}
println "Generating dependency graph into '${reportFile}'"
logger.lifecycle("Generating dependency graph into '${reportFile}'")
}
apply from: 'gradle-actions.github-dependency-graph-gradle-plugin-apply.groovy'

View File

@@ -0,0 +1,177 @@
import { BuildResult } from '../../src/build-results'
import { renderSummaryTable } from '../../src/job-summary'
import dedent from 'dedent'
const successfulHelpBuild: BuildResult = {
rootProjectName: 'root',
rootProjectDir: '/',
requestedTasks: 'help',
gradleVersion: '8.0',
gradleHomeDir: '/opt/gradle',
buildFailed: false,
buildScanUri: 'https://scans.gradle.com/s/abc123',
buildScanFailed: false
}
const failedHelpBuild: BuildResult = {
...successfulHelpBuild,
buildFailed: true
}
const longArgsBuild: BuildResult = {
...successfulHelpBuild,
requestedTasks: 'check publishMyLongNamePluginPublicationToMavenCentral publishMyLongNamePluginPublicationToPluginPortal',
}
const scanPublishDisabledBuild: BuildResult = {
...successfulHelpBuild,
buildScanUri: '',
buildScanFailed: false,
}
const scanPublishFailedBuild: BuildResult = {
...successfulHelpBuild,
buildScanUri: '',
buildScanFailed: true,
}
describe('renderSummaryTable', () => {
describe('renders', () => {
it('successful build', () => {
const table = renderSummaryTable([successfulHelpBuild])
expect(table.trim()).toBe(dedent`
<table>
<tr>
<th>Gradle Root Project</th>
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build&nbsp;Scan®</th>
</tr>
<tr>
<td>root</td>
<td>help</td>
<td align='center'>8.0</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
</tr>
</table>
`);
})
it('failed build', () => {
const table = renderSummaryTable([failedHelpBuild])
expect(table.trim()).toBe(dedent`
<table>
<tr>
<th>Gradle Root Project</th>
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build&nbsp;Scan®</th>
</tr>
<tr>
<td>root</td>
<td>help</td>
<td align='center'>8.0</td>
<td align='center'>:x:</td>
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
</tr>
</table>
`);
})
describe('when build scan', () => {
it('publishing disabled', () => {
const table = renderSummaryTable([scanPublishDisabledBuild])
expect(table.trim()).toBe(dedent`
<table>
<tr>
<th>Gradle Root Project</th>
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build&nbsp;Scan®</th>
</tr>
<tr>
<td>root</td>
<td>help</td>
<td align='center'>8.0</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://scans.gradle.com" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Not%20published-lightgrey" alt="Build Scan not published" /></a></td>
</tr>
</table>
`);
})
it('publishing failed', () => {
const table = renderSummaryTable([scanPublishFailedBuild])
expect(table.trim()).toBe(dedent`
<table>
<tr>
<th>Gradle Root Project</th>
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build&nbsp;Scan®</th>
</tr>
<tr>
<td>root</td>
<td>help</td>
<td align='center'>8.0</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Publish%20failed-orange" alt="Build Scan publish failed" /></a></td>
</tr>
</table>
`);
})
})
it('multiple builds', () => {
const table = renderSummaryTable([successfulHelpBuild, failedHelpBuild])
expect(table.trim()).toBe(dedent`
<table>
<tr>
<th>Gradle Root Project</th>
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build&nbsp;Scan®</th>
</tr>
<tr>
<td>root</td>
<td>help</td>
<td align='center'>8.0</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
</tr>
<tr>
<td>root</td>
<td>help</td>
<td align='center'>8.0</td>
<td align='center'>:x:</td>
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
</tr>
</table>
`);
})
it('truncating long requested tasks', () => {
const table = renderSummaryTable([longArgsBuild])
expect(table.trim()).toBe(dedent`
<table>
<tr>
<th>Gradle Root Project</th>
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
<th>Build&nbsp;Scan®</th>
</tr>
<tr>
<td>root</td>
<td><div title='check publishMyLongNamePluginPublicationToMavenCentral publishMyLongNamePluginPublicationToPluginPortal'>check publishMyLongNamePluginPublicationToMavenCentral publ…</div></td>
<td align='center'>8.0</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
</tr>
</table>
`);
})
})
})