Skip to content

Feat/new realese update - #3

Merged
DoniLite merged 3 commits into
masterfrom
feat/new-realese-update
Apr 23, 2026
Merged

Feat/new realese update#3
DoniLite merged 3 commits into
masterfrom
feat/new-realese-update

Conversation

@DoniLite

@DoniLite DoniLite commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

Introduce auto-discovered configuration file loading, improve Rust build caching and multi-arch Docker publishing, bump workspace version, and add a formal design system document.

New Features:

  • Add automatic discovery of the Mailify TOML configuration file across conventional locations, falling back to env vars.

Enhancements:

  • Extend configuration loading to resolve a per-user and system-wide config file via a prioritized search order.
  • Refine Dockerfile to use cargo-chef based multi-stage builds for more efficient Rust dependency caching and rebuild times.

Build:

  • Bump workspace package version to 0.1.2.
  • Switch Docker image publishing to a per-architecture build pipeline with a follow-up manifest creation step while preserving multi-arch support.

CI:

  • Replace single multi-arch Docker build job with a matrix of per-platform builds that publish digests and a dedicated manifest job to assemble and inspect the final image.

Documentation:

  • Document configuration precedence and discovery order in the Rust config crate docs.
  • Add a comprehensive DESIGN.md describing the visual and brand design system for Mailify.

Tests:

  • Add unit tests covering configuration candidate resolution and XDG configuration directory precedence.

@sourcery-ai

sourcery-ai Bot commented Apr 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implements auto-discovery for the Mailify TOML config file (with platform-aware search paths and tests), refactors the Docker build to use cargo-chef for better caching, reworks the CI Docker workflow into per-arch builds plus a manifest aggregation job, bumps the workspace version, and adds a comprehensive design system document.

Flow diagram for TOML config auto-discovery

flowchart TD
  Start([Start config discovery]) --> CheckEnv{MAILIFY_CONFIG set?}
  CheckEnv -- Yes --> EnvPath["Use path from MAILIFY_CONFIG"]
  EnvPath --> ExistsEnv{File exists?}
  ExistsEnv -- Yes --> UseEnv["Return MAILIFY_CONFIG path"]
  ExistsEnv -- No --> CheckCwd

  CheckEnv -- No --> CheckCwd{{"Mailify.toml in CWD?"}}
  CheckCwd -- Yes --> UseCwd["Return ./Mailify.toml"]
  CheckCwd -- No --> UserDir{user_config_dir available?}

  UserDir -- Yes --> UserPath["user_config_dir/mailify/config.toml"]
  UserPath --> ExistsUser{File exists?}
  ExistsUser -- Yes --> UseUser["Return per-user config path"]
  ExistsUser -- No --> CheckEtc

  UserDir -- No --> CheckEtc

  subgraph UnixOnly[Unix-only step]
    CheckEtc{{"/etc/mailify/config.toml exists?"}}
  end

  CheckEtc -- Yes --> UseEtc["Return /etc/mailify/config.toml"]
  CheckEtc -- No --> None["Return None (no config file)"]

  UseEnv --> End([End])
  UseCwd --> End
  UseUser --> End
  UseEtc --> End
  None --> End
Loading

Flow diagram for Dockerfile multi-stage build with cargo-chef

flowchart LR
  A[bun-builder\nbuild templates-parser] --> ChefBase[chef stage\ninstall cargo-chef]
  ChefBase --> Planner[planner stage\ncopy manifests + crates\n`cargo chef prepare`]
  Planner --> Cacher[cacher stage\n`cargo chef cook --release`\ncache deps]
  Cacher --> Builder[rs-builder stage\ncopy target + cargo dirs\ncopy sources\n`cargo build --release --bin mailify`]
  Builder --> Final[final image stage\ncopy `mailify` binary\ncopy built templates\nset entrypoint]
Loading

File-Level Changes

Change Details Files
Add platform-aware TOML config auto-discovery to AppConfig loading, with helper utilities and unit tests.
  • Update documentation comments on config precedence and dotenv behavior to describe auto-discovery semantics and search order.
  • Replace direct use of MAILIFY_CONFIG in AppConfig::load with a new discover_config_file helper.
  • Introduce config_candidates and user_config_dir helpers to compute candidate config paths based on env vars and OS (Unix vs Windows).
  • Limit /etc/mailify/config.toml and $HOME-based paths to Unix builds via cfg(unix), and APPDATA-based paths to Windows builds via cfg(windows).
  • Add unit tests that verify MAILIFY_CONFIG and ./Mailify.toml are present in candidates and that user_config_dir prefers XDG_CONFIG_HOME when set.
crates/mailify-config/src/lib.rs
Restructure CI Docker workflow into per-platform builds producing digests and a separate manifest-creation job.
  • Split the single docker job into docker-build (matrix over linux/amd64 and linux/arm64) and docker-manifest jobs.
  • Use per-arch runners and docker/setup-buildx-action with build-push-action to build images per platform and push by digest with registry caching keyed by arch.
  • Export build digests as artifacts from docker-build and consume them in docker-manifest via actions/download-artifact.
  • Create and push a multi-arch manifest list using docker buildx imagetools create, wiring in tags from docker/metadata-action and the per-arch digests, then inspect the resulting image.
.github/workflows/ci.yml
Optimize Dockerfile Rust build stage using cargo-chef to maximize dependency caching across builds.
  • Introduce a multi-stage cargo-chef workflow with separate chef, planner, cacher, and rs-builder stages.
  • Install cargo-chef with a cached cargo registry layer to speed up repeated installs.
  • Use cargo chef prepare to generate a recipe.json from the workspace manifests and then cargo chef cook to build and cache dependencies only.
  • Reuse the cached target and cargo directories in the final Rust builder stage before running cargo build --release --bin mailify.
docker/Dockerfile
Version bump for the Rust workspace to reflect the new release.
  • Increment workspace package version from 0.1.0 to 0.1.2 in Cargo.toml.
  • Regenerate Cargo.lock to align with the new version and any dependency resolution changes.
Cargo.toml
Cargo.lock
Add a comprehensive design system specification for Mailify.
  • Introduce DESIGN.md describing brand positioning, color and typography tokens, spacing, components, motion, accessibility, and responsive behavior.
  • Define concrete design rules and assets inventory to guide future UI/UX work and documentation styling.
  • Establish versioning guidelines for the design document itself.
DESIGN.md

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The test helpers mutate process environment variables inside unsafe blocks, which is unnecessary and can lead to flaky, racy tests when run in parallel—consider encapsulating env save/restore in a safe helper (or using a crate like temp_env) and marking these tests as serial if needed.
  • config_candidates eagerly allocates a Vec<PathBuf> just to scan for the first existing file; you could simplify and avoid allocation by returning an iterator (e.g. impl Iterator<Item = PathBuf>) and letting discover_config_file chain candidates lazily.
  • In the CI workflow the docker-build job exposes outputs.image but the final docker-manifest job recomputes tags via a separate docker/metadata-action and never uses that output—either wire the image output through or drop it to avoid confusion about which metadata source is authoritative.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The test helpers mutate process environment variables inside `unsafe` blocks, which is unnecessary and can lead to flaky, racy tests when run in parallel—consider encapsulating env save/restore in a safe helper (or using a crate like `temp_env`) and marking these tests as serial if needed.
- `config_candidates` eagerly allocates a `Vec<PathBuf>` just to scan for the first existing file; you could simplify and avoid allocation by returning an iterator (e.g. `impl Iterator<Item = PathBuf>`) and letting `discover_config_file` chain candidates lazily.
- In the CI workflow the `docker-build` job exposes `outputs.image` but the final `docker-manifest` job recomputes tags via a separate `docker/metadata-action` and never uses that output—either wire the `image` output through or drop it to avoid confusion about which metadata source is authoritative.

## Individual Comments

### Comment 1
<location path="crates/mailify-config/src/lib.rs" line_range="234-236" />
<code_context>
+fn config_candidates() -> Vec<PathBuf> {
+    let mut out = Vec::new();
+
+    if let Ok(explicit) = std::env::var("MAILIFY_CONFIG") {
+        out.push(PathBuf::from(explicit));
+    }
+
</code_context>
<issue_to_address>
**suggestion:** Empty `MAILIFY_CONFIG` values are treated as a path and become `.` implicitly.

When `MAILIFY_CONFIG` is set to an empty string, `PathBuf::from("")` becomes `"."`, so the current directory is added as a candidate and then `is_file()` is called on it. That’s a surprising interpretation of an empty override. Consider skipping empty values explicitly (e.g. check `!explicit.is_empty()` before pushing) so the env var only acts as a file path when it’s non-empty.

```suggestion
    if let Ok(explicit) = std::env::var("MAILIFY_CONFIG") {
        if !explicit.is_empty() {
            out.push(PathBuf::from(explicit));
        }
    }
```
</issue_to_address>

### Comment 2
<location path="docker/Dockerfile" line_range="16-17" />
<code_context>
 RUN apt-get update && apt-get install -y --no-install-recommends \
     pkg-config libssl-dev ca-certificates curl unzip build-essential && rm -rf /var/lib/apt/lists/*
-
+RUN --mount=type=cache,target=/usr/local/cargo/registry \
+    cargo install cargo-chef --locked --version ^0.1
 WORKDIR /w

</code_context>
<issue_to_address>
**suggestion:** The `cargo-chef` version is specified as a semver range, which can hurt build reproducibility.

Using `--version ^0.1` lets `cargo-chef` float to newer minor versions, which can change behavior over time and invalidate cached Docker layers. For more deterministic builds, consider pinning an exact version (e.g. `--version 0.1.XX`) and updating it explicitly when needed.

```suggestion
RUN --mount=type=cache,target=/usr/local/cargo/registry \
    cargo install cargo-chef --locked --version 0.1.67
```
</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 on lines +234 to +236
if let Ok(explicit) = std::env::var("MAILIFY_CONFIG") {
out.push(PathBuf::from(explicit));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Empty MAILIFY_CONFIG values are treated as a path and become . implicitly.

When MAILIFY_CONFIG is set to an empty string, PathBuf::from("") becomes ".", so the current directory is added as a candidate and then is_file() is called on it. That’s a surprising interpretation of an empty override. Consider skipping empty values explicitly (e.g. check !explicit.is_empty() before pushing) so the env var only acts as a file path when it’s non-empty.

Suggested change
if let Ok(explicit) = std::env::var("MAILIFY_CONFIG") {
out.push(PathBuf::from(explicit));
}
if let Ok(explicit) = std::env::var("MAILIFY_CONFIG") {
if !explicit.is_empty() {
out.push(PathBuf::from(explicit));
}
}

Comment thread docker/Dockerfile
Comment on lines +16 to +17
RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo install cargo-chef --locked --version ^0.1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: The cargo-chef version is specified as a semver range, which can hurt build reproducibility.

Using --version ^0.1 lets cargo-chef float to newer minor versions, which can change behavior over time and invalidate cached Docker layers. For more deterministic builds, consider pinning an exact version (e.g. --version 0.1.XX) and updating it explicitly when needed.

Suggested change
RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo install cargo-chef --locked --version ^0.1
RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo install cargo-chef --locked --version 0.1.67

- Created configuration reference documentation detailing all config options, their types, defaults, and purposes.
- Added HTTP API documentation outlining all endpoints, authentication requirements, and request/response formats.
- Introduced a template contract document explaining the directory layout and rendering conventions for templates.
- Compiled a troubleshooting guide covering common errors, debugging tactics, and FAQs to assist users in resolving issues.
- Implemented installation scripts for both Windows (install.ps1) and POSIX systems (install.sh) to simplify the setup process.
- Added a logo image to the static assets for branding purposes.
@DoniLite
DoniLite merged commit 2fecaaf into master Apr 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant