Skip to content

Commit a30b17f

Browse files
committed
ci(rust): add build/test/clippy gate; make the crates clippy-clean
The only Rust CI was CodeQL in build-mode `none` (buildless), so nothing ever compiled or tested robot-repo-automaton / shared-context / dashboard — which is how the non-compiling content-match path reached `main` before it was fixed in the prior PR. Add `.github/workflows/rust.yml`: a per-crate matrix running `cargo build --all-targets`, `cargo test`, and `cargo clippy --all-targets -- -D warnings` (blocking), with `cargo fmt --check` informational (there is pre-existing formatting drift — ~180 hunks — that is intentionally not gated yet). To make the clippy gate pass, fix the existing findings: - fixer.rs: drop a no-op `.replace("hyperpolymath", "hyperpolymath")`. - registry_guard.rs: use `split_once('/')` instead of a manual `splitn(2)`. - exclusion_registry.rs: rename the inherent `from_str` -> `parse` (it is not a `FromStr` impl; matches `Catalog::parse`) and use `if let Ok(..)` instead of `.ok()` + `if let Some(..)`. - hypatia.rs / main.rs: accept `&Path` instead of `&PathBuf`. - Cargo.toml (robot-repo-automaton + shared-context): drop the ignored `+spec-1.1.0` build metadata from the `toml` version requirement (resolution-neutral; silences the cargo warning). - benches: import `std::hint::black_box` (criterion's re-export is deprecated). All three crates are clippy `-D warnings` clean; 101 + 84 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RozeeLxpJsd3WWFngaZWz3
1 parent 4a10dde commit a30b17f

9 files changed

Lines changed: 59 additions & 14 deletions

File tree

.github/workflows/rust.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-License-Identifier: MPL-2.0
2+
name: Rust
3+
# Build + test + clippy gate for the three standalone Rust crates.
4+
# Added after a non-compiling crate (robot-repo-automaton) reached `main`
5+
# unnoticed: the only prior Rust CI was CodeQL in build-mode `none`
6+
# (buildless), so nothing actually compiled or tested these crates.
7+
on:
8+
push:
9+
branches: [main]
10+
pull_request:
11+
branches: ['**']
12+
permissions:
13+
contents: read
14+
env:
15+
CARGO_TERM_COLOR: always
16+
# reqwest=rustls-tls, git2=vendored-openssl, gix=rust-tls. OPENSSL_NO_VENDOR
17+
# makes openssl-sys link the runner's preinstalled system OpenSSL instead of
18+
# recompiling the vendored copy (matches the documented local build).
19+
OPENSSL_NO_VENDOR: '1'
20+
jobs:
21+
rust:
22+
name: build · test · clippy
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 30
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
crate: [robot-repo-automaton, shared-context, dashboard]
29+
defaults:
30+
run:
31+
working-directory: ${{ matrix.crate }}
32+
steps:
33+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
34+
- name: Ensure clippy + rustfmt components
35+
run: rustup component add clippy rustfmt
36+
- name: Build (all targets)
37+
run: cargo build --all-targets --verbose
38+
- name: Test
39+
run: cargo test --verbose
40+
- name: Clippy (deny warnings)
41+
run: cargo clippy --all-targets -- -D warnings
42+
- name: Rustfmt check (informational)
43+
# Pre-existing formatting drift is not yet gated; surfaced here so it
44+
# stays visible without blocking. Flip to a hard gate after a dedicated
45+
# `cargo fmt` pass lands.
46+
run: cargo fmt --check
47+
continue-on-error: true

robot-repo-automaton/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ reqwest = { version = "0.12.28", features = ["json", "rustls-tls"], default-feat
4242
# Serialization
4343
serde = { version = "1.0.228", features = ["derive"] }
4444
serde_json = "1.0.150"
45-
toml = "1.1.2+spec-1.1.0"
45+
toml = "1.1.2"
4646

4747
# Git operations
4848
# Using vendored-openssl to avoid system OpenSSL dependency (libssl-dev)

robot-repo-automaton/src/exclusion_registry.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ impl ExclusionRegistry {
135135
e
136136
))
137137
})?;
138-
Self::from_str(&source)
138+
Self::parse(&source)
139139
}
140140

141141
/// Parse from an in-memory A2ML string.
142-
pub fn from_str(source: &str) -> Result<Self> {
142+
pub fn parse(source: &str) -> Result<Self> {
143143
let raw: RawRegistry = toml::from_str(source).map_err(|e| {
144144
crate::error::Error::Config(format!("failed to parse exclusion registry: {e}"))
145145
})?;
@@ -270,7 +270,7 @@ impl ExclusionRegistry {
270270
}
271271

272272
// Kill-switch check first — cheapest, catches everything.
273-
if let Some(kill) = env::var("HYPATIA_AUTOMATION").ok() {
273+
if let Ok(kill) = env::var("HYPATIA_AUTOMATION") {
274274
let k = kill.to_ascii_lowercase();
275275
if matches!(k.as_str(), "off" | "disabled" | "0" | "false" | "halt") {
276276
return Decision::Deny {
@@ -445,7 +445,7 @@ reason = "upstream homebrew"
445445
"#;
446446

447447
fn registry() -> ExclusionRegistry {
448-
ExclusionRegistry::from_str(FIXTURE).unwrap()
448+
ExclusionRegistry::parse(FIXTURE).unwrap()
449449
}
450450

451451
#[test]

robot-repo-automaton/src/fixer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,6 @@ impl Fixer {
618618

619619
content
620620
.replace("gitbot-fleet", repo_name)
621-
.replace("hyperpolymath", "hyperpolymath")
622621
.replace("{{LICENSE}}", "MPL-2.0")
623622
.replace("{{YEAR}}", &year)
624623
.replace("{{AUTHOR}}", "Jonathan D.A. Jewell")

robot-repo-automaton/src/hypatia.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl CicdHyperAClient {
562562
/// - Auto-approve rules that consistently produce successful fixes
563563
pub async fn report_results(
564564
&self,
565-
repo_path: &PathBuf,
565+
repo_path: &Path,
566566
results: &[RuleExecutionResult],
567567
) -> crate::Result<()> {
568568
if !self.config.enable_feedback {

robot-repo-automaton/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use clap::{Parser, Subcommand};
2020
use robot_repo_automaton::prelude::*;
2121
use robot_repo_automaton::github::{GitHubClient, CreatePullRequest};
2222
use robot_repo_automaton::confidence::ThresholdConfig;
23-
use std::path::PathBuf;
23+
use std::path::{Path, PathBuf};
2424
use tracing::{debug, error, info, warn};
2525
use tracing_subscriber::EnvFilter;
2626

@@ -712,7 +712,7 @@ async fn cmd_hooks(_config: Option<&Config>, action: HookAction) -> anyhow::Resu
712712
}
713713

714714
/// Inspect the error catalog.
715-
fn cmd_catalog(path: &PathBuf, severity_filter: Option<&str>) -> anyhow::Result<()> {
715+
fn cmd_catalog(path: &Path, severity_filter: Option<&str>) -> anyhow::Result<()> {
716716
let catalog = ErrorCatalog::from_file(path)?;
717717
println!(
718718
"Error Catalog: {} error types (v{})",

robot-repo-automaton/src/registry_guard.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ fn parse_full_name(url: &str) -> Option<String> {
152152
for prefix in ["https://", "http://", "ssh://", "git://"] {
153153
if let Some(rest) = s.strip_prefix(prefix) {
154154
// Skip the host segment.
155-
let mut parts = rest.splitn(2, '/');
156-
let _host = parts.next()?;
157-
let path = parts.next()?;
155+
let (_host, path) = rest.split_once('/')?;
158156
return Some(path.to_string());
159157
}
160158
}

shared-context/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tokio = { version = "1.52.3", features = ["sync", "fs"] }
3535
notify = "8.2.0"
3636

3737
# Bot exclusion registry (exclusion_registry + registry_guard modules)
38-
toml = "1.1.2+spec-1.1.0"
38+
toml = "1.1.2"
3939
glob = "0.3.3"
4040
git2 = { version = "0.21.0", default-features = false }
4141

shared-context/benches/fleet_benchmarks.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// SPDX-License-Identifier: MPL-2.0
22
//! Performance benchmarks for gitbot-fleet operations
33
4-
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
4+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
55
use gitbot_shared_context::{BotId, Context, Finding, Severity};
6+
use std::hint::black_box;
67
use std::path::PathBuf;
78

89
/// Benchmark context creation

0 commit comments

Comments
 (0)