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

Clear go.mod after vendor scripts ran #3536

Closed
wants to merge 2 commits into from

Conversation

benja-M-1
Copy link
Member

@benja-M-1 benja-M-1 commented Apr 6, 2022

- What I did

This PR adds an option to remove the go.mod stub when executing a ./script/vendor command. It avoids go build to fail because of unconsistencies between go.mod and vendor/modules.txt files.

This PR also

  • fixes the ./scripts/vendor to display the usage command when no command is passed
  • adds the clean command called after yaml and man docs have been generated

- How I did it

When the following commands are ran

make vendor
make binary

go build fails with the message

go build -o build/docker-linux-arm64 -tags  -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=b82d9a7742" -X "github.com/docker/cli/cli/version.BuildTime=2022-04-06T11:45:13Z" -X "github.com/docker/cli/cli/version.Version=20.10.0-dev"' github.com/docker/cli/cmd/docker
go: inconsistent vendoring in /go/src/github.com/docker/cli:
	github.com/Azure/go-ansiterm@v0.0.0-20210617225240-d185dfc1b5a1: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
...

- How to verify it

- Description for the changelog

Clean up go.mod file after vendors have been updated, validated or list outdated.

- A picture of a cute animal (not mandatory but encouraged)

@benja-M-1 benja-M-1 force-pushed the feature/clear-go-mod branch 2 times, most recently from e0eda86 to 5148288 Compare April 6, 2022 12:23
@codecov-commenter
Copy link

codecov-commenter commented Apr 6, 2022

Codecov Report

Merging #3536 (bda03ef) into master (0b78efe) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #3536   +/-   ##
=======================================
  Coverage   58.99%   59.00%           
=======================================
  Files         282      284    +2     
  Lines       23813    23816    +3     
=======================================
+ Hits        14049    14053    +4     
  Misses       8908     8908           
+ Partials      856      855    -1     

@benja-M-1 benja-M-1 marked this pull request as draft April 6, 2022 12:24
@benja-M-1 benja-M-1 marked this pull request as ready for review April 6, 2022 12:28
@benja-M-1 benja-M-1 marked this pull request as draft April 6, 2022 13:26
@benja-M-1 benja-M-1 force-pushed the feature/clear-go-mod branch from 5148288 to 2ba210f Compare April 23, 2022 15:53
…d or outdated vendors listed.

This helps to avoid `go build` to fail because of unconsistencies between go.mod and vendor/modules.txt files.

Signed-off-by: Benjamin Grandfond <benjamin.grandfond@docker.com>
@benja-M-1 benja-M-1 force-pushed the feature/clear-go-mod branch 4 times, most recently from 89c12d9 to a00f352 Compare April 23, 2022 17:38
Signed-off-by: Benjamin Grandfond <benjamin.grandfond@docker.com>
@benja-M-1 benja-M-1 force-pushed the feature/clear-go-mod branch from a00f352 to bda03ef Compare April 23, 2022 17:44
@benja-M-1
Copy link
Member Author

benja-M-1 commented Apr 23, 2022

@thaJeztah I finally followed up on this WIP PR. Somehow the test/host (macos-latest) check fails but I fail to understand why. If ever you can help me on that I could mark this PR as reviewable! :)

@thaJeztah
Copy link
Member

Somehow the test/host (macos-latest) check fails but I fail to understand why.

Ah, you can ignore that one; we have a flaky test; see #3441 and #3554 for details.

Comment on lines +80 to +88
while getopts ":c" opt; do
case $opt in
c)
clean
;;
*)
;;
esac
done
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should reverse the option; by default, remove the go.mod, and only if it's needed after it ran, pass an option to --keep (or whatever) the file.

Looking at the changes, I think all (but one) calls of this script expect the go.mod to be deleted afterwards; WDYT?

@benja-M-1 benja-M-1 closed this Mar 26, 2024
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.

3 participants