@@ -4,76 +4,60 @@ description: Setup Rust with caching
4
4
5
5
inputs :
6
6
# See https://rust-lang.github.io/rustup/concepts/components.html
7
- clippy :
8
- default : false
9
- required : false
10
- type : boolean
11
- fmt :
12
- default : false
7
+ components :
13
8
required : false
14
- type : boolean
15
- docs :
16
- default : false
9
+ type : string
10
+ description : space separated Rust components, e.g. `clippy rustfmt rust-docs`
11
+
12
+ tools :
17
13
required : false
18
- type : boolean
14
+ type : string
15
+ description : comma separated Cargo tools
16
+
19
17
restore-cache :
20
18
default : true
21
19
required : false
22
20
type : boolean
21
+ description : whether to restore cache
22
+
23
23
save-cache :
24
24
default : false
25
25
required : false
26
26
type : boolean
27
- shared-key :
28
- default : ' warm'
27
+ description : whether to save cache, e.g. `github.ref_name == 'main'`
28
+
29
+ cache-key :
30
+ default : ' main'
29
31
required : false
30
32
type : string
33
+ description : cache key prefix
31
34
32
35
runs :
33
36
using : composite
34
37
steps :
35
38
- name : Print Inputs
36
39
shell : bash
37
40
run : |
38
- echo 'clippy: ${{ inputs.clippy }}'
39
- echo 'fmt: ${{ inputs.fmt }}'
40
- echo 'docs: ${{ inputs.docs }}'
41
+ echo 'components: ${{ inputs.components }}'
42
+ echo 'tools: ${{ inputs.tools }}'
41
43
echo 'restore-cache: ${{ inputs.restore-cache }}'
42
44
echo 'save-cache: ${{ inputs.save-cache }}'
43
- echo 'shared-key: ${{ inputs.shared-key }}'
44
-
45
- - name : Change to minimal profile on MacOS
46
- shell : bash
47
- if : runner.os == 'macOS'
48
- run : |
49
- sed -i '' -e 's/profile = "default"/profile = "minimal"/g' rust-toolchain.toml
50
- cat rust-toolchain.toml
45
+ echo 'cache-key: ${{ inputs.cache-key }}'
51
46
52
- - name : Change to minimal profile on non-MacOS
47
+ - name : Change to minimal profile
53
48
shell : bash
54
- if : runner.os != 'macOS'
55
49
run : |
56
- sed -i -e 's/profile = "default"/profile = "minimal"/g' rust-toolchain.toml
50
+ sed -i ${{ (runner.os == 'macOS' && '""') || '' }} -e 's/profile = "default"/profile = "minimal"/g' rust-toolchain.toml
57
51
cat rust-toolchain.toml
58
52
59
- - name : Set minimal profile
53
+ - name : Set Minimal Profile
60
54
shell : bash
61
55
run : rustup set profile minimal
62
56
63
- - name : Add Clippy
57
+ - name : Add Components
64
58
shell : bash
65
- if : ${{ inputs.clippy == 'true' }}
66
- run : rustup component add clippy
67
-
68
- - name : Add Rustfmt
69
- shell : bash
70
- if : ${{ inputs.fmt == 'true' }}
71
- run : rustup component add rustfmt
72
-
73
- - name : Add docs
74
- shell : bash
75
- if : ${{ inputs.docs == 'true' }}
76
- run : rustup component add rust-docs
59
+ if : ${{ inputs.components }}
60
+ run : rustup component add ${{ inputs.components }}
77
61
78
62
- name : Install
79
63
shell : bash
85
69
uses : Swatinem/rust-cache@v2
86
70
if : ${{ inputs.restore-cache == 'true' }}
87
71
with :
88
- shared-key : ${{ inputs.shared -key }}
72
+ shared-key : ${{ inputs.cache -key }}
89
73
save-if : ${{ inputs.save-cache == 'true' }}
74
+
75
+ - name : Install Tools
76
+ uses : taiki-e/install-action@v2
77
+ if : ${{ inputs.tools }}
78
+ with :
79
+ tool : ${{ inputs.tools }}
0 commit comments