mirror of
https://github.com/gradle/actions.git
synced 2026-08-29 19:28:23 +08:00
Provide information about outdated Gradle versions in the job summary
This commit is contained in:
@@ -28,6 +28,13 @@ export function getSupportStatus(version: GradleVersion, latestMajor: number): S
|
||||
}
|
||||
}
|
||||
|
||||
export function supportStatusOf(gradleVersion: string): SupportStatus | undefined {
|
||||
if (LATEST_RELEASED_MAJOR === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return getSupportStatus(new GradleVersion(gradleVersion), LATEST_RELEASED_MAJOR)
|
||||
}
|
||||
|
||||
export function reportSupportStatus(gradleVersions: string[]): void {
|
||||
if (LATEST_RELEASED_MAJOR === undefined) {
|
||||
return
|
||||
|
||||
@@ -6,6 +6,9 @@ import {CacheReport} from './cache-service'
|
||||
import {ProviderNote, renderCachingReport} from './caching-report'
|
||||
import {DependencyGraphConfig, getActionId, getGithubToken, getJobMatrix, SummaryConfig} from './configuration'
|
||||
import {Deprecation, getDeprecations, getErrors} from './deprecation-collector'
|
||||
import {supportStatusOf} from './gradle-support-status'
|
||||
|
||||
const FEATURE_LIFECYCLE_DOC = 'https://docs.gradle.org/current/userguide/feature_lifecycle.html#eol_support'
|
||||
|
||||
export async function generateJobSummary(
|
||||
buildResults: BuildResult[],
|
||||
@@ -97,7 +100,7 @@ Note that this permission is never available for a workflow triggered from a rep
|
||||
}
|
||||
|
||||
export function renderSummaryTable(results: BuildResult[]): string {
|
||||
return `${renderDeprecations()}\n${renderBuildResults(results)}`
|
||||
return `${renderDeprecations()}\n${renderBuildResults(results)}\n${renderOutdatedVersions(results)}`
|
||||
}
|
||||
|
||||
function renderActionHeading(): string {
|
||||
@@ -147,8 +150,7 @@ function renderBuildResults(results: BuildResult[]): string {
|
||||
<th>Build Outcome</th>
|
||||
<th>Build Scan®</th>
|
||||
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
|
||||
</table>
|
||||
`
|
||||
</table>`
|
||||
}
|
||||
|
||||
function anyFailed(results: BuildResult[]): boolean {
|
||||
@@ -160,12 +162,47 @@ function renderBuildResultRow(result: BuildResult): string {
|
||||
<tr>
|
||||
<td>${truncateString(result.rootProjectName, 30)}</td>
|
||||
<td>${truncateString(result.requestedTasks, 60)}</td>
|
||||
<td align='center'>${result.gradleVersion}</td>
|
||||
<td align='center'>${renderGradleVersion(result.gradleVersion)}</td>
|
||||
<td align='center'>${renderOutcome(result)}</td>
|
||||
<td>${renderBuildScan(result)}</td>
|
||||
</tr>`
|
||||
}
|
||||
|
||||
function renderGradleVersion(gradleVersion: string): string {
|
||||
switch (supportStatusOf(gradleVersion)) {
|
||||
case 'eol':
|
||||
return `${gradleVersion} <span title="End-of-life: no longer receives bug fixes or security fixes">:warning:</span>`
|
||||
case 'maintenance':
|
||||
return `${gradleVersion} <span title="Maintenance only: receives critical bug fixes and security fixes only">:information_source:</span>`
|
||||
default:
|
||||
return gradleVersion
|
||||
}
|
||||
}
|
||||
|
||||
function renderOutdatedVersions(results: BuildResult[]): string {
|
||||
const hasOutdatedVersion = results
|
||||
.map(result => supportStatusOf(result.gradleVersion))
|
||||
.some(status => status === 'eol' || status === 'maintenance')
|
||||
if (!hasOutdatedVersion) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return `
|
||||
<h4>:warning: This Job uses an outdated Gradle version</h4>
|
||||
<details>
|
||||
<summary>Gradle release end-of-life policy</summary>
|
||||
<p>For major versions, Gradle will backport critical fixes and security fixes to the last minor in the
|
||||
previous major version. As such, each major Gradle release causes:</p>
|
||||
<ul>
|
||||
<li>The previous major version becomes maintenance only. It will only receive critical bug fixes
|
||||
and security fixes.</li>
|
||||
<li>The major version before the previous one to become end-of-life (EOL), and that release line
|
||||
will not receive any new fixes.</li>
|
||||
</ul>
|
||||
<a href="${FEATURE_LIFECYCLE_DOC}" target="_blank">Gradle feature lifecycle</a>
|
||||
</details>`
|
||||
}
|
||||
|
||||
function renderOutcome(result: BuildResult): string {
|
||||
return result.buildFailed ? ':x:' : ':white_check_mark:'
|
||||
}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
import dedent from 'dedent'
|
||||
import * as github from '@actions/github'
|
||||
import {afterEach, describe, expect, it} from '@jest/globals'
|
||||
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals'
|
||||
|
||||
import {BuildResult} from '../../src/build-results'
|
||||
import {jobMarker, renderSummaryTable} from '../../src/job-summary'
|
||||
import {SupportStatus} from '../../src/gradle-support-status'
|
||||
|
||||
const mockSupportStatusOf = jest.fn<(gradleVersion: string) => SupportStatus | undefined>()
|
||||
jest.unstable_mockModule('../../src/gradle-support-status', () => ({
|
||||
supportStatusOf: mockSupportStatusOf
|
||||
}))
|
||||
|
||||
const {jobMarker, renderSummaryTable} = await import('../../src/job-summary')
|
||||
|
||||
beforeEach(() => {
|
||||
mockSupportStatusOf.mockReturnValue('active')
|
||||
})
|
||||
|
||||
const MATRIX_INPUT_ENV = 'INPUT_WORKFLOW-JOB-CONTEXT'
|
||||
|
||||
@@ -185,6 +196,53 @@ describe('renderSummaryTable', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('Gradle version support status', () => {
|
||||
it('marks an outdated version and adds a details section', () => {
|
||||
mockSupportStatusOf.mockReturnValue('eol')
|
||||
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 Scan®</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td>help</td>
|
||||
<td align='center'>8.0 <span title="End-of-life: no longer receives bug fixes or security fixes">:warning:</span></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>
|
||||
|
||||
<h4>:warning: This Job uses an outdated Gradle version</h4>
|
||||
<details>
|
||||
<summary>Gradle release end-of-life policy</summary>
|
||||
<p>For major versions, Gradle will backport critical fixes and security fixes to the last minor in the
|
||||
previous major version. As such, each major Gradle release causes:</p>
|
||||
<ul>
|
||||
<li>The previous major version becomes maintenance only. It will only receive critical bug fixes
|
||||
and security fixes.</li>
|
||||
<li>The major version before the previous one to become end-of-life (EOL), and that release line
|
||||
will not receive any new fixes.</li>
|
||||
</ul>
|
||||
<a href="https://docs.gradle.org/current/userguide/feature_lifecycle.html#eol_support" target="_blank">Gradle feature lifecycle</a>
|
||||
</details>
|
||||
`);
|
||||
})
|
||||
it('marks a maintenance-only version', () => {
|
||||
mockSupportStatusOf.mockReturnValue('maintenance')
|
||||
const table = renderSummaryTable([successfulHelpBuild])
|
||||
expect(table).toContain(
|
||||
`<td align='center'>8.0 <span title="Maintenance only: receives critical bug fixes and security fixes only">:information_source:</span></td>`
|
||||
)
|
||||
expect(table).toContain('This Job uses an outdated Gradle version')
|
||||
})
|
||||
})
|
||||
|
||||
describe('jobMarker', () => {
|
||||
const original = process.env[MATRIX_INPUT_ENV]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user