Remove deprecated input parameters

This commit is contained in:
daz
2024-07-19 14:56:50 -06:00
parent db8e69bc03
commit ded8009fcf
5 changed files with 24 additions and 81 deletions

View File

@@ -1,5 +1,5 @@
import * as setupGradle from '../../setup-gradle'
import * as gradle from '../../execution/gradle'
import * as provisioner from '../../execution/provision'
import * as dependencyGraph from '../../dependency-graph'
import {
BuildScanConfig,
@@ -19,6 +19,7 @@ import {handleMainActionError} from '../../errors'
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`'
)
@@ -38,11 +39,8 @@ export async function run(): Promise<void> {
await dependencyGraph.setup(new DependencyGraphConfig())
const config = new GradleExecutionConfig()
await gradle.provisionAndMaybeExecute(
config.getGradleVersion(),
config.getBuildRootDirectory(),
config.getArguments()
)
config.verifyNoArguments()
await provisioner.provisionGradle(config.getGradleVersion())
saveDeprecationState()
} catch (error) {

View File

@@ -4,7 +4,6 @@ import * as cache from '@actions/cache'
import * as deprecator from './deprecation-collector'
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'
@@ -173,11 +172,6 @@ export class SummaryConfig {
return false
}
// Check if Job Summary is disabled using the deprecated input
if (!this.isJobSummaryEnabled()) {
return false
}
return this.shouldAddJobSummary(this.getJobSummaryOption(), hasFailure)
}
@@ -196,10 +190,6 @@ export class SummaryConfig {
}
}
private isJobSummaryEnabled(): boolean {
return getBooleanInput('generate-job-summary', true)
}
private getJobSummaryOption(): JobSummaryOption {
return this.parseJobSummaryOption('add-job-summary')
}
@@ -239,11 +229,11 @@ export class BuildScanConfig {
}
getBuildScanTermsOfUseUrl(): string {
return this.getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url')
return core.getInput('build-scan-terms-of-use-url')
}
getBuildScanTermsOfUseAgree(): string {
return this.getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree')
return core.getInput('build-scan-terms-of-use-agree')
}
getDevelocityAccessKey(): string {
@@ -312,22 +302,6 @@ export class BuildScanConfig {
}
return true
}
/**
* TODO @bigdaz: remove support for the deprecated input property in the next major release of the action
*/
private getTermsOfUseProp(newPropName: string, oldPropName: string): string {
const newProp = core.getInput(newPropName)
if (newProp !== '') {
return newProp
}
const oldProp = core.getInput(oldPropName)
if (oldProp !== '') {
deprecator.recordDeprecation('The `build-scan-terms-of-service` input parameters have been renamed')
return oldProp
}
return core.getInput(oldPropName)
}
}
export class GradleExecutionConfig {
@@ -345,16 +319,6 @@ export class GradleExecutionConfig {
return resolvedBuildRootDirectory
}
getArguments(): string[] {
const input = core.getInput('arguments')
if (input.length !== 0) {
deprecator.recordDeprecation(
'Using the action to execute Gradle via the `arguments` parameter is deprecated'
)
}
return parseArgsStringToArgv(input)
}
getDependencyResolutionTask(): string {
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies'
}
@@ -362,6 +326,16 @@ export class GradleExecutionConfig {
getAdditionalArguments(): string {
return core.getInput('additional-arguments')
}
verifyNoArguments(): void {
const input = core.getInput('arguments')
if (input.length !== 0) {
deprecator.failOnUseOfRemovedFeature(
`The 'arguments' parameter is no longer supported for ${getActionId()}`,
'Using the action to execute Gradle via the `arguments` parameter is deprecated'
)
}
}
}
export function doValidateWrappers(): boolean {

View File

@@ -22,6 +22,13 @@ export function recordDeprecation(message: string): void {
}
}
export function failOnUseOfRemovedFeature(removalMessage: string, deprecationMessage: string): void {
const deprecation = new Deprecation(deprecationMessage)
core.error(
`${removalMessage}. See ${deprecation.getDocumentationLink()}`
)
}
export function getDeprecations(): Deprecation[] {
return recordedDeprecations
}