-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
107 lines (91 loc) · 3.14 KB
/
Copy pathaction.yml
File metadata and controls
107 lines (91 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Rustup
description: Setup Rust with caching
inputs:
# See https://rust-lang.github.io/rustup/concepts/components.html
components:
required: false
type: string
description: space separated Rust components, e.g. `clippy rustfmt rust-docs`
tools:
required: false
type: string
description: comma separated Cargo tools
restore-cache:
default: true
required: false
type: boolean
description: whether to restore cache
save-cache:
default: false
required: false
type: boolean
description: whether to save cache, e.g. `github.ref_name == 'main'`
cache-key:
default: 'main'
required: false
type: string
description: cache key prefix
cache-workspace-crates:
default: false
required: false
description: "Similar to cache-all-crates. If `true` the workspace crates will be cached."
target-dir:
required: false
type: string
description: 'Custom target directory path (for Dev Drive etc). Sets CARGO_TARGET_DIR and configures cache accordingly.'
runs:
using: composite
steps:
- name: Print Inputs
shell: bash
run: |
echo 'components: ${INPUTS_COMPONENTS}'
echo 'tools: ${INPUTS_TOOLS}'
echo 'restore-cache: ${INPUTS_RESTORE_CACHE}'
echo 'save-cache: ${INPUTS_SAVE_CACHE}'
echo 'cache-key: ${INPUTS_CACHE_KEY}'
env:
INPUTS_COMPONENTS: ${{ inputs.components }}
INPUTS_TOOLS: ${{ inputs.tools }}
INPUTS_RESTORE_CACHE: ${{ inputs.restore-cache }}
INPUTS_SAVE_CACHE: ${{ inputs.save-cache }}
INPUTS_CACHE_KEY: ${{ inputs.cache-key }}
- name: Change to minimal profile
shell: bash
run: |
sed -i ${{ (runner.os == 'macOS' && '""') || '' }} -e 's/profile = "default"/profile = "minimal"/g' rust-toolchain.toml
cat rust-toolchain.toml
- name: Set Minimal Profile
shell: bash
run: rustup set profile minimal
- name: Add Components
shell: bash
if: ${{ inputs.components }}
run: rustup component add ${INPUTS_COMPONENTS}
env:
INPUTS_COMPONENTS: ${{ inputs.components }}
- name: Install
shell: bash
run: |
rustup show
git restore . # restore rust-toolchain.toml change
- name: Set CARGO_TARGET_DIR
shell: bash
if: ${{ inputs.target-dir }}
run: echo "CARGO_TARGET_DIR=$INPUTS_TARGET_DIR" >> "$GITHUB_ENV" # zizmor: ignore[github-env]
env:
INPUTS_TARGET_DIR: ${{ inputs.target-dir }}
- name: Cache on ${{ github.ref_name }}
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
if: ${{ inputs.restore-cache == 'true' }}
with:
shared-key: ${{ inputs.cache-key }}
save-if: ${{ inputs.save-cache == 'true' }}
cache-workspace-crates: ${{ inputs.cache-workspace-crates }}
cache-targets: ${{ inputs.target-dir && 'false' || 'true' }}
cache-directories: ${{ inputs.target-dir || '' }}
- name: Install Tools
uses: taiki-e/install-action@e0eafa9a0d485c37f97c0f7beb930a58a2facbac # v2.79.4
if: ${{ inputs.tools }}
with:
tool: ${{ inputs.tools }}