-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (ci): Add Rust formatting command (#1552)
# Motivation CI has no rust formatter. As a result we have had PRs that contain changes that are just rust formatting. # Changes - Define rust and cargo formatting commands - Format # Tests <!-- Please provide any information or screenshots about the tests that have been done -->
- Loading branch information
Showing
7 changed files
with
53 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,31 @@ jobs: | |
working-directory: . | ||
run: ./scripts/test.backend.sh | ||
|
||
format: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-backend-tests-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }} | ||
- name: Install cargo dependency sorter | ||
run: cargo install [email protected] | ||
- name: Format | ||
run: ./scripts/format.sh | ||
- name: Check formatted | ||
run: | | ||
test -z "$(git status --porcelain)" || { | ||
echo "FIX: Please run ./scripts/format.sh" | ||
git diff | ||
exit 1 | ||
} | ||
may-merge: | ||
needs: [ 'tests' ] | ||
needs: [ 'tests', 'format' ] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Cleared for merging | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
cargo sort --grouped --workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
cargo fmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
cd "$(dirname "$(realpath "$0")")/.." | ||
|
||
set -x | ||
time xargs -P8 -I{} bash -c "{}" <<EOF | ||
./scripts/format.cargo.sh | ||
./scripts/format.rust.sh | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters