Skip to content

feat: migrate to v2 utility libraries (STEP-2449) - #92

Open
Badlazzor wants to merge 1 commit into
masterfrom
feat/step-2449-v2-deps
Open

feat: migrate to v2 utility libraries (STEP-2449)#92
Badlazzor wants to merge 1 commit into
masterfrom
feat/step-2449-v2-deps

Conversation

@Badlazzor

Copy link
Copy Markdown

Summary

  • Drop direct v1 go-utils (command, errorutil, log, pathutil) and go-steputils (stepconf, tools) imports from step source.
  • Thread a v2 log.Logger, command.Factory, pathutil.PathChecker/PathModifier/PathProvider, fileutil.FileManager, and export.Exporter through the call graph via explicit parameters.
  • keystore package gains a Runner (Logger + CmdFactory) and Helper gains a PathChecker; both are now dependency-injected instead of reaching into v1 package-level APIs.
  • NewKeystoreSignatureConfiguration similarly takes logger + cmdFactory and stores them on SignatureConfiguration.
  • errors.As(err, *command.ExitStatusError) replaces errorutil.IsExitStatusError.

Parent milestone: STEP-2381
Ticket: STEP-2449

Notes

  • v1 go-utils retained as // indirect: go-android v1 (kept per ticket scope — Milestone 5 handles it) transitively pulls go-utils/pathutil. Direct require block is v2-only.
  • v1 go-steputils fully removed from go.mod — nothing pulls it now that stepconf and tools are gone.
  • command.PrintableCommandArgs(false, cmdSlice): v1 exposed a package-level formatter; v2 only exposes it as a method on a constructed command. Wrapped as small helpers (Runner.PrintableCommandArgs in keystore, printableCommandArgs in apksigner.go) that build a throwaway command via the factory and return PrintableCommandArgs().
  • command.CopyFile(src, dst)fileManager.CopyFile(src, dst, &fileutil.CopyOptions{Overwrite: true}) — v1 command.CopyFile used cp -f semantics (always overwrite); explicit Overwrite: true matches.
  • tools.ExportEnvironmentWithEnvmanexport.Exporter.ExportOutput. Same envman invocation under the hood.
  • stepconf.Parse(&cfg)stepconf.NewInputParser(env.NewRepository()).Parse(&cfg); log.SetEnableDebugLog(cfg.VerboseLog)logger.EnableDebugLog(cfg.VerboseLog).
  • apk_info_test.go: v1 command/git was removed in v2. Swapped for os/exec.CommandContext to run the git clone — same behavior, no dependency on any specific git wrapper.
  • go directive: bumped 1.16 → 1.21 (testify v1.9 needs 1.21).
  • No new unit tests (Milestone 6, out of scope). Existing Test_parseAPKextractNativeLibs, TestPrettyBuildArtifactBasename, TestFilterMETAFiles, TestFilterSigningFiles, TestCreateSignCmd, TestFindSignatureAlgorithm all pass with -race.

Test plan

  • go build ./... passes (verified locally).
  • go test -race ./... passes — all 6 existing tests green (verified locally).
  • go vet ./... clean (verified locally).
  • Grep gate: no direct v1 go-utils / go-steputils imports in step source (verified locally).
  • go.mod: v2 libs only in the direct require block; v1 go-utils demoted to // indirect; v1 go-steputils removed.
  • Step CI (check, e2e) passes on Bitrise CI.

🤖 Generated with Claude Code

Drop direct v1 go-utils (command, errorutil, log, pathutil) and
go-steputils (stepconf, tools) imports. Route command execution through
a v2 command.Factory, log via v2 log.Logger, path checks via
pathutil.PathChecker/PathModifier/PathProvider, artifact copies via
fileutil.FileManager, envman exports via export.Exporter.

The keystore package gains a Runner (Logger + CmdFactory) and Helper
gains a PathChecker so both are dependency-injected instead of reaching
into the v1 package-level API. NewKeystoreSignatureConfiguration
similarly takes logger + factory.

v1 go-utils remains as // indirect (transitively pulled by go-android
v1, which is out of scope per Milestone 5). v1 go-steputils is dropped
entirely. go directive bumped 1.16 -> 1.21 (testify v1.9 requirement).

apk_info_test.go swaps v1 command/git for os/exec.CommandContext.

No new unit tests (Milestone 6, out of scope). Existing tests updated
to match the new signatures and pass locally with -race.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Badlazzor
Badlazzor marked this pull request as ready for review July 24, 2026 15:13
Comment thread keystore/keystore.go

out, err := cmd.RunAndReturnTrimmedCombinedOutput()
log.Printf(out)
r.Logger.Printf(out)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

preexisting, but can we just stream to stdout?

Comment thread keystore/keystore.go
}

var outputBuf bytes.Buffer
writer := io.MultiWriter(&outputBuf)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

preexisting, but do we need MultiWriter for a single stream?

Comment thread keystore/keystore.go
return err
} else if !exist {
return fmt.Errorf("Build Artifact not exist at: %s", buildArtifactPth)
if helper.pathChecker != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if pathChecker is nil, we will just continue without an error. It would be better to check earlier that it is not nil, here we can assume it is not nil.

Comment thread keystore/keystore.go

prinatableCmd := command.PrintableCommandArgs(false, secureSignCmd(cmdSlice))
log.Printf("=> %s", prinatableCmd)
helper.runner.Logger.Printf("=> %s", helper.runner.PrintableCommandArgs(secureSignCmd(cmdSlice)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could move PrintableCommandArgs inside ExecuteForOutput, so no need for runner.PrintableCommandArgs.

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