Skip to content

Commit eca1797

Browse files
committed
init
0 parents  commit eca1797

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

action.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Rustup
2+
3+
description: Setup Rust with caching
4+
5+
inputs:
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
13+
required: false
14+
type: boolean
15+
docs:
16+
default: false
17+
required: false
18+
type: boolean
19+
restore-cache:
20+
default: true
21+
required: false
22+
type: boolean
23+
save-cache:
24+
default: false
25+
required: false
26+
type: boolean
27+
shared-key:
28+
default: 'warm'
29+
required: false
30+
type: string
31+
32+
runs:
33+
using: composite
34+
steps:
35+
- name: Print Inputs
36+
shell: bash
37+
run: |
38+
echo 'clippy: ${{ inputs.clippy }}'
39+
echo 'fmt: ${{ inputs.fmt }}'
40+
echo 'docs: ${{ inputs.docs }}'
41+
echo 'restore-cache: ${{ inputs.restore-cache }}'
42+
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
51+
52+
- name: Change to minimal profile on non-MacOS
53+
shell: bash
54+
if: runner.os != 'macOS'
55+
run: |
56+
sed -i -e 's/profile = "default"/profile = "minimal"/g' rust-toolchain.toml
57+
cat rust-toolchain.toml
58+
59+
- name: Set minimal profile
60+
shell: bash
61+
run: rustup set profile minimal
62+
63+
- name: Add Clippy
64+
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
77+
78+
- name: Install
79+
shell: bash
80+
run: |
81+
rustup show
82+
git restore . # restore rust-toolchain.toml change
83+
84+
- name: Cache on ${{ github.ref_name }}
85+
uses: Swatinem/rust-cache@v2
86+
if: ${{ inputs.restore-cache == 'true' }}
87+
with:
88+
shared-key: ${{ inputs.shared-key }}
89+
save-if: ${{ inputs.save-cache == 'true' }}

0 commit comments

Comments
 (0)