mirror of
https://github.com/gradle/actions.git
synced 2025-12-08 17:15:46 +08:00
Only fetch checksums for unknown wrapper versions (#292)
The checksum values for most wrapper versions are hard-coded into the action. These known checksum values are first used for validation: only if none of the known values work do we download checksums. Previously, we blindly downloaded all of the checksum values in this case: we now only download the checksums for versions that are not in our "known" set. Fixes #171
This commit is contained in:
@@ -8,7 +8,7 @@ export async function findInvalidWrapperJars(
|
||||
minWrapperCount: number,
|
||||
allowSnapshots: boolean,
|
||||
allowedChecksums: string[],
|
||||
knownValidChecksums: Map<string, Set<string>> = checksums.KNOWN_VALID_CHECKSUMS
|
||||
knownValidChecksums: checksums.WrapperChecksums = checksums.KNOWN_CHECKSUMS
|
||||
): Promise<ValidationResult> {
|
||||
const wrapperJars = await find.findWrapperJars(gitRepoRoot)
|
||||
const result = new ValidationResult([], [])
|
||||
@@ -21,7 +21,7 @@ export async function findInvalidWrapperJars(
|
||||
const notYetValidatedWrappers = []
|
||||
for (const wrapperJar of wrapperJars) {
|
||||
const sha = await hash.sha256File(resolve(gitRepoRoot, wrapperJar))
|
||||
if (allowedChecksums.includes(sha) || knownValidChecksums.has(sha)) {
|
||||
if (allowedChecksums.includes(sha) || knownValidChecksums.checksums.has(sha)) {
|
||||
result.valid.push(new WrapperJar(wrapperJar, sha))
|
||||
} else {
|
||||
notYetValidatedWrappers.push(new WrapperJar(wrapperJar, sha))
|
||||
@@ -31,7 +31,7 @@ export async function findInvalidWrapperJars(
|
||||
// Otherwise fall back to fetching checksums from Gradle API and compare against them
|
||||
if (notYetValidatedWrappers.length > 0) {
|
||||
result.fetchedChecksums = true
|
||||
const fetchedValidChecksums = await checksums.fetchValidChecksums(allowSnapshots)
|
||||
const fetchedValidChecksums = await checksums.fetchUnknownChecksums(allowSnapshots, knownValidChecksums)
|
||||
|
||||
for (const wrapperJar of notYetValidatedWrappers) {
|
||||
if (!fetchedValidChecksums.has(wrapperJar.checksum)) {
|
||||
|
||||
Reference in New Issue
Block a user