Skip to content

Commit 3794a1f

Browse files
chore(ci): add lefthook hooks and fix pre-existing fmt drift
CI runs cargo fmt --check and cargo clippy -D warnings, but no local hook mirrored that — formatting drift slipped in via earlier merges and only surfaced once CI ran. Add a lefthook.yml so contributors get the same checks pre-commit (fmt) / pre-push (clippy), and fix the existing fmt violations in observer.rs and the e2e test harness. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent faad61e commit 3794a1f

5 files changed

Lines changed: 32 additions & 15 deletions

File tree

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
# Contributing
22

33
See [Contributing to this repository](https://github.com/ManoManoTech/ALaMano/blob/master/CONTRIBUTING.md).
4+
5+
## Git hooks
6+
7+
This repo ships a [lefthook](https://github.com/evilmartians/lefthook) config (`lefthook.yml`) that mirrors CI:
8+
9+
- `pre-commit`: `cargo fmt --check`
10+
- `pre-push`: `cargo clippy --all-targets -- -D warnings`
11+
12+
Install lefthook once (`brew install lefthook` / `go install github.com/evilmartians/lefthook@latest`) then run `lefthook install` in the repo to wire up `.git/hooks/`.

lefthook.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Lefthook git hooks. Install once with: lefthook install
2+
# https://github.com/evilmartians/lefthook
3+
#
4+
# Mirrors what CI enforces (.github/workflows/ci.yml):
5+
# - cargo fmt --check → pre-commit (fast, runs on every commit)
6+
# - cargo clippy -D warnings → pre-push (slower, runs once before push)
7+
8+
pre-commit:
9+
parallel: true
10+
commands:
11+
fmt:
12+
glob: "*.rs"
13+
run: cargo fmt --check
14+
15+
pre-push:
16+
commands:
17+
clippy:
18+
run: cargo clippy --all-targets -- -D warnings

src/pipeline/observer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ mod tests {
263263

264264
#[test]
265265
fn pipeline_observer_avg_upload_ms_computed_from_atomics() {
266-
let (_lt, _lr, _bt, _br, batches, upload_us, _c, obs) =
267-
make_pipeline_observer(4, 4, None);
266+
let (_lt, _lr, _bt, _br, batches, upload_us, _c, obs) = make_pipeline_observer(4, 4, None);
268267
batches.store(4, Ordering::Relaxed);
269268
upload_us.store(20_000, Ordering::Relaxed); // 20_000 us total = 20 ms total => 5 ms avg
270269
assert!((obs.avg_upload_ms() - 5.0).abs() < 1e-9);

tests/e2e/garage.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ pub async fn start_garage(bucket_name: &str) -> Result<GarageHandle> {
9494
let image = GenericImage::new(GARAGE_IMAGE, GARAGE_TAG)
9595
.with_exposed_port(ContainerPort::Tcp(S3_PORT))
9696
.with_exposed_port(ContainerPort::Tcp(ADMIN_PORT))
97-
.with_wait_for(WaitFor::message_on_stderr(
98-
"S3 API server listening on",
99-
));
97+
.with_wait_for(WaitFor::message_on_stderr("S3 API server listening on"));
10098

10199
let container = image
102100
.with_mount(Mount::bind_mount(
@@ -196,10 +194,7 @@ fn parse_key_create(stdout: &str) -> Option<(String, String)> {
196194
Some((access?, secret?))
197195
}
198196

199-
async fn exec_capture(
200-
container: &ContainerAsync<GenericImage>,
201-
cmd: &[&str],
202-
) -> Result<String> {
197+
async fn exec_capture(container: &ContainerAsync<GenericImage>, cmd: &[&str]) -> Result<String> {
203198
let mut result = container
204199
.exec(ExecCommand::new(cmd.iter().map(|s| s.to_string())))
205200
.await

tests/e2e/nginx.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ impl NginxHandle {
7070
.exec(ExecCommand::new([
7171
"sh".to_string(),
7272
"-c".to_string(),
73-
format!(
74-
"chmod -R a+rX /var/dumps && chown -R {host_uid}:{host_uid} /var/dumps",
75-
),
73+
format!("chmod -R a+rX /var/dumps && chown -R {host_uid}:{host_uid} /var/dumps",),
7674
]))
7775
.await
7876
.context("chmod/chown /var/dumps in container")?;
@@ -90,9 +88,7 @@ impl NginxHandle {
9088
let mut out = Vec::new();
9189
for e in entries {
9290
let p = e.path();
93-
out.push(
94-
std::fs::read(&p).with_context(|| format!("reading dump {}", p.display()))?,
95-
);
91+
out.push(std::fs::read(&p).with_context(|| format!("reading dump {}", p.display()))?);
9692
}
9793
Ok(out)
9894
}

0 commit comments

Comments
 (0)