Skip to content

Commit 5767910

Browse files
authored
Add ./script/format for customized cargo fmt invocation. (warpdotdev#11747)
## Description This adds a formatting script at `./script/format` that invokes `cargo fmt` with the options we want for our codebase. Due to the fact that we're using some unstable formatter options, we need to pass `RUSTC_BOOTSTRAP=1` to enable use of unstable options with a stable toolchain, and that requires us to put together a small script like this. This PR updates existing formatting using the new script, and modifies both `./script/presubmit` ~and CI to enforce formatting against this new configuration~. EDIT: Realized we probably want `./script/format` to soak for a week or so before we start enforcement, due to us not using a merge queue. Otherwise, we'll probably end up with non-conforming formatting changes being merged into `master` and causing issues.
1 parent 21334d4 commit 5767910

84 files changed

Lines changed: 306 additions & 278 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/promote-feature/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub const PREVIEW_FLAGS: &[FeatureFlag] = &[
8181
### Validate
8282

8383
```bash
84-
cargo fmt
84+
./script/format
8585
cargo clippy --workspace --all-targets --all-features --tests -- -D warnings
8686
```
8787

.agents/skills/remove-feature-flag/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ After removing the flag:
116116

117117
```bash
118118
# Format and lint
119-
cargo fmt
119+
./script/format
120120
cargo clippy --workspace --all-targets --all-features --tests -- -D warnings
121121

122122
# Run tests

.agents/skills/rust-unit-tests/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ cargo test --doc
106106
## Linting and formatting
107107
Run before submitting changes:
108108
```bash
109-
cargo fmt
109+
./script/format
110110
cargo clippy --workspace --all-targets --all-features --tests -- -D warnings
111111
```
112112

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,9 @@ jobs:
613613
run:
614614
cargo metadata --locked --format-version=1 > ${{ matrix.null_device }} || (echo "::error::Cargo.lock is out-of-date with Cargo.toml. Run 'cargo check' to update." && exit 1)
615615

616-
- name: Run cargo fmt
617-
run: cargo fmt --check
616+
- name: Run ./script/format
617+
shell: bash
618+
run: ./script/format --check
618619

619620
- name: Run cargo clippy
620621
shell: bash
@@ -724,8 +725,15 @@ jobs:
724725
run:
725726
cargo metadata --locked --format-version=1 >/dev/null || (echo "::error::Cargo.lock is out-of-date with Cargo.toml. Run 'cargo check' to update." && exit 1)
726727

727-
- name: Run cargo fmt
728-
run: cargo fmt --check
728+
- name: Check Rust formatting
729+
shell: bash
730+
run: |
731+
# TODO(vorporeal): Once people have gotten used to ./script/format, in a week or so,
732+
# we can have CI enforce the new formatting.
733+
#./script/format --check
734+
735+
# Until then, we'll keep running the traditional formatting check.
736+
cargo fmt --check
729737
730738
- name: Run cargo clippy
731739
run: |

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Run unit tests with `cargo nextest run`.
171171

172172
## Code Style
173173

174-
- `cargo fmt` and `cargo clippy --workspace --all-targets --all-features --tests -- -D warnings` must pass.
174+
- `./script/format --check` and `cargo clippy --workspace --all-targets --all-features --tests -- -D warnings` must pass.
175175
- Prefer imports over path qualifiers, inline format args (`println!("{x}")`), and exhaustive `match` over `_` wildcards.
176176
- See [WARP.md](WARP.md) for the full style guide, including WarpUI patterns and terminal model locking rules.
177177

FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ No. Contributing by hand or with your own agent is free. Oz runs on Warp's credi
8080

8181
### Are agent-generated PRs held to the same bar as human ones?
8282

83-
Yes. The same Oz + SME review, the same tests, and the same `cargo fmt` / `cargo clippy` / presubmit checks apply regardless of who (or what) wrote the code. Whether a PR is hand-written or agent-written doesn't change the quality bar — it changes how quickly you can iterate to meet it.
83+
Yes. The same Oz + SME review, the same tests, and the same `./script/format` / `cargo clippy` / presubmit checks apply regardless of who (or what) wrote the code. Whether a PR is hand-written or agent-written doesn't change the quality bar — it changes how quickly you can iterate to meet it.
8484

8585
### Will my issues, comments, or code be used to train models?
8686

WARP.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Environment variables:
3131

3232
### Linting and Formatting
3333
- `./script/presubmit` - Run all presubmit checks (fmt, clippy, tests)
34-
- `cargo fmt` - Format code
34+
- `./script/format` - Format code
3535
- `cargo clippy --workspace --all-targets --all-features --tests -- -D warnings` - Run clippy
3636
- `./script/run-clang-format.py -r --extensions 'c,h,cpp,m' ./crates/warpui/src/ ./app/src/` - Format C/C++/Obj-C code
3737
- `find . -name "*.wgsl" -exec wgslfmt --check {} +` - Check WGSL shader formatting
@@ -129,9 +129,9 @@ This is a Rust-based terminal emulator with a custom UI framework called **WarpU
129129
```
130130

131131
**Pull Request Workflow**:
132-
- **ALWAYS** run cargo fmt and cargo clippy (the versions specified in ./script/presubmit) before opening a PR or pushing updates to an existing PR branch
132+
- **ALWAYS** run `./script/format` and `cargo clippy` (the versions specified in ./script/presubmit) before opening a PR or pushing updates to an existing PR branch
133133
- Those commands must pass completely before creating or updating a pull request
134-
- Specifically, ensure `cargo fmt` and `cargo clippy` checks pass
134+
- Specifically, ensure `./script/format` and `cargo clippy` checks pass
135135
- If they fail, fix all issues before proceeding with the PR
136136
- This applies to:
137137
- Opening new pull requests

app/src/ai/agent/api/convert_from.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
use std::collections::HashMap;
33
use std::time::Duration;
44

5-
use ai::agent::action::LifecycleEventType as StartAgentLifecycleEventType;
6-
use ai::agent::action::ReadSkillRequest;
5+
use ai::agent::action::{LifecycleEventType as StartAgentLifecycleEventType, ReadSkillRequest};
76
use ai::agent::action_result::StartAgentVersion;
87
use ai::agent::convert::ToolToAIAgentActionError;
98
use ai::agent::UnknownCitationTypeError;

app/src/ai/agent/api/convert_from_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
use std::path::PathBuf;
2+
13
use ai::agent::action::AskUserQuestionType;
24
use ai::skills::{SkillPathOrigin, SkillReference};
3-
use std::path::PathBuf;
45
use warp_multi_agent_api as api;
56
use warp_util::local_or_remote_path::LocalOrRemotePath;
67

app/src/ai/agent/conversation_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use ai::api_keys::ApiKeyManager;
21
use std::collections::HashMap;
32

3+
use ai::api_keys::ApiKeyManager;
44
use warp_core::features::FeatureFlag;
55
use warp_multi_agent_api as api;
66
use warpui::{App, SingletonEntity};
@@ -11,7 +11,8 @@ use super::{
1111
};
1212
use crate::ai::artifacts::Artifact;
1313
use crate::ai::llms::LLMPreferences;
14-
use crate::auth::{auth_manager::AuthManager, AuthStateProvider};
14+
use crate::auth::auth_manager::AuthManager;
15+
use crate::auth::AuthStateProvider;
1516
use crate::network::NetworkStatus;
1617
use crate::persistence::model::AgentConversationData;
1718
use crate::server::server_api::ServerApiProvider;

0 commit comments

Comments
 (0)