Skip to content

Commit 426e06d

Browse files
committed
enhancement: Add option to specify rust-toolchain.toml path (#47)
1 parent ab68452 commit 426e06d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a
6666
| `matcher` | Enable problem matcher to surface build messages and formatting issues | true |
6767
| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" |
6868
| `override` | Setup the last installed toolchain as the default via `rustup override` | true |
69+
| `rust-toolchain-dir` | Path from root directory to directory with the rust toolchain file (if its not in the root of the repository) | |
6970

7071
[`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache
7172

action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ inputs:
6969
description: "Setup the last installed toolchain as the default via `rustup override`"
7070
required: false
7171
default: "true"
72+
rust-toolchain-dir:
73+
description: "Specify path from root directory to the directory to search for rust-toolchain.toml file. By default root directory will be used."
74+
required: false
7275

7376
outputs:
7477
rustc-version:
@@ -163,14 +166,18 @@ runs:
163166
targets: ${{inputs.target}}
164167
components: ${{inputs.components}}
165168
override: ${{inputs.override}}
169+
rust_toolchain_dir: ${{inputs.rust-toolchain-dir}}
166170
shell: bash
167171
run: |
168-
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]]
172+
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" || -f "$rust_toolchain_dir/rust-toolchain.toml") ]]
169173
then
170174
# Install the toolchain as specified in the file
171175
# rustup show is the old way that implicitly installed a toolchain
172176
# rustup toolchain install is the new explicit way
173177
# https://github.com/rust-lang/rustup/issues/3635#issuecomment-2343511297
178+
if [[ -n "$rust_toolchain_dir" ]]; then
179+
cd "$rust_toolchain_dir"
180+
fi
174181
rustup show active-toolchain || rustup toolchain install
175182
if [[ -n $components ]]; then
176183
rustup component add ${components//,/ }

0 commit comments

Comments
 (0)