Commit e74e959 1 parent 9b449c3 commit e74e959 Copy full SHA for e74e959
File tree 6 files changed +37
-8
lines changed
6 files changed +37
-8
lines changed Original file line number Diff line number Diff line change 94
94
with :
95
95
scarb-lock : ./subdir/Scarb.lock
96
96
97
+ - name : " Setup Scarb with caching disabled"
98
+ uses : ./
99
+ with :
100
+ cache : false
101
+
97
102
- name : " Create .tool-versions file"
98
103
run : echo "scarb 0.7.0" >> .tool-versions
99
104
- name : " Setup Scarb using `.tool-versions` file"
Original file line number Diff line number Diff line change 36
36
- ` scarb-lock` - **Optional**. String.
37
37
- Stating a relative or absolute path to the `Scarb.lock` file used for caching dependencies.
38
38
- Empty/not specified : ` Scarb.lock` in the working directory will be used.
39
+ - ` cache` - **Optional**. Boolean.
40
+ - Enables caching Scarb dependencies.
41
+ - Empty/not specified : ` true` .
39
42
40
43
# # Outputs
41
44
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ inputs:
14
14
scarb-lock :
15
15
description : Path to Scarb.lock file
16
16
required : false
17
+ cache :
18
+ description : Enable dependency caching
19
+ required : false
17
20
outputs :
18
21
scarb-prefix :
19
22
description : The prefix of the installed Scarb
Original file line number Diff line number Diff line change 1
1
import * as core from "@actions/core" ;
2
2
import * as cache from "@actions/cache" ;
3
3
4
- import { getCacheDirectory , State } from "./cache-utils" ;
4
+ import { getCacheDirectory , isCacheEnabled , State } from "./cache-utils" ;
5
5
6
6
async function saveCache ( ) {
7
+ const cacheInput = core . getInput ( "cache" ) ;
8
+
9
+ if ( ! isCacheEnabled ( cacheInput ) ) {
10
+ core . info ( `Caching disabled, not saving cache.` ) ;
11
+ return ;
12
+ }
13
+
7
14
try {
8
15
const primaryKey = core . getState ( State . CachePrimaryKey ) ;
9
16
const matchedKey = core . getState ( State . CacheMatchedKey ) ;
Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ export const State = {
11
11
CacheMatchedKey : "matched_key" ,
12
12
} ;
13
13
14
+ export function isCacheEnabled ( cacheInput ) {
15
+ cacheInput = cacheInput || "true" ;
16
+ return cacheInput === "true" ;
17
+ }
18
+
14
19
export async function getCacheDirectory ( ) {
15
20
// NOTE: The `cache path` command was introduced in Scarb 0.7.0. We do not want to break compatibility with older
16
21
// versions yet, so we fall back to a well-known cache path if this command is not available.
Original file line number Diff line number Diff line change @@ -9,12 +9,14 @@ import {
9
9
import { downloadScarb } from "./download" ;
10
10
import { getOsTriplet } from "./platform" ;
11
11
import { restoreCache } from "./cache-restore" ;
12
+ import { isCacheEnabled } from "./cache-utils" ;
12
13
13
14
export default async function main ( ) {
14
15
try {
15
16
const scarbVersionInput = core . getInput ( "scarb-version" ) ;
16
17
const toolVersionsPathInput = core . getInput ( "tool-versions" ) ;
17
18
const scarbLockPathInput = core . getInput ( "scarb-lock" ) ;
19
+ const cacheInput = core . getInput ( "cache" ) ;
18
20
19
21
const { repo : scarbRepo , version : scarbVersion } = await determineVersion (
20
22
scarbVersionInput ,
@@ -48,13 +50,17 @@ export default async function main() {
48
50
49
51
core . setOutput ( "scarb-version" , await getFullVersionFromScarb ( ) ) ;
50
52
51
- await restoreCache ( scarbLockPathInput ) . catch ( ( e ) => {
52
- core . error (
53
- `There was an error when restoring cache: ${
54
- e instanceof Error ? e . message : e
55
- } `,
56
- ) ;
57
- } ) ;
53
+ if ( isCacheEnabled ( cacheInput ) ) {
54
+ await restoreCache ( scarbLockPathInput ) . catch ( ( e ) => {
55
+ core . error (
56
+ `There was an error when restoring cache: ${
57
+ e instanceof Error ? e . message : e
58
+ } `,
59
+ ) ;
60
+ } ) ;
61
+ } else {
62
+ core . info ( `Caching disabled, not restoring cache.` ) ;
63
+ }
58
64
} catch ( e ) {
59
65
core . setFailed ( e ) ;
60
66
}
You can’t perform that action at this time.
0 commit comments