diff --git a/src/cache-distributions/cache-distributor.ts b/src/cache-distributions/cache-distributor.ts index 211946f..55a5a3d 100644 --- a/src/cache-distributions/cache-distributor.ts +++ b/src/cache-distributions/cache-distributor.ts @@ -10,10 +10,8 @@ export enum State { abstract class CacheDistributor { protected CACHE_KEY_PREFIX = 'setup-python'; - constructor( - protected packageManager: string, - protected cacheDependencyPath: string - ) {} + protected abstract readonly packageManager: string; + protected abstract readonly cacheDependencyPath: string; protected abstract getCacheGlobalDirectories(): Promise; protected abstract computeKeys(): Promise<{ diff --git a/src/cache-distributions/pip-cache.ts b/src/cache-distributions/pip-cache.ts index d64ae93..c1c9d02 100644 --- a/src/cache-distributions/pip-cache.ts +++ b/src/cache-distributions/pip-cache.ts @@ -12,12 +12,13 @@ import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants'; class PipCache extends CacheDistributor { private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH; + protected readonly packageManager = 'pip'; constructor( private pythonVersion: string, - cacheDependencyPath = '**/requirements.txt' + protected readonly cacheDependencyPath = '**/requirements.txt' ) { - super('pip', cacheDependencyPath); + super(); } protected async getCacheGlobalDirectories() { diff --git a/src/cache-distributions/pipenv-cache.ts b/src/cache-distributions/pipenv-cache.ts index 79674c2..978f63f 100644 --- a/src/cache-distributions/pipenv-cache.ts +++ b/src/cache-distributions/pipenv-cache.ts @@ -6,11 +6,13 @@ import * as core from '@actions/core'; import CacheDistributor from './cache-distributor'; class PipenvCache extends CacheDistributor { + protected readonly packageManager = 'pipenv'; + constructor( private pythonVersion: string, - protected cacheDependencyPath: string = '**/Pipfile.lock' + protected readonly cacheDependencyPath: string = '**/Pipfile.lock' ) { - super('pipenv', cacheDependencyPath); + super(); } protected async getCacheGlobalDirectories() { diff --git a/src/cache-distributions/poetry-cache.ts b/src/cache-distributions/poetry-cache.ts index 90739db..1baffaf 100644 --- a/src/cache-distributions/poetry-cache.ts +++ b/src/cache-distributions/poetry-cache.ts @@ -8,12 +8,15 @@ import CacheDistributor from './cache-distributor'; import {logWarning} from '../utils'; class PoetryCache extends CacheDistributor { + protected readonly packageManager = 'poetry'; + + constructor( private pythonVersion: string, - protected cacheDependencyPath: string = '**/poetry.lock', + protected readonly cacheDependencyPath: string = '**/poetry.lock', protected poetryProjects: Set = new Set() ) { - super('poetry', cacheDependencyPath); + super(); } protected async getCacheGlobalDirectories() {