-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache validated checksums for later executions
The most common case for validation will be that the wrapper jars are unchanged from a previous workflow run. In this case, we cache the validated wrapper checksums to minimise the work required on a subsequent run. Fixes #172
- Loading branch information
Showing
8 changed files
with
98 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import {ACTION_METADATA_DIR} from '../configuration' | ||
|
||
export class ChecksumCache { | ||
private readonly cacheFile: string | ||
|
||
constructor(gradleUserHome: string) { | ||
this.cacheFile = path.resolve(gradleUserHome, ACTION_METADATA_DIR, 'valid-wrappers.json') | ||
} | ||
|
||
load(): string[] { | ||
// Load previously validated checksums saved in Gradle User Home | ||
if (fs.existsSync(this.cacheFile)) { | ||
return JSON.parse(fs.readFileSync(this.cacheFile, 'utf-8')) | ||
} | ||
return [] | ||
} | ||
|
||
save(checksums: string[]): void { | ||
const uniqueChecksums = [...new Set(checksums)] | ||
// Save validated checksums to Gradle User Home | ||
fs.mkdirSync(path.dirname(this.cacheFile), {recursive: true}) | ||
fs.writeFileSync(this.cacheFile, JSON.stringify(uniqueChecksums)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters