Unverified Commit aeb3156e authored by daz's avatar daz
Browse files

Emit deprecation warning for 'gradle-build-action'

parent 7e9e4695
Loading
Loading
Loading
Loading
+28 −18
Changes for docs/deprecation-upgrade-guide.md: 28 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,23 @@ 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
@@ -32,6 +49,12 @@ steps:
   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.
@@ -45,6 +68,10 @@ Then replace this with a single call to `setup-gradle` together with separate `r

- 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
@@ -52,24 +79,7 @@ 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-gradle-build-action-has-been-replaced-by-the-setup-gradle-action) for more details on how to migrate.

### The `gradle-build-action` has been replaced by the `setup-gradle` action

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
```
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

+10
Changes for sources/src/configuration.ts: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ 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')
@@ -272,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
+4 −1
Changes for sources/src/dependency-submission/main.ts: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -10,7 +10,8 @@ import {
    CacheConfig,
    DependencyGraphConfig,
    DependencyGraphOption,
    GradleExecutionConfig
    GradleExecutionConfig,
    setActionId
} from '../configuration'
import {saveDeprecationState} from '../deprecation-collector'

@@ -19,6 +20,8 @@ import {saveDeprecationState} from '../deprecation-collector'
 */
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())

+2 −2
Changes for sources/src/deprecation-collector.ts: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
import * as core from '@actions/core'
import * as github from '@actions/github'
import {getActionId} from './configuration'

const DEPRECATION_UPGRADE_PAGE = 'https://github.com/gradle/actions/blob/main/docs/deprecation-upgrade-guide.md'
const recordedDeprecations: Deprecation[] = []
@@ -29,7 +29,7 @@ export function getDeprecations(): Deprecation[] {
export function emitDeprecationWarnings(): void {
    if (recordedDeprecations.length > 0) {
        core.warning(
            `This job uses deprecated functionality from the '${github.context.action}' action. Consult the Job Summary for more details.`
            `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()}`)
+3 −2
Changes for sources/src/job-summary.ts: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import * as github from '@actions/github'
import {RequestError} from '@octokit/request-error'

import {BuildResult} from './build-results'
import {SummaryConfig, getGithubToken} from './configuration'
import {SummaryConfig, getActionId, getGithubToken} from './configuration'
import {Deprecation, getDeprecations} from './deprecation-collector'

export async function generateJobSummary(
@@ -88,7 +88,8 @@ function renderDeprecations(): string {
        return ''
    }
    return `
<h4>Deprecated usages of ${github.context.action}</h4>
<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>
Loading