diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4eb1d53 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/autotag-releases.yml b/.github/workflows/autotag-releases.yml index a0b5f30..4ca4ad5 100644 --- a/.github/workflows/autotag-releases.yml +++ b/.github/workflows/autotag-releases.yml @@ -15,11 +15,11 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Get version from tag id: tag_name run: | - echo ::set-output name=current_version::${GITHUB_REF#refs/tags/} + echo "current_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT shell: bash - name: Create and push tags run: | diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..04af258 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,36 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.1.1] - 2024-10-01 + +### Fixed + +* Parse the new rustfmt file and line number format + + The format changed in https://github.com/rust-lang/rustfmt/pull/5971 + + Thanks to @0xcypher02 for pointing out the problem. + +## [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 + +* Switch from set-output to $GITHUB_OUTPUT to avoid warning + https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ + +## [1.0.0] - 2022-07-19 + +Initial Version diff --git a/README.md b/README.md index 37a5367..2d2d5ac 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ jobs: name: cargo fmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Ensure rustfmt is installed and setup problem matcher - uses: actions-rust-lang/setup-rust-toolchain@v1 with: @@ -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..2ed6026 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 @@ -35,12 +41,12 @@ runs: echo "${CARGO_OUTPUT}" | # Strip color codes - sed 's/\x1B\[[0-9;]*[A-Za-z]//g' | + sed 's/\x1B\[[0-9;]*[A-Za-z]\x0f\?//g' | # Strip (some) cursor movements sed 's/\x1B.[A-G]//g' | tr "\n" "\r" | # Wrap each location into a HTML details - sed -E 's#Diff in ([^\r]*?) at line ([[:digit:]]+):\r((:?[ +-][^\r]*\r)+)#
\n\1:\2\n\n```diff\n\3```\n\n
\n\n#g' | + sed -E 's#Diff in ([^\r]*?)( at line |:)([[:digit:]]+):\r((:?[ +-][^\r]*\r)+)#
\n\1:\3\n\n```diff\n\4```\n\n
\n\n#g' | tr "\r" "\n" >> $GITHUB_STEP_SUMMARY fi