feat: migrate to v2 utility libraries (STEP-2449) - #92
Open
Badlazzor wants to merge 1 commit into
Open
Conversation
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
marked this pull request as ready for review
July 24, 2026 15:13
lpusok
reviewed
Jul 30, 2026
|
|
||
| out, err := cmd.RunAndReturnTrimmedCombinedOutput() | ||
| log.Printf(out) | ||
| r.Logger.Printf(out) |
Contributor
There was a problem hiding this comment.
preexisting, but can we just stream to stdout?
lpusok
reviewed
Jul 30, 2026
| } | ||
|
|
||
| var outputBuf bytes.Buffer | ||
| writer := io.MultiWriter(&outputBuf) |
Contributor
There was a problem hiding this comment.
preexisting, but do we need MultiWriter for a single stream?
lpusok
reviewed
Jul 30, 2026
| return err | ||
| } else if !exist { | ||
| return fmt.Errorf("Build Artifact not exist at: %s", buildArtifactPth) | ||
| if helper.pathChecker != nil { |
Contributor
There was a problem hiding this comment.
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.
lpusok
reviewed
Jul 30, 2026
|
|
||
| prinatableCmd := command.PrintableCommandArgs(false, secureSignCmd(cmdSlice)) | ||
| log.Printf("=> %s", prinatableCmd) | ||
| helper.runner.Logger.Printf("=> %s", helper.runner.PrintableCommandArgs(secureSignCmd(cmdSlice))) |
Contributor
There was a problem hiding this comment.
Could move PrintableCommandArgs inside ExecuteForOutput, so no need for runner.PrintableCommandArgs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go-utils(command,errorutil,log,pathutil) andgo-steputils(stepconf,tools) imports from step source.log.Logger,command.Factory,pathutil.PathChecker/PathModifier/PathProvider,fileutil.FileManager, andexport.Exporterthrough the call graph via explicit parameters.keystorepackage gains aRunner(Logger + CmdFactory) andHelpergains aPathChecker; both are now dependency-injected instead of reaching into v1 package-level APIs.NewKeystoreSignatureConfigurationsimilarly takeslogger+cmdFactoryand stores them onSignatureConfiguration.errors.As(err, *command.ExitStatusError)replaceserrorutil.IsExitStatusError.Parent milestone: STEP-2381
Ticket: STEP-2449
Notes
go-utilsretained as// indirect:go-androidv1 (kept per ticket scope — Milestone 5 handles it) transitively pullsgo-utils/pathutil. Directrequireblock is v2-only.go-steputilsfully removed fromgo.mod— nothing pulls it now thatstepconfandtoolsare 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.PrintableCommandArgsinkeystore,printableCommandArgsinapksigner.go) that build a throwaway command via the factory and returnPrintableCommandArgs().command.CopyFile(src, dst)→fileManager.CopyFile(src, dst, &fileutil.CopyOptions{Overwrite: true})— v1command.CopyFileusedcp -fsemantics (always overwrite); explicitOverwrite: truematches.tools.ExportEnvironmentWithEnvman→export.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: v1command/gitwas removed in v2. Swapped foros/exec.CommandContextto run thegit clone— same behavior, no dependency on any specificgitwrapper.godirective: bumped 1.16 → 1.21 (testify v1.9 needs 1.21).Test_parseAPKextractNativeLibs,TestPrettyBuildArtifactBasename,TestFilterMETAFiles,TestFilterSigningFiles,TestCreateSignCmd,TestFindSignatureAlgorithmall 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).go-utils/go-steputilsimports in step source (verified locally).go.mod: v2 libs only in the directrequireblock; v1go-utilsdemoted to// indirect; v1go-steputilsremoved.check,e2e) passes on Bitrise CI.🤖 Generated with Claude Code