Skip to content
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

go_modules: don't raise error for go mod tidy #2830

Merged
merged 6 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ def update_files # rubocop:disable Metrics/AbcSize
def run_go_mod_tidy
return unless tidy?

# NOTE(arslan): use `go mod tidy -e` once Go 1.16 is out:
# https://github.com/golang/go/commit/3aa09489ab3aa13a3ac78b1ff012b148ffffe367
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

command = "go mod tidy"
_, stderr, status = Open3.capture3(ENVIRONMENT, command)
handle_subprocess_error(stderr) unless status.success?

# we explicitly don't raise an error for 'go mod tidy' and silently
# continue here. `go mod tidy` shouldn't block updating versions
# because there are some edge cases where it's OK to fail (such as
# generated files not available yet to us).
Open3.capture3(ENVIRONMENT, command)
end

def run_go_vendor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,16 @@
# OpenAPIV2 has been renamed to openapiv2 in this version
let(:dependency_version) { "v0.5.1" }

it "raises a DependencyFileNotResolvable error" do
error_class = Dependabot::DependencyFileNotResolvable
# NOTE: We explitly don't want to raise a resolvability error from go mod tidy
it "does not raises a DependencyFileNotResolvable error" do
expect { updater.updated_go_sum_content }.
to raise_error(error_class) do |error|
expect(error.message).to include("googleapis/gnostic/OpenAPIv2")
end
to_not raise_error(Dependabot::DependencyFileNotResolvable)
end

it "updates the go.mod" do
expect(updater.updated_go_mod_content).to include(
%(github.com/googleapis/gnostic v0.5.1 // indirect\n)
)
end
end
end
Expand Down