Skip to content

Commit 3224de1

Browse files
jdclaude
andauthored
feat(rust): scaffold Cargo workspace and Rust CI (#1263)
Introduces the Rust toolchain skeleton for the upcoming port. Ships nothing functional — the binary prints an identification line and exits 0. The value of this commit is the groundwork: a reviewable workspace layout, lint/test/release pipeline wired into CI, and a clear toolchain policy so subsequent phases have a stable foundation. ## Layout ``` Cargo.toml # workspace root rust-toolchain.toml # tracks latest stable + rustfmt/clippy crates/ mergify-cli/ # [[bin]] name = "mergify"; Phase 1.0 stub mergify-core/ # shared foundations (empty today; filled in 1.2) ``` Per the design, more crates (`mergify-py-shim`, one per command group) land in later phases. The 2-crate start is deliberate: the workspace exists, the lints and profile are set workspace-wide, but there is nothing for a reviewer to miss. ## Conventions - Edition 2024, MSRV `rust-version = 1.85` (edition-2024 minimum). - ``rust-toolchain.toml`` uses ``channel = "stable"`` — tracks the current stable toolchain, not a specific pinned version. Renovate can bump it later if we want a narrower contract. - Workspace-level lints: `unsafe_code = "forbid"`, `clippy::all`, `clippy::pedantic`. A small allow-list (`module_name_repetitions`, `missing_errors_doc`, `missing_panics_doc`) kills noise that would otherwise dominate a CLI with many small modules. Revisit per-PR. - Release profile: thin LTO, single codegen unit, symbols stripped — reduces binary size for `cargo-dist` output in Phase 1.5. ## CI New `rust` job on ubuntu-24.04: ``rustup toolchain install stable`` explicitly (so the build is deterministic against whatever the runner image has cached), then ``cargo fmt --check``, ``cargo clippy -D warnings``, ``cargo test``, ``cargo build --release``. Added to ``ci-gate`` so a red Rust job blocks merge just like linters and tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0d5d389 commit 3224de1

9 files changed

Lines changed: 142 additions & 0 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@ jobs:
4444
shell: bash
4545
run: uv run --locked poe compat-test
4646

47+
rust:
48+
timeout-minutes: 10
49+
runs-on: ubuntu-24.04
50+
steps:
51+
- uses: actions/checkout@v6.0.2
52+
53+
- name: Install Rust toolchain
54+
run: |
55+
rustup toolchain install stable --profile minimal
56+
rustup default stable
57+
rustup component add rustfmt clippy --toolchain stable
58+
59+
- uses: Swatinem/rust-cache@v2
60+
61+
- name: cargo fmt
62+
run: cargo fmt --all --check
63+
64+
- name: cargo clippy
65+
run: cargo clippy --all-targets --workspace -- -D warnings
66+
67+
- name: cargo test
68+
run: cargo test --workspace
69+
70+
- name: cargo build --release
71+
run: cargo build --release
72+
4773
test:
4874
timeout-minutes: 10
4975
strategy:
@@ -89,6 +115,7 @@ jobs:
89115
- test
90116
- linters
91117
- compat-tests
118+
- rust
92119
runs-on: ubuntu-latest
93120
steps:
94121
- name: Verify all jobs succeeded

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ __pycache__
22
.mypy_cache
33
dist
44
build
5+
target

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Copyright © 2021-2026 Mergify SAS
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
# not use this file except in compliance with the License. You may obtain
6+
# a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
11+
[workspace]
12+
resolver = "3"
13+
members = ["crates/*"]
14+
15+
[workspace.package]
16+
edition = "2024"
17+
# MSRV: the minimum supported toolchain. Set to the rustc that
18+
# ships edition 2024, so the project works on any stable from
19+
# early 2025 onwards. CI uses whatever stable is current.
20+
rust-version = "1.85"
21+
license = "Apache-2.0"
22+
repository = "https://github.com/Mergifyio/mergify-cli"
23+
authors = ["Mergify Team <hello@mergify.com>"]
24+
25+
[workspace.lints.rust]
26+
unsafe_code = "forbid"
27+
28+
[workspace.lints.clippy]
29+
all = { level = "warn", priority = -1 }
30+
pedantic = { level = "warn", priority = -1 }
31+
# Allow-list: pedantic rules that fire too aggressively for a CLI.
32+
# Keep this list intentional and short; revisit per-PR as we learn.
33+
module_name_repetitions = "allow"
34+
missing_errors_doc = "allow"
35+
missing_panics_doc = "allow"
36+
37+
[profile.release]
38+
lto = "thin"
39+
codegen-units = 1
40+
strip = "symbols"

crates/mergify-cli/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "mergify-cli"
3+
version = "0.0.0"
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
authors.workspace = true
9+
description = "mergify CLI — Rust implementation."
10+
publish = false
11+
12+
[[bin]]
13+
name = "mergify"
14+
path = "src/main.rs"
15+
16+
[dependencies]
17+
mergify-core = { path = "../mergify-core" }
18+
19+
[lints]
20+
workspace = true

crates/mergify-cli/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! `mergify` binary entry point.
2+
//!
3+
//! This is the Phase 1.0 scaffolding stub: it prints an identification
4+
//! line and exits 0 so CI can verify the Rust toolchain, build, and
5+
//! release profile end-to-end. Subsequent phases replace this with the
6+
//! real clap-based dispatch that forwards commands to native Rust
7+
//! implementations or the embedded Python shim.
8+
9+
fn main() {
10+
println!(
11+
"mergify {} — Rust scaffolding (Phase 1.0). \
12+
Use the Python CLI for actual functionality.",
13+
mergify_core::VERSION,
14+
);
15+
}

crates/mergify-core/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "mergify-core"
3+
version = "0.0.0"
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
authors.workspace = true
9+
description = "Shared foundations for mergify-cli: HTTP, auth, errors, output, git, config, prompts."
10+
publish = false
11+
12+
[lints]
13+
workspace = true

crates/mergify-core/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//! Shared foundations for the mergify CLI Rust port.
2+
//!
3+
//! This crate is intentionally empty in Phase 1.0 — it is the container
4+
//! that subsequent phases fill with the HTTP client, auth, error types,
5+
//! output traits, git operations, config loading, and interactive prompts.
6+
7+
/// Compile-time version string taken from the crate package metadata
8+
/// via ``CARGO_PKG_VERSION``.
9+
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "stable"
3+
components = ["rustfmt", "clippy"]

0 commit comments

Comments
 (0)