Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustfmt: Add CI scripts and format onion_utils.rs #2877

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set -eox pipefail command includes the -x option, which prints commands and their arguments as they are executed. This can inadvertently leak sensitive information in logs. Consider removing -x unless debugging.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out find command (#find . -name '*.rs' -type f |sort >rustfmt_excluded_files) suggests an initial approach to generating the exclusion list. If this step is necessary for setup or future use, provide instructions or automate its execution rather than leaving it commented out.


# 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
Loading