From 29606db6ceaf5c72d6c397155bfd9faba24278ee Mon Sep 17 00:00:00 2001 From: anchore-oss-update-bot Date: Mon, 20 Apr 2026 12:48:19 +0000 Subject: [PATCH 1/2] chore(deps): update Go version Signed-off-by: anchore-oss-update-bot --- .github/actions/bootstrap/action.yaml | 7 +----- cmd/binny/cli/option/duration.go | 6 +++--- cmd/binny/cli/option/duration_test.go | 2 +- event/parsers.go | 4 ++-- go.mod | 2 +- internal/http/logger_adapter.go | 8 +++---- internal/log/log.go | 24 ++++++++++----------- test/cli/trait_assertions_test.go | 2 +- tool/githubrelease/installer.go | 4 ++-- tool/githubrelease/version_resolver.go | 2 +- tool/githubrelease/version_resolver_test.go | 4 ++-- tool/goproxy/version_resolver.go | 5 +---- tool/goproxy/version_resolver_test.go | 8 +++---- 13 files changed, 35 insertions(+), 43 deletions(-) diff --git a/.github/actions/bootstrap/action.yaml b/.github/actions/bootstrap/action.yaml index 331db86..6d67cf5 100644 --- a/.github/actions/bootstrap/action.yaml +++ b/.github/actions/bootstrap/action.yaml @@ -4,7 +4,7 @@ inputs: go-version: description: "Go version to install" required: true - default: "1.26.x" + default: "1.26.2" cache-key-prefix: description: "Prefix all cache keys with this value" required: true @@ -12,14 +12,12 @@ inputs: bootstrap-apt-packages: description: "Space delimited list of tools to install via apt" default: "" - runs: using: "composite" steps: - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version: ${{ inputs.go-version }} - - name: Restore tool cache id: tool-cache uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 @@ -29,15 +27,12 @@ runs: restore-keys: | ${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool-${{ hashFiles('Taskfile.yaml') }} ${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool - - name: (cache-miss) Bootstrap project tools shell: bash run: make ci-bootstrap-tools - - name: Bootstrap go dependencies shell: bash run: make ci-bootstrap-go - - name: Install apt packages if: inputs.bootstrap-apt-packages != '' shell: bash diff --git a/cmd/binny/cli/option/duration.go b/cmd/binny/cli/option/duration.go index 1e74a28..db1c3b1 100644 --- a/cmd/binny/cli/option/duration.go +++ b/cmd/binny/cli/option/duration.go @@ -25,8 +25,8 @@ func (d *JSONDuration) UnmarshalText(text []byte) error { } // support "Nd" shorthand for days - if strings.HasSuffix(s, "d") { - prefix := strings.TrimSuffix(s, "d") + if before, ok := strings.CutSuffix(s, "d"); ok { + prefix := before days, err := strconv.Atoi(prefix) if err != nil { return fmt.Errorf("invalid duration %q: %w", string(text), err) @@ -63,7 +63,7 @@ func (d JSONDuration) MarshalText() ([]byte, error) { return []byte(d.Duration.String()), nil } -func (d *JSONDuration) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (d *JSONDuration) UnmarshalYAML(unmarshal func(any) error) error { var s string if err := unmarshal(&s); err != nil { return err diff --git a/cmd/binny/cli/option/duration_test.go b/cmd/binny/cli/option/duration_test.go index 1f6f72a..38f53bf 100644 --- a/cmd/binny/cli/option/duration_test.go +++ b/cmd/binny/cli/option/duration_test.go @@ -144,7 +144,7 @@ func TestJSONDuration_UnmarshalYAML(t *testing.T) { } var d JSONDuration - err := d.UnmarshalYAML(func(v interface{}) error { + err := d.UnmarshalYAML(func(v any) error { ptr, ok := v.(*string) if !ok { t.Fatal("expected *string") diff --git a/event/parsers.go b/event/parsers.go index 7472f5b..f4f94a3 100644 --- a/event/parsers.go +++ b/event/parsers.go @@ -20,14 +20,14 @@ type ToolUpdate interface { type ErrBadPayload struct { Type partybus.EventType Field string - Value interface{} + Value any } func (e *ErrBadPayload) Error() string { return fmt.Sprintf("event='%s' has bad event payload field='%v': '%+v'", string(e.Type), e.Field, e.Value) } -func newPayloadErr(t partybus.EventType, field string, value interface{}) error { +func newPayloadErr(t partybus.EventType, field string, value any) error { return &ErrBadPayload{ Type: t, Field: field, diff --git a/go.mod b/go.mod index 0e1de2f..b0b0141 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/anchore/binny -go 1.24.2 +go 1.26.2 require ( github.com/Masterminds/semver/v3 v3.4.0 diff --git a/internal/http/logger_adapter.go b/internal/http/logger_adapter.go index 761ad91..61fe18a 100644 --- a/internal/http/logger_adapter.go +++ b/internal/http/logger_adapter.go @@ -18,18 +18,18 @@ func NewLeveledLogger(lgr logger.Logger) retryablehttp.LeveledLogger { return &leveledLoggerAdapter{lgr: lgr} } -func (l *leveledLoggerAdapter) Error(msg string, keysAndValues ...interface{}) { +func (l *leveledLoggerAdapter) Error(msg string, keysAndValues ...any) { l.lgr.WithFields(keysAndValues...).Error(msg) } -func (l *leveledLoggerAdapter) Warn(msg string, keysAndValues ...interface{}) { +func (l *leveledLoggerAdapter) Warn(msg string, keysAndValues ...any) { l.lgr.WithFields(keysAndValues...).Warn(msg) } -func (l *leveledLoggerAdapter) Info(msg string, keysAndValues ...interface{}) { +func (l *leveledLoggerAdapter) Info(msg string, keysAndValues ...any) { l.lgr.WithFields(keysAndValues...).Info(msg) } -func (l *leveledLoggerAdapter) Debug(msg string, keysAndValues ...interface{}) { +func (l *leveledLoggerAdapter) Debug(msg string, keysAndValues ...any) { l.lgr.WithFields(keysAndValues...).Debug(msg) } diff --git a/internal/log/log.go b/internal/log/log.go index f1249b2..f746747 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -27,61 +27,61 @@ func Get() logger.Logger { } // Errorf takes a formatted template string and template arguments for the error logging level. -func Errorf(format string, args ...interface{}) { +func Errorf(format string, args ...any) { log.Errorf(format, args...) } // Error logs the given arguments at the error logging level. -func Error(args ...interface{}) { +func Error(args ...any) { log.Error(args...) } // Warnf takes a formatted template string and template arguments for the warning logging level. -func Warnf(format string, args ...interface{}) { +func Warnf(format string, args ...any) { log.Warnf(format, args...) } // Warn logs the given arguments at the warning logging level. -func Warn(args ...interface{}) { +func Warn(args ...any) { log.Warn(args...) } // Infof takes a formatted template string and template arguments for the info logging level. -func Infof(format string, args ...interface{}) { +func Infof(format string, args ...any) { log.Infof(format, args...) } // Info logs the given arguments at the info logging level. -func Info(args ...interface{}) { +func Info(args ...any) { log.Info(args...) } // Debugf takes a formatted template string and template arguments for the debug logging level. -func Debugf(format string, args ...interface{}) { +func Debugf(format string, args ...any) { log.Debugf(format, args...) } // Debug logs the given arguments at the debug logging level. -func Debug(args ...interface{}) { +func Debug(args ...any) { log.Debug(args...) } // Tracef takes a formatted template string and template arguments for the trace logging level. -func Tracef(format string, args ...interface{}) { +func Tracef(format string, args ...any) { log.Tracef(format, args...) } // Trace logs the given arguments at the trace logging level. -func Trace(args ...interface{}) { +func Trace(args ...any) { log.Trace(args...) } // WithFields returns a message logger with multiple key-value fields. -func WithFields(fields ...interface{}) logger.MessageLogger { +func WithFields(fields ...any) logger.MessageLogger { return log.WithFields(fields...) } // Nested returns a new logger with hard coded key-value pairs -func Nested(fields ...interface{}) logger.Logger { +func Nested(fields ...any) logger.Logger { return log.Nested(fields...) } diff --git a/test/cli/trait_assertions_test.go b/test/cli/trait_assertions_test.go index 54eb698..a1b87f0 100644 --- a/test/cli/trait_assertions_test.go +++ b/test/cli/trait_assertions_test.go @@ -33,7 +33,7 @@ func assertFileOutput(tb testing.TB, path string, assertions ...traitAssertion) func assertJson(tb testing.TB, _, stdout, _ string, _ int) { tb.Helper() - var data interface{} + var data any if err := json.Unmarshal([]byte(stdout), &data); err != nil { tb.Errorf("expected to find a JSON report, but was unmarshalable: %+v", err) diff --git a/tool/githubrelease/installer.go b/tool/githubrelease/installer.go index 231479d..95f5b62 100644 --- a/tool/githubrelease/installer.go +++ b/tool/githubrelease/installer.go @@ -191,7 +191,7 @@ func downloadAndExtractAsset(ctx context.Context, asset ghAsset, checksumAsset * } } - logFields := map[string]interface{}{ + logFields := map[string]any{ "destination": assetPath, } @@ -868,7 +868,7 @@ func fetchReleaseGithubV4API(ctx context.Context, user, repo, tag string) (*ghRe RateLimit rateLimit } - variables := map[string]interface{}{ + variables := map[string]any{ "repositoryOwner": githubv4.String(user), "repositoryName": githubv4.String(repo), "tagName": githubv4.String(tag), // Null after argument to get first page. diff --git a/tool/githubrelease/version_resolver.go b/tool/githubrelease/version_resolver.go index 0dbc9ce..0b5a5d2 100644 --- a/tool/githubrelease/version_resolver.go +++ b/tool/githubrelease/version_resolver.go @@ -336,7 +336,7 @@ func fetchAllReleasesFromGithubV4API(ctx context.Context, user, repo string) ([] RateLimit rateLimit } - variables := map[string]interface{}{ + variables := map[string]any{ "repositoryOwner": githubv4.String(user), "repositoryName": githubv4.String(repo), "releasesCursor": (*githubv4.String)(nil), // Null after argument to get first page. diff --git a/tool/githubrelease/version_resolver_test.go b/tool/githubrelease/version_resolver_test.go index 765202d..5fec30a 100644 --- a/tool/githubrelease/version_resolver_test.go +++ b/tool/githubrelease/version_resolver_test.go @@ -412,7 +412,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) { name: "cooldown error when all versions are too new", cooldown: 7 * 24 * time.Hour, version: "latest", - wantErr: func(t require.TestingT, err error, _ ...interface{}) { + wantErr: func(t require.TestingT, err error, _ ...any) { require.Error(t, err) var cooldownErr *binny.CooldownError require.ErrorAs(t, err, &cooldownErr) @@ -484,7 +484,7 @@ func TestVersionResolver_UpdateVersion_withCooldown(t *testing.T) { name: "update with cooldown error when all too new", cooldown: 7 * 24 * time.Hour, version: "1.0.0", - wantErr: func(t require.TestingT, err error, _ ...interface{}) { + wantErr: func(t require.TestingT, err error, _ ...any) { require.Error(t, err) var cooldownErr *binny.CooldownError require.ErrorAs(t, err, &cooldownErr) diff --git a/tool/goproxy/version_resolver.go b/tool/goproxy/version_resolver.go index c9ac348..c702cec 100644 --- a/tool/goproxy/version_resolver.go +++ b/tool/goproxy/version_resolver.go @@ -221,10 +221,7 @@ func (v VersionResolver) checkCandidatesForCooldown(ctx context.Context, candida result.absoluteLatest = candidates[0].original } - limit := maxCooldownCandidates - if limit > len(candidates) { - limit = len(candidates) - } + limit := min(maxCooldownCandidates, len(candidates)) result.checkedCount = limit for i := 0; i < limit; i++ { diff --git a/tool/goproxy/version_resolver_test.go b/tool/goproxy/version_resolver_test.go index 98f0a1d..1e92264 100644 --- a/tool/goproxy/version_resolver_test.go +++ b/tool/goproxy/version_resolver_test.go @@ -177,7 +177,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) { name: "cooldown error when all versions are too new", cooldown: 7 * 24 * time.Hour, version: "latest", - wantErr: func(t require.TestingT, err error, _ ...interface{}) { + wantErr: func(t require.TestingT, err error, _ ...any) { require.Error(t, err) var cooldownErr *binny.CooldownError require.ErrorAs(t, err, &cooldownErr) @@ -230,7 +230,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) { availableVersionsFetcher: func(_ context.Context, _ string) ([]string, error) { // generate more candidates than maxCooldownCandidates var versions []string - for i := 0; i < maxCooldownCandidates+5; i++ { + for i := range maxCooldownCandidates + 5 { versions = append(versions, fmt.Sprintf("1.0.%d", i)) } return versions, nil @@ -239,7 +239,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) { // all checked versions are too new return &versionInfo{Version: "1.0.0", Time: newDate}, nil }, - wantErr: func(t require.TestingT, err error, _ ...interface{}) { + wantErr: func(t require.TestingT, err error, _ ...any) { require.Error(t, err) var cooldownErr *binny.CooldownError require.ErrorAs(t, err, &cooldownErr) @@ -309,7 +309,7 @@ func TestVersionResolver_UpdateVersion_withCooldown(t *testing.T) { name: "update with cooldown error when all too new", cooldown: 7 * 24 * time.Hour, version: "1.0.0", - wantErr: func(t require.TestingT, err error, _ ...interface{}) { + wantErr: func(t require.TestingT, err error, _ ...any) { require.Error(t, err) var cooldownErr *binny.CooldownError require.ErrorAs(t, err, &cooldownErr) From 5cf25a096fcefade166aed51dd54909411825c0c Mon Sep 17 00:00:00 2001 From: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Date: Mon, 20 Apr 2026 14:18:06 -0400 Subject: [PATCH 2/2] fix: only packages with test files handed off Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> --- scripts/list_units.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/list_units.py b/scripts/list_units.py index b93c403..2f7ceba 100644 --- a/scripts/list_units.py +++ b/scripts/list_units.py @@ -4,9 +4,16 @@ def go_list_exclude_pattern(owner, project): exclude_pattern = f"{owner}/{project}/test" - result = subprocess.run(["go", "list", "./..."], stdout=subprocess.PIPE, text=True, check=True) + # restrict to packages that contain test files so `go test -coverprofile` + # does not drag test-less packages through the covdata toolchain + result = subprocess.run( + ["go", "list", "-f", "{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}", "./..."], + stdout=subprocess.PIPE, + text=True, + check=True, + ) - filtered_lines = [line for line in result.stdout.splitlines() if exclude_pattern not in line] + filtered_lines = [line for line in result.stdout.splitlines() if line and exclude_pattern not in line] joined_output = ' '.join(filtered_lines)