File tree Expand file tree Collapse file tree 3 files changed +33
-7
lines changed Expand file tree Collapse file tree 3 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 5
5
packages :
6
6
description : ' Packages to install'
7
7
required : true
8
+ cache :
9
+ description : ' Enable caching'
10
+ required : false
8
11
runs :
9
12
using : ' node12'
10
13
main : ' dist/index.js'
Original file line number Diff line number Diff line change @@ -47561,17 +47561,28 @@ const run = async () => {
47561
47561
core.info(`Installing '${packageName}'...`);
47562
47562
const foundPackage = allPackages.find(p => p.name === packageName);
47563
47563
if (!foundPackage) {
47564
- throw new Error(` Package '${packageName}' is not available. Enable debug output for more details.`);
47564
+ throw new Error(`Package '${packageName}' is not available. Enable debug output for more details.`);
47565
47565
}
47566
47566
if (foundPackage.installed && !foundPackage.update) {
47567
- core.info(`Package '${foundPackage.name}' is already installed and update is not required`);
47567
+ core.info(` Package '${foundPackage.name}' is already installed and update is not required`);
47568
47568
continue;
47569
47569
}
47570
47570
const cacheKey = `${foundPackage.name} ${foundPackage.remoteVersion}`;
47571
- await sdkmanager.install(foundPackage);
47572
47571
const localPackagePath = sdkmanager.getPackagePath(foundPackage);
47572
+ let cacheHit = false;
47573
+ if (enableCache) {
47574
+ const cacheHitKey = await cache.restoreCache([localPackagePath], cacheKey);
47575
+ cacheHit = Boolean(cacheHitKey);
47576
+ }
47577
+ if (cacheHit) {
47578
+ core.info(` Package ${foundPackage.name}' is restored from cache`);
47579
+ continue;
47580
+ }
47581
+ await sdkmanager.install(foundPackage);
47582
+ core.info(` Package ${foundPackage.name}' is downloaded and installed`);
47573
47583
if (enableCache) {
47574
47584
await cache.saveCache([localPackagePath], cacheKey);
47585
+ core.info(` Package ${foundPackage.name}' is saved to cache`);
47575
47586
}
47576
47587
}
47577
47588
}
Original file line number Diff line number Diff line change @@ -28,22 +28,34 @@ const run = async(): Promise<void> => {
28
28
core . info ( `Installing '${ packageName } '...` ) ;
29
29
const foundPackage = allPackages . find ( p => p . name === packageName ) ;
30
30
if ( ! foundPackage ) {
31
- throw new Error ( ` Package '${ packageName } ' is not available. Enable debug output for more details.` ) ;
31
+ throw new Error ( `Package '${ packageName } ' is not available. Enable debug output for more details.` ) ;
32
32
}
33
33
34
34
if ( foundPackage . installed && ! foundPackage . update ) {
35
- core . info ( `Package '${ foundPackage . name } ' is already installed and update is not required` ) ;
35
+ core . info ( ` Package '${ foundPackage . name } ' is already installed and update is not required` ) ;
36
36
continue ;
37
37
}
38
38
39
39
const cacheKey = `${ foundPackage . name } ${ foundPackage . remoteVersion } ` ;
40
+ const localPackagePath = sdkmanager . getPackagePath ( foundPackage ) ;
40
41
41
- await sdkmanager . install ( foundPackage ) ;
42
+ let cacheHit = false ;
43
+ if ( enableCache ) {
44
+ const cacheHitKey = await cache . restoreCache ( [ localPackagePath ] , cacheKey ) ;
45
+ cacheHit = Boolean ( cacheHitKey ) ;
46
+ }
42
47
43
- const localPackagePath = sdkmanager . getPackagePath ( foundPackage ) ;
48
+ if ( cacheHit ) {
49
+ core . info ( ` Package ${ foundPackage . name } ' is restored from cache` ) ;
50
+ continue ;
51
+ }
52
+
53
+ await sdkmanager . install ( foundPackage ) ;
54
+ core . info ( ` Package ${ foundPackage . name } ' is downloaded and installed` ) ;
44
55
45
56
if ( enableCache ) {
46
57
await cache . saveCache ( [ localPackagePath ] , cacheKey ) ;
58
+ core . info ( ` Package ${ foundPackage . name } ' is saved to cache` ) ;
47
59
}
48
60
}
49
61
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments