File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -92,13 +92,9 @@ describe('restore-cache', () => {
9292 dependencyFile
9393 ) ;
9494 await cacheDistributor . restoreCache ( ) ;
95- let pythonKey = '' ;
96- if ( packageManager === 'pipenv' ) {
97- pythonKey = `python-${ pythonVersion } -` ;
98- }
9995
10096 expect ( infoSpy ) . toHaveBeenCalledWith (
101- `Cache restored from key: setup-python-${ process . env [ 'RUNNER_OS' ] } -${ pythonKey } ${ packageManager } -${ fileHash } `
97+ `Cache restored from key: setup-python-${ process . env [ 'RUNNER_OS' ] } -python- ${ pythonVersion } - ${ packageManager } -${ fileHash } `
10298 ) ;
10399 }
104100 ) ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export function getCacheDistributor(
1313) {
1414 switch ( packageManager ) {
1515 case PackageManagers . Pip :
16- return new PipCache ( cacheDependencyPath ) ;
16+ return new PipCache ( pythonVersion , cacheDependencyPath ) ;
1717 case PackageManagers . Pipenv :
1818 return new PipenvCache ( pythonVersion , cacheDependencyPath ) ;
1919 default :
Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ import os from 'os';
88import CacheDistributor from './cache-distributor' ;
99
1010class PipCache extends CacheDistributor {
11- constructor ( cacheDependencyPath : string = '**/requirements.txt' ) {
11+ constructor (
12+ private pythonVersion : string ,
13+ cacheDependencyPath : string = '**/requirements.txt'
14+ ) {
1215 super ( 'pip' , cacheDependencyPath ) ;
1316 }
1417
@@ -36,8 +39,8 @@ class PipCache extends CacheDistributor {
3639
3740 protected async computeKeys ( ) {
3841 const hash = await glob . hashFiles ( this . cacheDependencyPath ) ;
39- const primaryKey = `${ this . CACHE_KEY_PREFIX } -${ process . env [ 'RUNNER_OS' ] } -${ this . packageManager } -${ hash } ` ;
40- const restoreKey = `${ this . CACHE_KEY_PREFIX } -${ process . env [ 'RUNNER_OS' ] } -${ this . packageManager } ` ;
42+ const primaryKey = `${ this . CACHE_KEY_PREFIX } -${ process . env [ 'RUNNER_OS' ] } -python- ${ this . pythonVersion } - ${ this . packageManager } -${ hash } ` ;
43+ const restoreKey = `${ this . CACHE_KEY_PREFIX } -${ process . env [ 'RUNNER_OS' ] } -python- ${ this . pythonVersion } - ${ this . packageManager } ` ;
4144
4245 return {
4346 primaryKey,
You can’t perform that action at this time.
0 commit comments