diff --git a/CHANGELOG.md b/CHANGELOG.md index dbdbf4b..9ba50ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0] - 2022-11-21 + +### Added + +* Add the input `manifest-path` to set the `--manifest-path` argument of rustfmt. #1 + This allows formatting any cargo project in the repository independent of the location. + ## [1.0.1] - 2022-10-13 ### Changed diff --git a/README.md b/README.md index 37a5367..fa33146 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,15 @@ jobs: uses: actions-rust-lang/rustfmt@v1 ``` +## Inputs + +All inputs are optional. +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. +All input values are ignored if a toolchain file exists. + +| Name | Description | Default | +| --------------- | ------------------------------------------------------------------------ | ------------ | +| `manifest-path` | Path to the `Cargo.toml` file, by default in the root of the repository. | ./Cargo.toml | + [`actions-rust-lang/setup-rust-toolchain`]: https://github.com/actions-rust-lang/setup-rust-toolchain [problem matcher]: https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md diff --git a/action.yml b/action.yml index f1beaec..7b5816e 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,12 @@ branding: icon: "check-square" color: "yellow" +inputs: + manifest-path: + description: "Specify the --manifest-path argument to rustfmt" + required: false + default: "./Cargo.toml" + runs: using: composite steps: @@ -14,7 +20,7 @@ runs: run: | # Run cargo and store the original output CARGO_STATUS=0 - CARGO_OUTPUT=$(cargo fmt --all -- --color=always --check 2>/dev/null) || CARGO_STATUS=$? + CARGO_OUTPUT=$(cargo fmt --all --manifest-path=${{ inputs.manifest-path }} -- --color=always --check 2>/dev/null) || CARGO_STATUS=$? if [ ${CARGO_STATUS} -eq 0 ]; then cat <> $GITHUB_STEP_SUMMARY