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

fixes toolchain directive getting into go.mod #7884

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions go_modules/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ USER dependabot
COPY --chown=dependabot:dependabot go_modules $DEPENDABOT_HOME/go_modules
COPY --chown=dependabot:dependabot common $DEPENDABOT_HOME/common
COPY --chown=dependabot:dependabot updater $DEPENDABOT_HOME/dependabot-updater

# See https://tip.golang.org/doc/toolchain#select
# By specifying go1.20, we use 1.20 for any go.mod with go directive <=1.20.
# By specifying auto, it automatically downloads the correct version if the go.mod is > 1.20,
# unless it's already downloaded, like Go 1.21.0 above.
ENV GOTOOLCHAIN="go1.20+auto"
# This pre-installs go 1.20 so that each job doesn't have to do it.
RUN go version
9 changes: 9 additions & 0 deletions go_modules/spec/dependabot/go_modules/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ module declares its path as: go.etcd.io/bbolt
end
end

context "pre 1.21 go.mod that uses a 1.21 dependency" do
let(:project_name) { "toolchain" }
let(:files) { [go_mod] }

it "doesn't add a toolchain directive" do
expect(updated_files.first&.content).to_not include("toolchain")
jakecoffman marked this conversation as resolved.
Show resolved Hide resolved
end
end

context "without a clone of the repository" do
before do
# We don't have git configured in prod, so simulate the same setup here
Expand Down
7 changes: 7 additions & 0 deletions go_modules/spec/fixtures/projects/toolchain/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/dependabot/vgotest

go 1.20

require (
tailscale.com v1.48.1
)
3 changes: 3 additions & 0 deletions go_modules/spec/fixtures/projects/toolchain/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package toolchain

import _ "tailscale.com/log/sockstatlog"