Skip to content

Commit fd0dc93

Browse files
committed
Use default runner tool cache location in favor of custom default
1 parent a240322 commit fd0dc93

5 files changed

Lines changed: 25 additions & 9 deletions

File tree

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ inputs:
88
description: An explicit key for storing and restoring the cache.
99
required: true
1010
dir:
11-
description: A directory path for storing (to) and restoring (from) the cache. Defaults to $SELF_CACHED_DIR or `~/.self-cached` if not set.
11+
description: A directory path for storing (to) and restoring (from) the cache. Defaults to $SELF_CACHED_DIR or $RUNNER_TOOL_CACHE if not set.
1212
required: false
1313
outputs:
1414
cache-hit:

product/dist/Restore.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

product/dist/Store.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/Test/UtilTest.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,33 @@ beforeEach(() => {
1313
});
1414

1515
describe('getDirInput', () => {
16-
it('can return input value when $SELF_CACHED_DIR is not set', () => {
16+
it('can return input value when only $SELF_CACHED_DIR is set', () => {
17+
vi.stubEnv('SELF_CACHED_DIR', 'foo');
18+
vi.stubEnv('RUNNER_TOOL_CACHE', undefined);
19+
expect(getDirInput('baz')).toBe('baz');
20+
expect(getDirInput(undefined)).toBe('foo');
21+
});
22+
23+
it('can return input value when only $RUNNER_TOOL_CACHE is set', () => {
1724
vi.stubEnv('SELF_CACHED_DIR', undefined);
18-
expect(getDirInput('foo')).toBe('foo');
19-
expect(getDirInput(undefined)).toBe(path.join(os.homedir(), '.self-cached'));
25+
vi.stubEnv('RUNNER_TOOL_CACHE', 'foo');
26+
expect(getDirInput('baz')).toBe('baz');
27+
expect(getDirInput(undefined)).toBe('foo');
2028
});
2129

22-
it('can return input value when $SELF_CACHED_DIR is set', () => {
30+
it('can return input value when both $SELF_CACHED_DIR and $RUNNER_TOOL_CACHE are set', () => {
2331
vi.stubEnv('SELF_CACHED_DIR', 'foo');
24-
expect(getDirInput('bar')).toBe('bar');
32+
vi.stubEnv('RUNNER_TOOL_CACHE', 'bar');
33+
expect(getDirInput('baz')).toBe('baz');
2534
expect(getDirInput(undefined)).toBe('foo');
2635
});
36+
37+
it("can't return input value when neither $SELF_CACHED_DIR or $RUNNER_TOOL_CACHE are not set", () => {
38+
vi.stubEnv('SELF_CACHED_DIR', undefined);
39+
vi.stubEnv('RUNNER_TOOL_CACHE', undefined);
40+
expect(getDirInput('baz')).toBe('baz');
41+
expect(getDirInput(undefined)).toBe(undefined);
42+
});
2743
});
2844

2945
describe('getLocalPath', () => {

source/Util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export enum State {
2323
export function getDirInput(value: string | undefined): string {
2424
if (value) return value;
2525
if (process.env.SELF_CACHED_DIR) return process.env.SELF_CACHED_DIR;
26-
return path.join(os.homedir(), '.self-cached');
26+
return process.env.RUNNER_TOOL_CACHE!;
2727
}
2828

2929
export async function getLocalPath(inputPath: string): Promise<{ path: string; name: string; exists: boolean }> {

0 commit comments

Comments
 (0)