Skip to content

Commit cd82e1e

Browse files
committed
update
1 parent eca1797 commit cd82e1e

File tree

1 file changed

+31
-41
lines changed

1 file changed

+31
-41
lines changed

action.yml

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,76 +4,60 @@ description: Setup Rust with caching
44

55
inputs:
66
# 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:
138
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:
1713
required: false
18-
type: boolean
14+
type: string
15+
description: comma separated Cargo tools
16+
1917
restore-cache:
2018
default: true
2119
required: false
2220
type: boolean
21+
description: whether to restore cache
22+
2323
save-cache:
2424
default: false
2525
required: false
2626
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'
2931
required: false
3032
type: string
33+
description: cache key prefix
3134

3235
runs:
3336
using: composite
3437
steps:
3538
- name: Print Inputs
3639
shell: bash
3740
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 }}'
4143
echo 'restore-cache: ${{ inputs.restore-cache }}'
4244
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 }}'
5146
52-
- name: Change to minimal profile on non-MacOS
47+
- name: Change to minimal profile
5348
shell: bash
54-
if: runner.os != 'macOS'
5549
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
5751
cat rust-toolchain.toml
5852
59-
- name: Set minimal profile
53+
- name: Set Minimal Profile
6054
shell: bash
6155
run: rustup set profile minimal
6256

63-
- name: Add Clippy
57+
- name: Add Components
6458
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 }}
7761

7862
- name: Install
7963
shell: bash
@@ -85,5 +69,11 @@ runs:
8569
uses: Swatinem/rust-cache@v2
8670
if: ${{ inputs.restore-cache == 'true' }}
8771
with:
88-
shared-key: ${{ inputs.shared-key }}
72+
shared-key: ${{ inputs.cache-key }}
8973
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

Comments
 (0)