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: improve regenerate.sh to use the correct proto compiler version #7064

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

aranjans
Copy link
Contributor

@aranjans aranjans commented Mar 25, 2024

Fixes #6583

This PR includes the following changes:

  • Currently the regenerate script installs protoc-gen-go and protoc-gen-go-grpc in a workdir, but uses the system installed protoc which means that running the regenerate.sh script could result in all generated files being changed with a diff in protoc version for the generated files.
  • Now we have a install_protoc.sh script(responsible for installing protobuf on client side in case its not present) which is called by vet.sh and regenerate.sh.

RELEASE NOTES: n/a

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.70%. Comparing base (adf976b) to head (b3106cc).
Report is 85 commits behind head on master.

Current head b3106cc differs from pull request most recent head ab458c5

Please upload reports for the commit ab458c5 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7064      +/-   ##
==========================================
- Coverage   81.24%   80.70%   -0.54%     
==========================================
  Files         345      346       +1     
  Lines       33941    33802     -139     
==========================================
- Hits        27574    27280     -294     
- Misses       5202     5355     +153     
- Partials     1165     1167       +2     

see 33 files with indirect coverage changes

@aranjans aranjans force-pushed the aranjans_6583 branch 2 times, most recently from 8bb8747 to af6bc49 Compare March 25, 2024 17:33
@dfawley dfawley added the Type: Meta Github repo, process, etc label Mar 25, 2024
@dfawley dfawley added this to the 1.64 Release milestone Mar 25, 2024
@dfawley dfawley requested a review from arvindbr8 March 25, 2024 17:37
@aranjans aranjans marked this pull request as ready for review March 25, 2024 17:37
@aranjans aranjans force-pushed the aranjans_6583 branch 2 times, most recently from e404049 to a582a54 Compare March 26, 2024 06:59
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

I would prefer if we didnt track the version of protoc in different places.

What might be nicer is if both regenerate.sh and vet.sh points to the same place to install protoc. Also note ./vet.sh -install basically does the same thing of installing protoc for Github Actions.

I prefer creating a new script which installs protoc based on the ${OS}. And for ./vet -install I could call into the script to install the linux and x86_64 flavor of protoc. And do something similar for regenerate.sh

vet.sh Outdated Show resolved Hide resolved
regenerate.sh Show resolved Hide resolved
regenerate.sh Outdated Show resolved Hide resolved
@aranjans aranjans force-pushed the aranjans_6583 branch 12 times, most recently from 20c21cb to a880e4d Compare March 27, 2024 10:00
@dfawley dfawley assigned arvindbr8 and unassigned aranjans Mar 27, 2024
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

I've made a few comments on your change. Could you please take a look at it?

protoc_installer.sh Outdated Show resolved Hide resolved
protoc_installer.sh Outdated Show resolved Hide resolved
protoc_installer.sh Outdated Show resolved Hide resolved
protoc_installer.sh Outdated Show resolved Hide resolved
protoc_installer.sh Outdated Show resolved Hide resolved
regenerate.sh Outdated Show resolved Hide resolved
regenerate.sh Outdated Show resolved Hide resolved
regenerate.sh Outdated Show resolved Hide resolved
regenerate.sh Outdated Show resolved Hide resolved
protoc_installer.sh Outdated Show resolved Hide resolved
@arvindbr8 arvindbr8 assigned aranjans and unassigned arvindbr8 Mar 29, 2024
@aranjans aranjans force-pushed the aranjans_6583 branch 2 times, most recently from 2cddfeb to cc78601 Compare April 1, 2024 06:40
@aranjans aranjans removed their assignment May 28, 2024
scripts/install_protoc.sh Outdated Show resolved Hide resolved
scripts/install_protoc.sh Outdated Show resolved Hide resolved
scripts/install_protoc.sh Show resolved Hide resolved
scripts/install_protoc.sh Outdated Show resolved Hide resolved
scripts/install_protoc.sh Outdated Show resolved Hide resolved
scripts/regenerate.sh Outdated Show resolved Hide resolved
scripts/regenerate.sh Outdated Show resolved Hide resolved
scripts/regenerate.sh Outdated Show resolved Hide resolved
scripts/vet-proto.sh Show resolved Hide resolved
scripts/vet-proto.sh Outdated Show resolved Hide resolved
@arvindbr8
Copy link
Member

arvindbr8 commented May 28, 2024

Also this still seems to be not resolved? #7064 (comment)

@arvindbr8
Copy link
Member

i would prefer if the reporter of a comment to close the conversation as resolved. The Github UI hides the conversation, and we would need to click on each to see if/what the response is.

@aranjans aranjans force-pushed the aranjans_6583 branch 2 times, most recently from 2baac2d to 32610ba Compare May 30, 2024 07:45
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

Great! Looks better now. LGTM modulo the comments from this pass.

scripts/install_protoc.sh Outdated Show resolved Hide resolved
scripts/install_protoc.sh Show resolved Hide resolved
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
source ./scripts/install_protoc.sh "/home/runner/go"
else
die "run protoc installer https://github.com/grpc/grpc-go/scripts/install_protoc.sh."
Copy link
Member

Choose a reason for hiding this comment

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

broken link?

Copy link
Member

Choose a reason for hiding this comment

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

also shouldn't we mention how to run the installer from the terminal?

We should also put something in the top level package comment in scripts/install_protoc.sh

Copy link
Member

Choose a reason for hiding this comment

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

also i'm not convinced that only Github Actions should be able to run ./scripts/vet-proto.sh with -install. I would expect that if a user runs this, then we install protoc for them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/grpc/grpc-go/scripts/install_protoc.sh. install_protoc.sh script is a new file so this link will be accessed only when it is merged.

Copy link
Member

Choose a reason for hiding this comment

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

This is how links to files in our repo @ master would look like https://github.com/grpc/grpc-go/blob/master/admin/admin.go

Also about this; why not just something like:

source ./scripts/install_protoc.sh

scripts/install_protoc.sh Show resolved Hide resolved
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
source ./scripts/install_protoc.sh "/home/runner/go"
else
die "run protoc installer https://github.com/grpc/grpc-go/scripts/install_protoc.sh."
Copy link
Member

Choose a reason for hiding this comment

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

This is how links to files in our repo @ master would look like https://github.com/grpc/grpc-go/blob/master/admin/admin.go

Also about this; why not just something like:

source ./scripts/install_protoc.sh

scripts/install_protoc.sh Show resolved Hide resolved
Comment on lines +23 to +27
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
source ./scripts/install_protoc.sh "/home/runner/go"
else
die "run protoc installer https://github.com/grpc/grpc-go/blob/master/scripts/install_protoc.sh"
fi
Copy link
Member

Choose a reason for hiding this comment

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

nit: This still looks like a link to what to do. But just points to a script without the how to. Have you looked at my other comment that talked about why it might be nice to run install_protoc.sh also in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added few lines on how to use install_protoc.sh in case of manual run.

Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

LGTM, modulo two nits

@@ -19,12 +19,16 @@ WORKDIR=$(mktemp -d)

function finish {
rm -rf "$WORKDIR"
# Revert back the PATH to client's original value
export PATH=$ORIGINAL_PATH
echo "Restored PATH variable to original value."
Copy link
Member

Choose a reason for hiding this comment

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

nit: remove this echo as well. The user doesnt have to know that the state changed and was reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@purnesh42H purnesh42H assigned purnesh42H and unassigned aranjans Jun 4, 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.

Improve regenerate.sh to use the correct proto compiler version
5 participants