Skip to content

Add rustfmt config and nightly toolchain#59

Merged
leynos merged 6 commits intomainfrom
codex/update-formatting-and-ci-configurations
Jun 16, 2025
Merged

Add rustfmt config and nightly toolchain#59
leynos merged 6 commits intomainfrom
codex/update-formatting-and-ci-configurations

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 16, 2025

Summary

  • configure rustfmt with project rules
  • pin nightly toolchain for CI
  • ensure release workflow builds with +stable
  • apply rustfmt changes across the codebase

Testing

  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test
  • npx -y markdownlint-cli2 '**/*.md' '#node_modules'
  • nixie docs/preamble-validator.md

https://chatgpt.com/codex/tasks/task_e_685039965f508322968e3c9587a04a06

Summary by Sourcery

Configure Rust formatting, toolchains, and release automation, and reformat the codebase to match the new rules.

Enhancements:

  • Apply consistent rustfmt formatting across the entire codebase
  • Reflow doc comments and collapse simple functions into single-line definitions

Build:

  • Add rustfmt configuration file (.rustfmt.toml)
  • Pin nightly Rust toolchain with formatting and linting components (rust-toolchain.toml)

CI:

  • Use nightly toolchain for CI and retain stable toolchain for release builds
  • Introduce GitHub Actions release workflow to build and upload stable artifacts

Summary by CodeRabbit

  • Chores
    • Added a release workflow to automate building and uploading binaries on tagged releases.
    • Introduced configuration files for Rust toolchain and code formatting standards.
  • Style
    • Reformatted and consolidated import statements across multiple files for improved readability.
    • Adjusted documentation comments for better consistency and line wrapping.
    • Reformatted some function implementations to single-line expressions where applicable.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 16, 2025

Reviewer's Guide

This PR establishes a locked nightly toolchain and rustfmt configuration, adds a release workflow that builds on stable, and then reformats the entire codebase to adhere to the new style rules.

File-Level Changes

Change Details Files
Define project-specific rustfmt rules
  • Added .rustfmt.toml with unstable_features, comment_width, imports and wrapping settings
  • Enabled formatting of code and macro matchers, single-line functions, grouped imports
.rustfmt.toml
Pin nightly toolchain for development
  • Created rust-toolchain.toml locking channel to nightly-2025-06-10
  • Included rustfmt and clippy components in the toolchain
rust-toolchain.toml
Introduce GitHub Actions release workflow with stable build
  • Added .github/workflows/release.yml triggered on version tags
  • Installed and overrode to stable toolchain before building
  • Built release artifacts with cargo +stable and uploaded the binary
.github/workflows/release.yml
Reformat codebase according to new rustfmt configuration
  • Reflowed and wrapped doc comments to the configured width
  • Collapsed trivial functions and simple methods into single-line bodies
  • Grouped and ordered imports, condensed wildcard suffixes across modules
src/server.rs
src/extractor.rs
src/preamble.rs
src/app.rs
src/message.rs
src/middleware.rs
tests/preamble.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 16, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update introduces configuration files for continuous integration and Rust development tooling, including a GitHub Actions release workflow, Rust toolchain specification, and code formatting rules. Additionally, it applies consistent import grouping and code style refinements across source and test files, focusing on non-functional, stylistic improvements.

Changes

File(s) Change Summary
.github/workflows/release.yml Added a GitHub Actions workflow for building and uploading release binaries on tag push events.
.rustfmt.toml, rust-toolchain.toml Introduced Rust formatting and toolchain configuration files for consistent style and tool usage.
src/app.rs, src/extractor.rs, src/message.rs,
src/middleware.rs, src/preamble.rs, src/rewind_stream.rs,
src/server.rs, tests/preamble.rs
Consolidated and grouped import statements, reformatted code and documentation comments for style consistency; no logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub
    participant GitHub Actions
    participant Build System

    Developer->>GitHub: Push tag "v*"
    GitHub->>GitHub Actions: Trigger "Release" workflow
    GitHub Actions->>Build System: Checkout code, install Rust toolchain
    Build System->>Build System: Build project (cargo build --release)
    Build System->>GitHub Actions: Upload "wireframe" binary as artifact
Loading

Possibly related PRs

Poem

Hopping through code with a formatting wand,
Imports now gather in a neat little pond.
A workflow appears for releases to run,
Rusty new toolchains—oh, what fun!
With style and precision, the code’s looking bright,
This bunny approves: it’s a coder’s delight!
🐇✨

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch codex/update-formatting-and-ci-configurations
  • Post Copyable Unit Tests in Comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread .github/workflows/release.yml Fixed
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leynos - I've reviewed your changes - here's some feedback:

  • Consider splitting the rustfmt configuration and CI toolchain pinning into one commit/PR and the bulk formatting changes into another to keep the revision history and reviews focused.
  • Pinning the toolchain to a specific nightly date may lead to CI breakage when that snapshot expires—consider using the floating nightly channel or a more update‐resilient approach.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider splitting the rustfmt configuration and CI toolchain pinning into one commit/PR and the bulk formatting changes into another to keep the revision history and reviews focused.
- Pinning the toolchain to a specific nightly date may lead to CI breakage when that snapshot expires—consider using the floating `nightly` channel or a more update‐resilient approach.

## Individual Comments

### Comment 1
<location> `rust-toolchain.toml:2` </location>
<code_context>
+[toolchain]
+channel = "nightly-2025-06-10"
+components = ["rustfmt", "clippy"]
</code_context>

<issue_to_address>
Pinning to a specific nightly date may become unavailable

Using a hardcoded nightly date risks breakage if that build is removed. Consider using `channel = "nightly"` or regularly updating the date.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
channel = "nightly-2025-06-10"
=======
channel = "nightly"
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `src/server.rs:337` </location>
<code_context>
 #[allow(clippy::type_complexity)]
 /// Runs a worker task that accepts incoming TCP connections and processes them asynchronously.
 ///
</code_context>

<issue_to_address>
Missing module-level item comment (`//!`) at the top of the file.

Please add a module-level item comment at the top of this file using the `//!` syntax to describe the purpose of the module, as required by the review instructions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread rust-toolchain.toml
Comment thread src/server.rs
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🔭 Outside diff range comments (1)
src/extractor.rs (1)

32-113: Expand single-line functions to multi-line blocks
Prettier checks require methods and functions to be defined over multiple lines.

--- a/src/extractor.rs
+++ b/src/extractor.rs
@@ -31,7 +31,10 @@ impl Payload<'_> {
-    pub fn remaining(&self) -> usize { self.data.len() }
+    pub fn remaining(&self) -> usize {
+        self.data.len()
+    }

 #[deprecated(since = "0.2.0", note = "construct via `inner.into()` instead")]
-    pub fn new(inner: Arc<T>) -> Self { Self(inner) }
+    pub fn new(inner: Arc<T>) -> Self {
+        Self(inner)
+    }
@@ -87,7 +90,10 @@ impl<T: Send + Sync> From<Arc<T>> for SharedState<T> {
-    fn from(inner: Arc<T>) -> Self { Self(inner) }
+    fn from(inner: Arc<T>) -> Self {
+        Self(inner)
+    }
 }
 
 impl<T: Send + Sync> From<T> for SharedState<T> {
-    fn from(inner: T) -> Self { Self(Arc::new(inner)) }
+    fn from(inner: T) -> Self {
+        Self(Arc::new(inner))
+    }
 }
@@ -112,7 +118,10 @@ impl<T: Send + Sync> std::ops::Deref for SharedState<T> {
-    fn deref(&self) -> &Self::Target { &self.0 }
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
 }
🧹 Nitpick comments (3)
src/preamble.rs (1)

50-74: Documentation section now contains duplicated / disordered paragraphs

Lines 59-64 re-introduce the “Errors” heading and explanatory text that already exists immediately above. The result is two “Errors” sections and a broken sentence at line 60 (“Returns a [DecodeError] if decoding the preamble fails or an Asynchronously reads…”).

-/// # Errors
-///
-/// Returns a [`DecodeError`] if decoding the preamble fails or an
-/// Asynchronously reads and decodes ...
+/// # Errors
+///
+/// Returns a [`DecodeError`] if decoding fails or if an I/O error occurs while
+/// reading from the reader.

Cleaning this up avoids confusing rust-doc output.

src/middleware.rs (1)

52-53: Minor doc-comment grammar

“Returns a response produced by the service, or an error if the service fails to handle the request.” reads better without the line break that splits the sentence mid-phrase.

.github/workflows/release.yml (1)

1-25: Restrict GitHub Actions permissions for security
Grant the workflow only the minimal required permissions to reduce risk.

 name: Release
 on:
   push:
     tags:
       - 'v*'
+permissions:
+  contents: read

 jobs:
   build:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41e5e25 and e1da345.

📒 Files selected for processing (11)
  • .github/workflows/release.yml (1 hunks)
  • .rustfmt.toml (1 hunks)
  • rust-toolchain.toml (1 hunks)
  • src/app.rs (3 hunks)
  • src/extractor.rs (5 hunks)
  • src/message.rs (3 hunks)
  • src/middleware.rs (1 hunks)
  • src/preamble.rs (2 hunks)
  • src/rewind_stream.rs (1 hunks)
  • src/server.rs (10 hunks)
  • tests/preamble.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/middleware.rs (4)
src/app.rs (2)
  • new (41-41)
  • service (63-66)
src/extractor.rs (1)
  • new (84-84)
src/rewind_stream.rs (1)
  • new (20-26)
src/server.rs (1)
  • new (68-83)
src/message.rs (1)
src/preamble.rs (1)
  • borrow_decode_from_slice (115-115)
🪛 GitHub Actions: CI
src/middleware.rs

[error] 41-44: Prettier formatting check failed. Function 'new' should be expanded to multiple lines.

src/app.rs

[error] 38-41: Prettier formatting check failed. Code formatting does not match expected style; function 'new' should be expanded to multiple lines.

src/message.rs

[error] 1-7: Prettier formatting check failed. Imports should be formatted on separate lines.


[error] 19-22: Prettier formatting check failed. Function 'to_bytes' should be expanded to multiple lines.

src/server.rs

[error] 186-189: Prettier formatting check failed. Function 'worker_count' should be expanded to multiple lines.

src/extractor.rs

[error] 29-32: Prettier formatting check failed. Method 'remaining' should be formatted with braces and on multiple lines.


[error] 81-84: Prettier formatting check failed. Function 'new' should be expanded to multiple lines.


[error] 88-91: Prettier formatting check failed. Function 'from' should be expanded to multiple lines.


[error] 92-95: Prettier formatting check failed. Function 'from' should be expanded to multiple lines.


[error] 110-113: Prettier formatting check failed. Function 'deref' should be expanded to multiple lines.

🪛 GitHub Check: CodeQL
.github/workflows/release.yml

[warning] 10-24: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

🔇 Additional comments (18)
rust-toolchain.toml (1)

2-3: Nightly toolchain pin may quickly become stale

Locking to a dated nightly (nightly-2025-06-10) gives reproducibility today but is prone to breakage once components disappear from the nightly index or if newer language features are required. Consider:

-channel = "nightly-2025-06-10"
+# Prefer either:
+# channel = "nightly"               # always latest
+#   or
+# channel = "1.XX"                  # stable version if no nightly-only features are used

If nightly is unavoidable, automate periodic bumps (e.g. via dependabot-config.yml) so CI does not silently rot.

src/rewind_stream.rs (1)

1-5: Grouped imports look good

The consolidated std::{ … } import matches the new rustfmt config and keeps the prelude tidy. No functional impact.

src/preamble.rs (1)

1-1: Import consolidation fine – but verify unused items

error::DecodeError is now pulled into the grouped list ― good. Just confirm no orphan use bincode::error::DecodeError; remains elsewhere to avoid duplicates.

tests/preamble.rs (1)

2-8: Import grouping LGTM

The grouped tokio and wireframe imports improve readability and match the new style guide.

src/extractor.rs (1)

1-1: Consolidated imports improve readability
Grouping std imports into a single line reduces clutter and matches project style.

src/app.rs (1)

1-1: Use grouped std imports consistently
The consolidated import use std::{boxed::Box, collections::HashMap, future::Future, pin::Pin}; matches the project’s formatting conventions.

src/server.rs (12)

8-11: Consolidated standard library imports look clean.
Grouping std imports into a single block improves readability and maintainability.


14-18: Tokio imports are well grouped.
The tokio crate imports are logically consolidated, easing future additions or removals.


20-24: Crate imports are neatly sorted.
Imports from the local crate follow a consistent order, enhancing clarity.


55-56: Reflowing doc comments is clear.
The multi-line description now wraps nicely in Rustdoc style and reads well.


87-88: Doc comment adjusted for clarity.
The expanded note about dropping previous callbacks is more explicit.


92-93: Type parameter docs are explicit.
Specifying the required trait bounds in the documentation aids user comprehension.


201-202: Doc comment clarification for bind.
The revised description adds useful context on binding behaviour and error conditions.


249-251: Enhanced method doc for run.
The expanded details on how shutdown is handled improve overall comprehension.


340-342: Worker task doc comments extended.
The elaborated description of exponential backoff and graceful shutdown is helpful.


378-384: Stream processing doc refined.
The documentation now fully covers both success and failure code paths.


436-442: Test imports consolidated.
Grouping std imports within the test module aligns with the project's import style.


446-450: Tokio and test crates neatly grouped.
Consistent consolidation of external crate imports enhances readability.

Comment thread src/middleware.rs
Comment thread src/app.rs
Comment thread src/message.rs
Comment thread src/message.rs
Comment thread .rustfmt.toml
Comment thread src/server.rs
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Release file not needed for wireframe
Use newer sha for toolchain
@leynos leynos merged commit 1016e28 into main Jun 16, 2025
4 of 5 checks passed
@leynos leynos deleted the codex/update-formatting-and-ci-configurations branch June 16, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants