Skip to content

Commit 2d1d4e9

Browse files
authored
Merge pull request #2 from actions-rust-lang/add-manifest-path
2 parents 35e7a82 + 3e2206c commit 2d1d4e9

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.1.0] - 2022-11-21
11+
12+
### Added
13+
14+
* Add the input `manifest-path` to set the `--manifest-path` argument of rustfmt. #1
15+
This allows formatting any cargo project in the repository independent of the location.
16+
1017
## [1.0.1] - 2022-10-13
1118

1219
### Changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,15 @@ jobs:
3333
uses: actions-rust-lang/rustfmt@v1
3434
```
3535
36+
## Inputs
37+
38+
All inputs are optional.
39+
If a [toolchain file](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) (i.e., `rust-toolchain` or `rust-toolchain.toml`) is found in the root of the repository, it takes precedence.
40+
All input values are ignored if a toolchain file exists.
41+
42+
| Name | Description | Default |
43+
| --------------- | ------------------------------------------------------------------------ | ------------ |
44+
| `manifest-path` | Path to the `Cargo.toml` file, by default in the root of the repository. | ./Cargo.toml |
45+
3646
[`actions-rust-lang/setup-rust-toolchain`]: https://github.com/actions-rust-lang/setup-rust-toolchain
3747
[problem matcher]: https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ branding:
66
icon: "check-square"
77
color: "yellow"
88

9+
inputs:
10+
manifest-path:
11+
description: "Specify the --manifest-path argument to rustfmt"
12+
required: false
13+
default: "./Cargo.toml"
14+
915
runs:
1016
using: composite
1117
steps:
@@ -14,7 +20,7 @@ runs:
1420
run: |
1521
# Run cargo and store the original output
1622
CARGO_STATUS=0
17-
CARGO_OUTPUT=$(cargo fmt --all -- --color=always --check 2>/dev/null) || CARGO_STATUS=$?
23+
CARGO_OUTPUT=$(cargo fmt --all --manifest-path=${{ inputs.manifest-path }} -- --color=always --check 2>/dev/null) || CARGO_STATUS=$?
1824
1925
if [ ${CARGO_STATUS} -eq 0 ]; then
2026
cat <<MARKDOWN_INTRO >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)