mirror of
https://github.com/actions/setup-python.git
synced 2025-07-18 17:48:20 +02:00
add support for caching
This commit is contained in:
parent
feeaa3ba49
commit
952fef3565
14 changed files with 124033 additions and 7678 deletions
42
src/cache-distributions/pipenv-cache.ts
Normal file
42
src/cache-distributions/pipenv-cache.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import * as glob from '@actions/glob';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import CacheDistributor from './cache-distributor';
|
||||
|
||||
class PipenvCache extends CacheDistributor {
|
||||
constructor(
|
||||
private pythonVersion: string,
|
||||
protected patterns: string = 'Pipfile.lock'
|
||||
) {
|
||||
super('pipenv', patterns);
|
||||
}
|
||||
|
||||
private getVirtualenvsPath() {
|
||||
if (process.platform === 'win32') {
|
||||
return '.virtualenvs';
|
||||
} else {
|
||||
return '.local/share/virtualenvs';
|
||||
}
|
||||
}
|
||||
|
||||
protected async getCacheGlobalDirectories() {
|
||||
const cachePath = path.join(os.homedir(), this.getVirtualenvsPath());
|
||||
core.debug(`Pipenv virtualenvs path is ${cachePath}`);
|
||||
|
||||
return [cachePath];
|
||||
}
|
||||
|
||||
protected async computeKeys() {
|
||||
const hash = await glob.hashFiles(this.patterns);
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.toolName}-${hash}`;
|
||||
const restoreKey = undefined;
|
||||
return {
|
||||
primaryKey,
|
||||
restoreKey
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default PipenvCache;
|
Loading…
Add table
Add a link
Reference in a new issue