mirror of
https://github.com/gradle/actions.git
synced 2025-11-26 17:09:10 +08:00
Move wrapper-validation into common setup code
This commit is contained in:
23
sources/src/wrapper-validation/wrapper-validator.ts
Normal file
23
sources/src/wrapper-validation/wrapper-validator.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as core from '@actions/core'
|
||||
import {WrapperValidationConfig} from '../configuration'
|
||||
import {findInvalidWrapperJars} from './validate'
|
||||
import {JobFailure} from '../errors'
|
||||
|
||||
export async function validateWrappers(config: WrapperValidationConfig, workspaceRoot: string): Promise<void> {
|
||||
if (!config.doValidateWrappers()) {
|
||||
return // Wrapper validation is disabled
|
||||
}
|
||||
|
||||
const allowedChecksums = process.env['ALLOWED_GRADLE_WRAPPER_CHECKSUMS']?.split(',') || []
|
||||
const result = await findInvalidWrapperJars(workspaceRoot, 0, config.allowSnapshotWrappers(), allowedChecksums)
|
||||
if (result.isValid()) {
|
||||
await core.group('All Gradle Wrapper jars are valid', async () => {
|
||||
core.info(result.toDisplayString())
|
||||
})
|
||||
} else {
|
||||
core.info(result.toDisplayString())
|
||||
throw new JobFailure(
|
||||
`Gradle Wrapper Validation Failed!\n See https://github.com/gradle/actions/blob/main/docs/wrapper-validation.md#reporting-failures\n${result.toDisplayString()}`
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user