mirror of
https://github.com/actions/setup-python.git
synced 2025-07-18 22:48:20 +02:00
resolving comments
This commit is contained in:
parent
952fef3565
commit
c98dcdec10
8 changed files with 61 additions and 52 deletions
|
@ -9,7 +9,7 @@ export enum State {
|
|||
|
||||
abstract class CacheDistributor {
|
||||
protected CACHE_KEY_PREFIX = 'setup-python';
|
||||
constructor(protected toolName: string, protected patterns: string) {}
|
||||
constructor(protected toolName: string, protected cacheDependencyPath: string) {}
|
||||
|
||||
protected abstract getCacheGlobalDirectories(): Promise<string[]>;
|
||||
protected abstract computeKeys(): Promise<{
|
||||
|
@ -19,22 +19,25 @@ abstract class CacheDistributor {
|
|||
|
||||
public async restoreCache() {
|
||||
const {primaryKey, restoreKey} = await this.computeKeys();
|
||||
const cachePath = await this.getCacheGlobalDirectories();
|
||||
core.saveState(State.CACHE_PATHS, cachePath);
|
||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||
if (primaryKey.endsWith('-')) {
|
||||
throw new Error(
|
||||
`No file in ${process.cwd()} matched to [${this.patterns
|
||||
`No file in ${process.cwd()} matched to [${this.cacheDependencyPath
|
||||
.split('\n')
|
||||
.join(',')}], make sure you have checked out the target repository`
|
||||
);
|
||||
}
|
||||
|
||||
const cachePath = await this.getCacheGlobalDirectories();
|
||||
|
||||
core.saveState(State.CACHE_PATHS, cachePath);
|
||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||
|
||||
const matchedKey = await cache.restoreCache(
|
||||
cachePath,
|
||||
primaryKey,
|
||||
restoreKey
|
||||
);
|
||||
|
||||
if (matchedKey) {
|
||||
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
|
||||
core.info(`Cache restored from key: ${matchedKey}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue