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

introduce new --skip-initial-tidy flag #36

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

Dentrax
Copy link
Contributor

@Dentrax Dentrax commented Aug 3, 2024

This flag would be useful for the cases where old packages contains old dependencies that would require to do replace or update before running go mod tidy.

For example, for the following case:
https://github.com/iwilltry42/confd

It's impossible to use gobump since one of dependencies got renamed, that required replace first:

gobump --packages "github.com/coreos/[email protected] github.com/gogo/[email protected] golang.org/x/[email protected] golang.org/x/[email protected] golang.org/x/tex
[email protected] gopkg.in/[email protected]" --tidy=true --replaces="github.com/hashicorp/consul=github.com/hashicorp/[email protected] github.com/coreos/bbolt=github.com/coreos/[email protected] google.golang.org/grpc=google.golang.org/[email protected] github.com/hashicorp/vault=github.com/hashicorp/[email protected]"
go: github.com/iwilltry42/confd/backends/consul imports
	github.com/hashicorp/consul/api tested by
	github.com/hashicorp/consul/api.test imports
	github.com/hashicorp/serf/serf imports
	github.com/armon/go-metrics: github.com/armon/[email protected]: parsing go.mod:
	module declares its path as: github.com/hashicorp/go-metrics
	        but was required as: github.com/armon/go-metrics

The new --skip-initial-tidy flag solves that by skipping the first go mod tidy run. So that we able to do required updates and replaces before run go mod tidy.

Do git reset --hard and append the new --skip-initial-tidy flag, then expect to see a success output:

2024/08/03 14:58:05 Local Go version: 1.22.5
2024/08/03 14:58:05 Update package: github.com/hashicorp/consul
2024/08/03 14:58:05 Running go mod edit replace ...
2024/08/03 14:58:05 Update package: github.com/coreos/bbolt
2024/08/03 14:58:05 Running go mod edit replace ...
2024/08/03 14:58:05 Update package: google.golang.org/grpc
2024/08/03 14:58:05 Running go mod edit replace ...
2024/08/03 14:58:05 Update package: github.com/hashicorp/vault
2024/08/03 14:58:05 Running go mod edit replace ...
2024/08/03 14:58:05 Update package: github.com/coreos/etcd
2024/08/03 14:58:05 Running go mod edit -droprequire ...
2024/08/03 14:58:05 Running go get ...
2024/08/03 14:58:47 Update package: github.com/gogo/protobuf
2024/08/03 14:58:47 Running go mod edit -droprequire ...
2024/08/03 14:58:47 Running go get ...
2024/08/03 14:58:48 Update package: golang.org/x/net
2024/08/03 14:58:48 Running go mod edit -droprequire ...
2024/08/03 14:58:48 Running go get ...
2024/08/03 14:58:50 Update package: golang.org/x/sys
2024/08/03 14:58:50 Running go get ...
2024/08/03 14:58:50 Update package: golang.org/x/text
2024/08/03 14:58:50 Running go mod edit -droprequire ...
2024/08/03 14:58:50 Running go get ...
2024/08/03 14:58:51 Update package: gopkg.in/yaml.v2
2024/08/03 14:58:51 Running go mod edit -droprequire ...
2024/08/03 14:58:51 Running go get ...
2024/08/03 14:58:53 Running go mod tidy with go version '1.22.5' ...
2024/08/03 14:59:18 Running go mod vendor...

This flag would be useful for the cases where old packages
contains old dependencies that would require to do _replace_
or _update_ before running `go mod tidy`.

Signed-off-by: Dentrax <[email protected]>
@Dentrax Dentrax marked this pull request as draft August 3, 2024 12:08
Copy link
Member

@hectorj2f hectorj2f left a comment

Choose a reason for hiding this comment

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

Looks good to me overall. @Dentrax Could you a test to test this new functionality ?

@hectorj2f
Copy link
Member

hectorj2f commented Aug 4, 2024

Once we ship it, we should add a flag to the gobump pipeline in Wolfi.

@Dentrax
Copy link
Contributor Author

Dentrax commented Aug 4, 2024

Looks good to me overall. @Dentrax Could you a test to test this new functionality ?

Thank you @hectorj2f, I have tried to add a unit test but I'm not sure if I did handle the case correctly. Please take a look when possible.

@Dentrax Dentrax force-pushed the skip-initial-tidy branch from a2c16f9 to 55c69df Compare August 4, 2024 12:49
Signed-off-by: Dentrax <[email protected]>
@Dentrax Dentrax force-pushed the skip-initial-tidy branch from 55c69df to 963fcae Compare August 5, 2024 08:45
@Dentrax
Copy link
Contributor Author

Dentrax commented Aug 5, 2024

CI is failing because of: 'go mod tidy': exit status 2 with output: invalid value "1.20.14" for flag -go: expecting a Go version like "1.20"

Signed-off-by: Hector Fernandez <[email protected]>
Signed-off-by: hectorj2f <[email protected]>
@Dentrax Dentrax marked this pull request as ready for review August 7, 2024 08:50
@Dentrax
Copy link
Contributor Author

Dentrax commented Aug 7, 2024

Thanks for the fixing the CI issue!

@hectorj2f hectorj2f merged commit f45e67e into chainguard-dev:main Aug 7, 2024
5 checks passed
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