Skip to content

Add self-updater for CLI binary#274

Merged
sourya-deepsource merged 6 commits intomasterfrom
self-updater
Mar 10, 2026
Merged

Add self-updater for CLI binary#274
sourya-deepsource merged 6 commits intomasterfrom
self-updater

Conversation

@jai-deepsource
Copy link
Contributor

  • Two-phase update: check manifest, apply on next run
  • Verify archive checksum before replacing binary
  • Skip in CI and dev builds, add config opt-out
  • Bump version to 2.0.45

- Two-phase update: check manifest, apply on next run
- Verify archive checksum before replacing binary
- Skip in CI and dev builds, add config opt-out
- Bump version to 2.0.45
@deepsource-io
Copy link

deepsource-io bot commented Mar 5, 2026

DeepSource Code Review

We reviewed changes in 51594ab...75768cb on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Coverage  

Feedback

  • Mocks mask real-world integration failures
    • Unit tests mock filesystem and network behavior, so runtime issues—partial downloads, permission errors, transport quirks—can slip by; add lightweight integration/contract tests against a sandboxed updater and real artifact samples to surface them.
  • Version parsing may be brittle to format drift
    • Thorough semver tests protect current cases, but upstream metadata or build-metadata changes can break consumers; centralize parsing into a single canonical parser, validate incoming update metadata with a schema, and include real release samples in regression tests.
  • Tests coupled to implementation hinder refactoring
    • Table-driven tests that drive internal mocks and call sequences make refactors fragile and encourage implementation leaks; prefer black-box behavioral tests and golden outputs, keeping mocks confined to a thin adapter layer so tests assert behavior, not internals.

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Mar 10, 2026 6:55a.m. Review ↗
Secrets Mar 10, 2026 6:55a.m. Review ↗
Test coverage Mar 10, 2026 6:55a.m. Review ↗

Code Coverage Summary

Language Line Coverage (New Code) Line Coverage (Overall)
Aggregate
58.9%
[⤫ below threshold]
24.9%
[▲ up 3.2% from master]
Go
58.9%
[⤫ below threshold]
24.9%
[▲ up 3.2% from master]
[✓ above threshold]

➟ Additional coverage metrics may have been reported. See full coverage report ↗

sourya-deepsource and others added 4 commits March 10, 2026 11:35
The CDN serves archives under /build/, but the URL was constructed
without it, causing 404 errors during self-update downloads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Sourya Vatsyayan <sourya@deepsource.io>
- Handle os.UserHomeDir() error to prevent state file in relative paths
- Restrict config dir permissions from 0o755 to 0o750
- Limit download size with io.LimitReader (50MB cap)
- Replace unused parameter `r` with `_` in test handler
- Refactor replaceBinary into testable replaceBinaryAt function
- Rewrite tests to call actual functions instead of reimplementing logic

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Sourya Vatsyayan <sourya@deepsource.io>
- Rewrite TestCheckForUpdate_AlreadyUpToDate to call CheckForUpdate
  with a mock HTTP server instead of reimplementing logic
- Add tests for FetchManifest, downloadFile, and error paths
  (HTTP errors, network errors, checksum mismatch, missing platform,
  nil build info, zip archive path)
- Add parseSemver test cases for invalid minor/patch and pre-release
- Add ClearBuildInfo helper for test setup
- Update package coverage from 47.5% to ~80%

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sourya-deepsource sourya-deepsource merged commit e2a7abb into master Mar 10, 2026
5 checks passed
@sourya-deepsource sourya-deepsource deleted the self-updater branch March 10, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants