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

scripts: regenerate pbs with caching deps to a fixed tmp folder #7409

Merged
merged 7 commits into from
Jul 17, 2024

Conversation

arvindbr8
Copy link
Member

Fixes #7400

@dfawley I went with something that's more along the lines of option no.3 in the issue. Now the deps are installed in a
"well-known" directory which is /tmp/grpc-go-tools. This will ensure not requiring to re-download all deps when running regenerate.

Changes:

install-protoc.sh

  1. Now requires an INSTALL_PATH to be specified
    • This is a behavior change. Previously INSTALL_PATH was optional and would put it in your GOBIN/GOPATH. We dont want to be polluting the users GO dir with non-golang binaries.
  2. Now checks if protoc in the required version is present in INSTALL_PATH and not $PATH

regenerate.sh

  1. Installs everything to /tmp/grpc-go-tools instead of mktmp
  2. Only download deps if not present
  3. Other shell linter changes

cc: @aranjans

RELEASE NOTES: none

@arvindbr8 arvindbr8 added the Type: Meta Github repo, process, etc label Jul 12, 2024
@arvindbr8 arvindbr8 added this to the 1.66 Release milestone Jul 12, 2024
@arvindbr8 arvindbr8 requested a review from dfawley July 12, 2024 23:31
Copy link

codecov bot commented Jul 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.47%. Comparing base (ecbb837) to head (4a49832).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7409      +/-   ##
==========================================
- Coverage   81.47%   81.47%   -0.01%     
==========================================
  Files         350      350              
  Lines       26843    26846       +3     
==========================================
+ Hits        21871    21873       +2     
- Misses       3784     3785       +1     
  Partials     1188     1188              

see 19 files with indirect coverage changes

Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

LGTM, just some nits.

Comment on lines 93 to 96
# Detect the hardware platform.
ARCH="$(uname -m)"
# Detect the Operating System.
OS="$(uname -s)"
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably delete these vars and do these things in download_binary instead. Note that you're setting ARCH twice to different things, so that's a little confusing, and you're passing these as positional parameters, so separating their usage from their definition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes you are right. I dont know why we needed a function to be defined like this. I've moved everything into main() now. Looks cleaner this way.


./scripts/install-protoc.sh "${WORKDIR}"
"./$(dirname "${0}")/install-protoc.sh" ${WORKDIR}
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to remove ./ at the start? Try executing as /abs/path/to/scripts/regenerate.sh and I think it will fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, for whatever reason i've always run executables with a leading ./. Every time I do a shell PR I learn something new.

I also did not want to put the abs/path since that would require that you run the script from the gRPC-go/ dir

Copy link
Member

Choose a reason for hiding this comment

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

for whatever reason i've always run executables with a leading ./.

If you're running one in the current directory, then that's important. If it's in an absolute path, you'd use /usr/bin/ls, e.g. If it's in a relative path, then either ./bin/foo or bin/foo work.

@@ -31,7 +28,7 @@ mkdir -p "${GOBIN}"
echo "remove existing generated files"
Copy link
Member

Choose a reason for hiding this comment

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

Nit: "Removing existing generated files."

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -31,7 +28,7 @@ mkdir -p "${GOBIN}"
echo "remove existing generated files"
# grpc_testing_not_regenerate/*.pb.go is not re-generated,
# see grpc_testing_not_regenerate/README.md for details.
rm -f $(find . -name '*.pb.go' | grep -v 'grpc_testing_not_regenerate')
find . -name '*.pb.go' | grep -v 'grpc_testing_not_regenerate' | xargs rm -f || true

echo "go install google.golang.org/protobuf/cmd/protoc-gen-go"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe "Executing: go install _______" (etc)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Let me know how you feel about the new echo-s

@@ -40,10 +37,18 @@ echo "go install cmd/protoc-gen-go-grpc"
(cd cmd/protoc-gen-go-grpc && go install .)

echo "git clone https://github.com/grpc/grpc-proto"
git clone --quiet https://github.com/grpc/grpc-proto "${WORKDIR}/grpc-proto"
if [ -d "${WORKDIR}/grpc-proto" ]; then
(cd "${WORKDIR}/grpc-proto" && git pull)
Copy link
Member

Choose a reason for hiding this comment

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

Why parens here (and below)?

Copy link
Member Author

Choose a reason for hiding this comment

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

so that I dont have to cd - after the command :)

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough

@dfawley dfawley assigned arvindbr8 and unassigned dfawley Jul 16, 2024
@arvindbr8 arvindbr8 requested a review from dfawley July 16, 2024 22:38
@arvindbr8 arvindbr8 assigned dfawley and unassigned arvindbr8 Jul 16, 2024
@dfawley dfawley assigned arvindbr8 and unassigned dfawley Jul 17, 2024
@arvindbr8 arvindbr8 merged commit 64adc81 into grpc:master Jul 17, 2024
13 checks passed
printchard pushed a commit to printchard/grpc-go that referenced this pull request Jul 30, 2024
printchard pushed a commit to printchard/grpc-go that referenced this pull request Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Meta Github repo, process, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scripts: fixes/improvements to regenerate.sh / install_protoc.sh
2 participants