mirror of
https://github.com/gradle/actions
synced 2024-11-27 11:52:24 +00:00
Emit deprecation warning for 'gradle-build-action'
This commit is contained in:
parent
7e9e469530
commit
aeb3156e6f
6 changed files with 64 additions and 25 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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,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>
|
||||
|
|
|
@ -3,14 +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 '../configuration'
|
||||
import {saveDeprecationState} from '../deprecation-collector'
|
||||
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())
|
||||
|
||||
|
|
Loading…
Reference in a new issue