-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(nix): snapshot builds can now hash files as well #5894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
There was a problem hiding this 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 PR refactors the Nix integration to always use real file hashing (via nix-hash
) instead of the previous zero-only hasher, consolidates two constructors into one, and updates all usages and tests accordingly.
- Consolidate
NewBuild
andNewPublish
into a singleNew
function that always usesrealHasher
. - Remove the
alwaysZeroHasher
andzeroHash
from production code and adjust tests to match the new behavior. - Update all pipeline, publish, and healthcheck references to call
nix.New()
and revise tests innix_test.go
.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
pkg/healthcheck/healthcheck.go | Replaced nix.NewPublish() with nix.New() |
internal/pipeline/pipeline.go | Replaced nix.NewBuild() with nix.New() |
internal/pipe/publish/publish.go | Replaced nix.NewPublish() with nix.New() |
internal/pipe/nix/nix.go | Removed zero-only hasher, consolidated constructors into New |
internal/pipe/nix/nix_test.go | Updated tests to use New() , removed zero-hasher tests |
Comments suppressed due to low confidence (1)
internal/pipe/nix/nix.go:53
- The comment refers only to the publish phase, but
New
now handles both build and publish. Consider updating it to something like// New returns a Nix hashing pipe used in both build and publish phases.
// New returns a pipe to be used in the publish phase.
type unavailableHasher struct{} | ||
|
||
func (m unavailableHasher) Hash(string) (string, error) { | ||
return "", errors.New("unavailable hasher") | ||
} | ||
func (m unavailableHasher) Available() bool { return false } | ||
func (m unavailableHasher) Hash(string) (string, error) { return "", errors.New("unavailable hasher") } | ||
func (m unavailableHasher) Available() bool { return false } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unavailableHasher
type is defined but never used in any test. You can remove this dead code to keep the test file focused.
Copilot uses AI. Check for mistakes.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5894 +/- ##
==========================================
- Coverage 82.68% 82.68% -0.01%
==========================================
Files 165 165
Lines 16520 16516 -4
==========================================
- Hits 13660 13656 -4
Misses 2268 2268
Partials 592 592 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Historically, we used to use
nix-prefetch-url
, so it could only calculate the hashes after the artifacts were pushed, so when using--snapshot
, hashes would always be0000...
.Rather recently, we've changed it to use
nix-hash
instead, so we could also have changed it so it uses real hashes all the time.This PR does that.
Discussion: https://github.com/orgs/goreleaser/discussions/5893