Skip to content

Commit

Permalink
Merge pull request #2877 from tnull/2024-02-start-rustfmt-journey
Browse files Browse the repository at this point in the history
`rustfmt`: Add CI scripts and format `onion_utils.rs`
  • Loading branch information
TheBlueMatt authored Feb 22, 2024
2 parents affe557 + 5d50e9e commit c4a2f1b
Show file tree
Hide file tree
Showing 6 changed files with 817 additions and 258 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,20 @@ jobs:
- name: Run default clippy linting
run: |
cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err
rustfmt:
runs-on: ubuntu-latest
env:
TOOLCHAIN: 1.63.0
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
rustup override set ${{ env.TOOLCHAIN }}
- name: Install rustfmt
run: |
rustup component add rustfmt
- name: Run rustfmt checks
run: ci/rustfmt.sh
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ Coding Conventions
------------------

Use tabs. If you want to align lines, use spaces. Any desired alignment should
display fine at any tab-length display setting.
display fine at any tab-length display setting. We use `rustfmt` to establish
uniform coding standards throughout the codebase. Please run

```bash
./ci/rustfmt.sh
```

before committing and pushing any changes, as compliance will also be checked
and enforced by our CI scripts.

Our CI enforces [clippy's](https://github.com/rust-lang/rust-clippy) default
linting
Expand Down
13 changes: 13 additions & 0 deletions ci/rustfmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -eox pipefail

# Generate initial exclusion list
#find . -name '*.rs' -type f |sort >rustfmt_excluded_files

# Run fmt
TMP_FILE=$(mktemp)
find . -name '*.rs' -type f |sort >$TMP_FILE
for file in $(comm -23 $TMP_FILE rustfmt_excluded_files); do
echo "Checking formatting of $file"
rustfmt +1.63.0 --check $file
done
Loading

0 comments on commit c4a2f1b

Please sign in to comment.