Skip to content

feat: Improve auto-updater coverage and fix CI coverage command#9

Merged
echobt merged 2 commits intoPlatformNetwork:mainfrom
cuteolaf:test/auto-updater
Jan 7, 2026
Merged

feat: Improve auto-updater coverage and fix CI coverage command#9
echobt merged 2 commits intoPlatformNetwork:mainfrom
cuteolaf:test/auto-updater

Conversation

@cuteolaf
Copy link
Contributor

@cuteolaf cuteolaf commented Jan 6, 2026

  • add test-only pull hook, shutdown delay toggle, and new unit tests to updater.rs, plus extra coverage for version.rs and watcher.rs
  • update the CI workflow to use distinct output flags for json vs html in the cargo llvm-cov nextest step, resolving the duplicate --output-path error

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for the auto-updater: pull process, restart signaling, mandatory update handling, update orchestration, version parsing defaults, and watcher behavior.
  • Chores
    • CI workflow updated to change where HTML coverage reports are written.

✏️ Tip: You can customize this high-level summary in your review settings.

- add test-only pull hook, shutdown delay toggle, and new unit tests to
  `updater.rs`, plus extra coverage for `version.rs` and `watcher.rs`
- update the CI workflow to use distinct output flags for json vs html
  in the `cargo llvm-cov nextest` step, resolving the duplicate
  `--output-path` error
@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

Adds test-only hook support to the auto-updater pull flow, expands unit tests across updater, version, and watcher modules, and updates the CI workflow to change the cargo-llvm-cov HTML output option.

Changes

Cohort / File(s) Summary
CI Workflow Configuration
.github/workflows/ci.yml
Replaced cargo-llvm-cov --output-path coverage.html with --output-dir coverage-html, changing where HTML coverage is produced.
Auto-Updater Test Infrastructure & Tests
crates/auto-updater/src/updater.rs
Introduced a test-only PullHook type alias and pull_hook: Option<PullHook> field on AutoUpdater (behind #[cfg(test)]); added test-only SHUTDOWN_DELAY_SECS variant and conditional shutdown behavior; modified pull_image to invoke the hook when present; expanded test suite covering pull hook behavior, mandatory update handling, restart signaling, image formatting, and end-to-end update/pull interactions.
Version Unit Tests
crates/auto-updater/src/version.rs
Added unit tests: default equals current version and invalid parse inputs ("1.2", "1.2.3.4", "a.b.c"). No runtime API changes.
Watcher Unit Tests
crates/auto-updater/src/watcher.rs
Added tests for VersionWatcher accessor, builder default/custom intervals, and status logic when required version equals current version. No runtime API changes.

Sequence Diagram(s)

(omitted — changes are test hooks and unit tests without a new multi-component runtime control flow that warrants a sequence diagram)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 In tests I hop where hooks abide,

I mimic pulls and skip the tide.
Coverage finds its tidy nest,
Versions checked, the code at rest.
A cheerful nibble, then a jest. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: improving auto-updater test coverage and fixing the CI coverage command flag.
Docstring Coverage ✅ Passed Docstring coverage is 84.38% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19a6e0d and f572dd8.

📒 Files selected for processing (1)
  • crates/auto-updater/src/updater.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/auto-updater/src/updater.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cuteolaf cuteolaf marked this pull request as draft January 6, 2026 16:23
Copy link

@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: 1

🤖 Fix all issues with AI Agents
In @crates/auto-updater/src/updater.rs:
- Around line 280-286: The test currently calls
updater.check_and_update().await.unwrap() and then discards the boolean returned
by matches!(result, UpdateResult::NoUpdateAvailable |
UpdateResult::AlreadyUpToDate), so the assertion has no effect; replace the bare
matches! usage with an actual assertion such as assert!(matches!(result,
UpdateResult::NoUpdateAvailable | UpdateResult::AlreadyUpToDate)) (or an
appropriate assert_eq!/matches! variant) so the test fails when
updater.check_and_update().await.unwrap() does not return one of the expected
UpdateResult variants.
🧹 Nitpick comments (1)
crates/auto-updater/src/updater.rs (1)

311-322: Edge case: future_version() returns current version when all components are u32::MAX.

While extremely unlikely in practice, if current has all components at u32::MAX, this returns the same version rather than a "future" one. The test using this helper (make_future_requirement) would then test the "already up to date" path instead of the intended "needs update" path.

This is a minor robustness concern for test reliability. Consider adding a panic! or using a sentinel version for clarity.

🔎 Optional: fail explicitly if no future version is possible
         } else if current.major < u32::MAX {
             Version::new(current.major + 1, 0, 0)
         } else {
-            current
+            panic!("Cannot create future version: all components are u32::MAX")
         }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 299d25a and 19a6e0d.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • crates/auto-updater/src/updater.rs
  • crates/auto-updater/src/version.rs
  • crates/auto-updater/src/watcher.rs
🧰 Additional context used
🧬 Code graph analysis (1)
crates/auto-updater/src/updater.rs (2)
crates/auto-updater/src/version.rs (2)
  • new (16-22)
  • current (25-31)
crates/auto-updater/src/watcher.rs (2)
  • new (20-29)
  • new (113-117)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Clippy
🔇 Additional comments (8)
.github/workflows/ci.yml (1)

74-74: LGTM!

The separation of --output-path for JSON and --output-dir for HTML correctly resolves the duplicate flag conflict. The downstream references to coverage-html/ in the artifact upload and GitHub Pages deployment are consistent with this change.

crates/auto-updater/src/version.rs (1)

138-148: LGTM!

The new tests provide good coverage for:

  • Verifying Default trait consistency with current()
  • Validating parse() correctly rejects malformed version strings (too few/many parts, non-numeric)
crates/auto-updater/src/watcher.rs (1)

158-191: LGTM!

The new tests provide comprehensive coverage for:

  • Current version accessor returning expected value
  • Builder pattern with custom and default intervals
  • Status correctly reports UpToDate when requirement matches current version

Accessing check_interval directly is acceptable since tests are in the same module.

crates/auto-updater/src/updater.rs (5)

9-30: LGTM!

The test-only infrastructure is well-designed:

  • PullHook type alias enables mocking Docker pull operations
  • SHUTDOWN_DELAY_SECS eliminates test delays while preserving production graceful shutdown timing
  • Conditional compilation keeps production binaries clean

110-118: LGTM!

The conditional handling for mandatory updates is correct. In tests, returning Ok(()) allows the test to continue and verify behavior, while production code exits to trigger orchestrator restart.


126-129: LGTM!

Clean hook injection pattern that short-circuits real Docker calls during tests while preserving production behavior.


336-449: LGTM!

Excellent test coverage for the update flow:

  • test_handle_update_triggers_restart_signal verifies pull hook invocation and restart signal emission
  • test_check_and_update_reports_updated validates the full update path with watcher integration
  • test_handle_update_mandatory_triggers_shutdown confirms mandatory flag handling

The hook-based approach cleanly isolates tests from Docker dependencies.


451-469: LGTM!

Good negative test case verifying that pull errors propagate correctly through handle_update.

@cuteolaf cuteolaf marked this pull request as ready for review January 6, 2026 17:19
@echobt echobt merged commit d9183f2 into PlatformNetwork:main Jan 7, 2026
6 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.

2 participants