-
Notifications
You must be signed in to change notification settings - Fork 54
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
chore: bake protoc into the hermetic build docker image #2707
Changes from 64 commits
0b65f15
a6bb064
d4f27e2
19a0b04
bc693b5
f335cbb
aab50ef
f97cdca
d68c14a
eca0d92
6aa8533
53c5dea
cc4309b
7a4b6b8
4838d5b
1b01713
c149461
4ee1692
e77bacc
9120c94
3d18426
427c564
7b79763
240742a
8498f2c
f893e5c
2faf45d
7ce9548
8474452
b58e990
00cb2a7
b27a57e
6c6432a
eca8c62
0041c6b
7ec0f4c
4399bfe
ef105e7
b1d3fc3
1df1aa1
054458d
00d9ecc
1a5faec
9e25542
5a7d525
3cde6f5
acf26fa
1ef4006
358be32
17de6db
0fd0d21
e3d6e50
315feb9
291f911
5fe0a97
eb48f45
706d095
868a1bf
5d9beb5
6d76843
8a57737
550f162
340622c
5e71efa
c4b7f72
df0d23c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,6 @@ class IntegrationTest(unittest.TestCase): | |
def setUpClass(cls) -> None: | ||
IntegrationTest.__build_image(docker_file=build_file, cwd=repo_root_dir) | ||
|
||
@classmethod | ||
def tearDownClass(cls) -> None: | ||
cls.__remove_docker_image() | ||
|
||
@classmethod | ||
def setUp(cls) -> None: | ||
cls.__remove_generated_files() | ||
|
@@ -308,6 +304,3 @@ def __recursive_diff_files( | |
sub_dcmp, diff_files, left_only, right_only, dirname + sub_dirname + "/" | ||
) | ||
|
||
@classmethod | ||
def __remove_docker_image(cls): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the GitHub runner cleans itself up after running the ITs and we usually want to troubleshoot locally via this integration test, it may be more convenient to not have to build the image from scratch every time when debugging. |
||
subprocess.check_call(["docker", "image", "rmi", image_tag]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,11 @@ get_grpc_version() { | |
get_protoc_version() { | ||
local gapic_generator_version=$1 | ||
local protoc_version | ||
if [[ -n "${DOCKER_PROTOC_VERSION}" ]]; then | ||
>&2 echo "Using protoc version baked into the container: ${DOCKER_PROTOC_VERSION}" | ||
echo "${DOCKER_PROTOC_VERSION}" | ||
return | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can return this function early? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Removed. |
||
pushd "${output_folder}" > /dev/null | ||
# get protobuf version from gapic-generator-java-pom-parent/pom.xml | ||
download_gapic_generator_pom_parent "${gapic_generator_version}" | ||
|
@@ -131,7 +136,17 @@ download_tools() { | |
local os_architecture=$4 | ||
pushd "${output_folder}" | ||
download_generator_artifact "${gapic_generator_version}" "gapic-generator-java-${gapic_generator_version}.jar" | ||
download_protoc "${protoc_version}" "${os_architecture}" | ||
|
||
# the variable protoc_path is used in generate_library.sh. It is explicitly | ||
# exported to make clear that it is used outside this utilities file. | ||
if [[ "${DOCKER_PROTOC_VERSION}" == "${protoc_version}" ]]; then | ||
# if the specified protoc_version matches the one baked in the docker | ||
# container, we just point protoc_path to its location. | ||
export protoc_path="${DOCKER_PROTOC_LOCATION}/protoc-${protoc_version}/bin" | ||
else | ||
export protoc_path=$(download_protoc "${protoc_version}" "${os_architecture}") | ||
fi | ||
|
||
download_grpc_plugin "${grpc_version}" "${os_architecture}" | ||
popd | ||
} | ||
|
@@ -162,7 +177,10 @@ download_generator_artifact() { | |
download_protoc() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, I feel like we may not need any changes in
But I think this requires us to reuse the proto location specified in Dockerfile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left |
||
local protoc_version=$1 | ||
local os_architecture=$2 | ||
if [ ! -d "protoc-${protoc_version}" ]; then | ||
|
||
local protoc_path="${output_folder}/protoc-${protoc_version}/bin" | ||
|
||
if [ ! -d "${protoc_path}" ]; then | ||
# pull proto files and protoc from protobuf repository as maven central | ||
# doesn't have proto files | ||
download_from \ | ||
|
@@ -173,8 +191,8 @@ download_protoc() { | |
cp -r "protoc-${protoc_version}/include/google" . | ||
rm "protoc-${protoc_version}.zip" | ||
fi | ||
echo "${protoc_path}" | ||
|
||
protoc_path="${output_folder}/protoc-${protoc_version}/bin" | ||
} | ||
|
||
download_grpc_plugin() { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -28,6 +28,18 @@ | |||||||||||||||||
"depNameTemplate": "com.google.protobuf:protobuf-java", | ||||||||||||||||||
"datasourceTemplate": "maven" | ||||||||||||||||||
}, | ||||||||||||||||||
{ | ||||||||||||||||||
"customType": "regex", | ||||||||||||||||||
"fileMatch": [ | ||||||||||||||||||
"^\\.cloudbuild/library_generation/library_generation\\.Dockerfile$" | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you verify this setting will work? Do we need to specify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JoeWang1127 I verified it worked locally. I added the results to the PR description. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually we probably don't want to let renovate bot to automatically update protoc. Not before we can update the whole repo(java-comon-protos, java-iam, test files in gapic-generator-java) along side the protoc update. Because the new protoc version may not work with the current protos or the newly generated code may not work with the generator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Both sdk-platform-java/renovate.json Lines 154 to 161 in eb48f45
I guess we can keep these regexes and enable them afterwards? |
||||||||||||||||||
], | ||||||||||||||||||
"matchStrings": [ | ||||||||||||||||||
"ARG PROTOC_VERSION=[\"']?(?<currentValue>.+?)[\"']?\\s+" | ||||||||||||||||||
], | ||||||||||||||||||
"datasourceTemplate": "github-releases", | ||||||||||||||||||
"depNameTemplate": "protocolbuffers/protobuf", | ||||||||||||||||||
"extractVersionTemplate": "^v(?<version>.*)$" | ||||||||||||||||||
}, | ||||||||||||||||||
{ | ||||||||||||||||||
"customType": "regex", | ||||||||||||||||||
"fileMatch": [ | ||||||||||||||||||
|
@@ -141,7 +153,8 @@ | |||||||||||||||||
}, | ||||||||||||||||||
{ | ||||||||||||||||||
"matchPackagePatterns": [ | ||||||||||||||||||
"^com.google.protobuf" | ||||||||||||||||||
"^com.google.protobuf", | ||||||||||||||||||
"^protocolbuffers/protobuf" | ||||||||||||||||||
], | ||||||||||||||||||
"groupName": "Protobuf dependencies", | ||||||||||||||||||
"enabled": false | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything requires us to change the default shell to bash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
nvm
installation script assumes the environment isbash
based. Usingsh
makes the following line to have no effects.sdk-platform-java/.cloudbuild/library_generation/library_generation.Dockerfile
Line 63 in 5e71efa