Skip to content

Migrate go utils v2 - #33

Open
pgyula wants to merge 5 commits into
mainfrom
migrate-go-utils-v2
Open

Migrate go utils v2#33
pgyula wants to merge 5 commits into
mainfrom
migrate-go-utils-v2

Conversation

@pgyula

@pgyula pgyula commented Jul 24, 2026

Copy link
Copy Markdown

Checklist

  • I've read and followed the Contribution Guidelines
  • step.yml and README.md is updated with the changes (if needed)

Version

Requires a MAJOR/MINOR/PATCH version update

Context

Changes

Investigation details

Decisions

pgyula and others added 3 commits July 24, 2026 15:44
Swap the step's three remaining v1 go-utils usages for their v2
equivalents: retry (identical API, import-path swap only),
filedownloader (reshaped as an injected Downloader interface,
ctx moves from constructor to Download() call), and pathutil
(NormalizedOSTempDirPath becomes an injected PathProvider).

PathProvider is threaded through NewIntermediateFileDownloader and
NewConcurrentArtifactDownloader alongside the existing Logger/
CommandFactory/EnvRepository injection, rather than calling the v2
package function inline.

go-utils v1 moves to `// indirect` in go.mod - go-steputils/v2's own
stepenv->export chain and the got download library both still pull
it in internally, which is outside this step's control.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
downloadFile's single-threaded fallback (416 / unexpected EOF) only
reaches go-utils/v2/filedownloader after downloadWithRetry's real
5x5s backoff, so it isn't covered by exercising downloadFile
end-to-end. Test it directly instead, the same way the fallback
branch constructs and calls it: success writes the destination file,
a non-200 response returns an error and never creates the file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Previous steps in this CI workflow created uncommitted file changes
(e.g. a code formatter, linter, or code generator). This commit
captures those changes.

https://github.com/bitrise-steplib/bitrise-step-autofix-ci

Modified files:
- README.md
Previous steps in this CI workflow created uncommitted file changes
(e.g. a code formatter, linter, or code generator). This commit
captures those changes.

https://github.com/bitrise-steplib/bitrise-step-autofix-ci

Modified files:
- README.md
Comment thread downloader/artifact_downloader_test.go Outdated
The previous two tests constructed go-utils/v2/filedownloader directly and
asserted on it, which tests the dependency rather than the step's fallback
branch. They only existed because downloadWithRetry's 5x5s backoff made the
fallback unreachable in a reasonable test.

Make the backoff injectable instead: downloadWithRetry takes a retry.Sleeper
(nil keeps the real time.Sleep in production), so the fallback can be driven
end-to-end through downloadFile. The tests now serve a 416 to got's
`Range: bytes=0-0` probe -- the real-world 0-byte-file case the fallback exists
for -- and assert that the single-threaded download takes over and writes the
file, and that a failing fallback surfaces the wrapped error with no file left
behind.

The same seam removes the real backoff from the two pre-existing retry tests:
the downloader package now runs in 5s instead of 55s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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