Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 57e52b9

Browse files
committed
WIP: Remove key arguments of actions
This depends on a change in @actions-rs/core
1 parent 9f5d8b9 commit 57e52b9

3 files changed

Lines changed: 23 additions & 41 deletions

File tree

action.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ inputs:
1616
description: Use tool cache to speed up installation
1717
required: false
1818
default: false
19-
key:
20-
description: Store installed binary in the GitHub Actions cache with the specified key
21-
required: false
22-
restore-keys:
23-
description: Restore keys as used in the GitHub cache action
19+
use-cache:
20+
description: Store installed binary in the GitHub Actions cache
2421
required: false
22+
default: true
2523

2624
runs:
2725
using: 'node12'

src/input.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@ export interface Input {
99
crate: string;
1010
version: string;
1111
useToolCache: boolean;
12-
primaryKey?: string;
13-
restoreKeys?: string[];
12+
useCache: boolean;
1413
}
1514

1615
export function get(): Input {
1716
const crate = input.getInput("crate", { required: true });
1817
const version = input.getInput("version", { required: true });
1918
const useToolCache = input.getInputBool("use-tool-cache") || false;
20-
const primaryKey = input.getInput("key") || undefined;
21-
const restoreKeys = input.getInputAsArray("restore-keys") || undefined;
19+
const useCache = input.getInputBool("use-cache") || true;
2220

2321
return {
2422
crate: crate,
2523
version: version,
2624
useToolCache: useToolCache,
27-
primaryKey: primaryKey,
28-
restoreKeys: restoreKeys,
25+
useCache: useCache,
2926
};
3027
}

src/main.ts

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import * as download from "./download";
66

77
interface Options {
88
useToolCache: boolean;
9-
primaryKey?: string;
10-
restoreKeys?: string[];
9+
useCache: boolean;
1110
}
1211

1312
async function downloadFromToolCache(
@@ -29,36 +28,25 @@ export async function run(
2928
version: string,
3029
options: Options
3130
): Promise<void> {
32-
try {
33-
if (options.useToolCache) {
34-
try {
35-
core.info(
36-
"Tool cache is explicitly enabled via the Action input"
37-
);
38-
core.startGroup("Downloading from the tool cache");
39-
40-
return await downloadFromToolCache(crate, version);
41-
} finally {
42-
core.endGroup();
43-
}
44-
} else {
45-
core.info(
46-
"Tool cache is disabled in the Action inputs, skipping it"
47-
);
31+
if (options.useToolCache) {
32+
try {
33+
core.info("Tool cache is explicitly enabled via the Action input");
34+
core.startGroup("Downloading from the tool cache");
4835

49-
throw new Error(
50-
"Faster installation options either failed or disabled"
51-
);
36+
return await downloadFromToolCache(crate, version);
37+
} finally {
38+
core.endGroup();
5239
}
53-
} catch (error) {
54-
core.info("Falling back to the `cargo install` command");
40+
} else if (options.useCache) {
41+
core.info("GitHub Actions cache is used to install the tool");
5542
const cargo = await Cargo.get();
56-
await cargo.installCached(
57-
crate,
58-
version,
59-
options.primaryKey,
60-
options.restoreKeys
43+
await cargo.installCached(crate, version);
44+
} else {
45+
core.info(
46+
"Cache is disabled. Falling back to the `cargo install` command"
6147
);
48+
const cargo = await Cargo.get();
49+
await cargo.install(crate, version);
6250
}
6351
}
6452

@@ -68,8 +56,7 @@ async function main(): Promise<void> {
6856

6957
await run(actionInput.crate, actionInput.version, {
7058
useToolCache: actionInput.useToolCache,
71-
primaryKey: actionInput.primaryKey,
72-
restoreKeys: actionInput.restoreKeys,
59+
useCache: actionInput.useCache,
7360
});
7461
} catch (error) {
7562
core.setFailed(error.message);

0 commit comments

Comments
 (0)