Skip to content

Commit c4a2f1b

Browse files
authored
Merge pull request #2877 from tnull/2024-02-start-rustfmt-journey
`rustfmt`: Add CI scripts and format `onion_utils.rs`
2 parents affe557 + 5d50e9e commit c4a2f1b

File tree

6 files changed

+817
-258
lines changed

6 files changed

+817
-258
lines changed

.github/workflows/build.yml

+17
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,20 @@ jobs:
216216
- name: Run default clippy linting
217217
run: |
218218
cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err
219+
220+
rustfmt:
221+
runs-on: ubuntu-latest
222+
env:
223+
TOOLCHAIN: 1.63.0
224+
steps:
225+
- name: Checkout source code
226+
uses: actions/checkout@v3
227+
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
228+
run: |
229+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
230+
rustup override set ${{ env.TOOLCHAIN }}
231+
- name: Install rustfmt
232+
run: |
233+
rustup component add rustfmt
234+
- name: Run rustfmt checks
235+
run: ci/rustfmt.sh

CONTRIBUTING.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,15 @@ Coding Conventions
120120
------------------
121121

122122
Use tabs. If you want to align lines, use spaces. Any desired alignment should
123-
display fine at any tab-length display setting.
123+
display fine at any tab-length display setting. We use `rustfmt` to establish
124+
uniform coding standards throughout the codebase. Please run
125+
126+
```bash
127+
./ci/rustfmt.sh
128+
```
129+
130+
before committing and pushing any changes, as compliance will also be checked
131+
and enforced by our CI scripts.
124132

125133
Our CI enforces [clippy's](https://github.com/rust-lang/rust-clippy) default
126134
linting

ci/rustfmt.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# Generate initial exclusion list
5+
#find . -name '*.rs' -type f |sort >rustfmt_excluded_files
6+
7+
# Run fmt
8+
TMP_FILE=$(mktemp)
9+
find . -name '*.rs' -type f |sort >$TMP_FILE
10+
for file in $(comm -23 $TMP_FILE rustfmt_excluded_files); do
11+
echo "Checking formatting of $file"
12+
rustfmt +1.63.0 --check $file
13+
done

0 commit comments

Comments
 (0)