Skip to content

Self Update#164

Merged
michaelbeutler merged 5 commits intomainfrom
feature/self-update
Sep 24, 2025
Merged

Self Update#164
michaelbeutler merged 5 commits intomainfrom
feature/self-update

Conversation

@michaelbeutler
Copy link
Copy Markdown
Contributor

This pull request introduces a new self-update feature for the decoder CLI, allowing users to check for and apply updates directly from the command line. It also improves build metadata handling and adds comprehensive tests for the new update logic and core helpers. The most important changes are grouped below.

Self-update feature and CLI integration

  • Added a new update subcommand in cmd/update.go that checks for the latest release (optionally including release candidates) and replaces the running binary with the latest version, providing user feedback on success or failure.
  • Integrated non-blocking update checks at application startup in cmd/root.go, notifying users if a new version is available.
  • Added the selfupdate package import and supporting context usage to enable update logic in the CLI. [1] [2]

Build and version metadata improvements

  • Updated .goreleaser.yaml to inject build-time metadata (Version, Commit, Date) into the binary using ldflags, and configured release settings for proper draft/prerelease handling. [1] [2]
  • Added cmd/version.go to define version and metadata variables that are set at build time.

Testing and reliability

  • Added extensive unit tests for the self-update logic in internal/selfupdate/selfupdate_test.go and supporting helpers in internal/selfupdate/selfupdate_more_test.go, covering scenarios like release filtering, checksum validation, archive extraction, and error handling. [1] [2]
  • Added a new test suite for common encoding/decoding helpers in pkg/common/helpers_more_test.go, improving reliability of payload validation and encoding routines.

Dependency updates

  • Added golang.org/x/mod as a new dependency in go.mod to support module operations required by the update logic.

Copilot AI review requested due to automatic review settings September 24, 2025 11:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces a comprehensive self-update feature for the decoder CLI, allowing users to check for and apply updates directly from the command line. It also improves build metadata handling by injecting version information at build time via GoReleaser.

  • Adds a new update subcommand with support for stable releases and release candidates
  • Implements non-blocking update notifications at application startup
  • Enhances build configuration to inject version metadata and handle releases properly

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/selfupdate/selfupdate.go Core self-update logic with GitHub API integration, archive handling, and binary replacement
internal/selfupdate/selfupdate_test.go Comprehensive test suite for update functionality including mocking and edge cases
internal/selfupdate/selfupdate_more_test.go Additional tests for helper functions and utility methods
pkg/decoder/decoder_test.go Test coverage for decoder package interfaces and feature checking
pkg/common/helpers_more_test.go Test suite for common helper functions including payload validation and encoding
cmd/update.go Update subcommand implementation with timeout handling and user feedback
cmd/version.go Version metadata variables for build-time injection
cmd/root.go Integration of update checks and version display in root command
.goreleaser.yaml Build configuration updates for metadata injection and release handling
go.mod Addition of golang.org/x/mod dependency
Comments suppressed due to low confidence (2)

internal/selfupdate/selfupdate_test.go:1

  • The defer statement should handle the error from Close() to avoid potential issues in tests. Consider using defer func() { _ = rc.Close() }() for consistency with the rest of the codebase.
package selfupdate

internal/selfupdate/selfupdate_test.go:1

  • Similar to the previous comment, the defer should handle the Close() error. Consider using defer func() { _ = out.Close() }() for consistency.
package selfupdate

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 62.96296% with 120 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/selfupdate/selfupdate.go 62.96% 80 Missing and 40 partials ⚠️
Files with missing lines Coverage Δ
internal/selfupdate/selfupdate.go 62.96% <62.96%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link
Copy Markdown

@michaelbeutler michaelbeutler merged commit f8070b4 into main Sep 24, 2025
8 of 9 checks passed
@michaelbeutler michaelbeutler deleted the feature/self-update branch September 24, 2025 12:03
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