-
Notifications
You must be signed in to change notification settings - Fork 53
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
Conversation
@@ -0,0 +1,197 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
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.
Since this is a test resource, could you remove all unused part?
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.
My bad, it slipped into my commits!
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.
Removed
@@ -157,7 +161,22 @@ download_generator_artifact() { | |||
download_protoc() { | |||
local protoc_version=$1 | |||
local os_architecture=$2 | |||
if [ ! -d "protoc-${protoc_version}" ]; then | |||
|
|||
protoc_dirname="protoc-${protoc_version}" |
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.
Could you add a comment specifying the the protoc version priority?
{ | ||
"customType": "regex", | ||
"fileMatch": [ | ||
"^\\.cloudbuild/library_generation/library_generation\\.Dockerfile$" |
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.
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.
|
||
# install protobuf | ||
WORKDIR /protoc | ||
RUN ls /src |
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.
Is this just for troubleshooting purposes?
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.
Indeed. I removed it
# if the specified protoc_version matches the one baked in the docker | ||
# container, we just copy it into the output folder | ||
mkdir -p "${output_folder}/${protoc_dirname}" | ||
cp -r "${DOCKER_PROTOC_LOCATION}/${protoc_dirname}" \ |
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.
Can we use the protoc location specified in Dockerfile?
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.
Yes. We now explicitly export
the protoc_path
variable to simply point to this location instead of copying it.
@@ -157,7 +161,22 @@ download_generator_artifact() { | |||
download_protoc() { |
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.
In general, I feel like we may not need any changes in download_protoc
. Ideally this function can stay as it is and we can add logics before calling it, for example
if [[ "${protoc_version}" != "${DOCKER_PROTOC_VERSION}" ]]; then
download_protoc "${protoc_version}" "${os_architecture}"
fi
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I left download_protoc
almost untouched and left the DOCKER_PROTOC_VERSION
handling in download_tools
(one level up in the call hierarchy).
if [[ -n "${DOCKER_PROTOC_VERSION}" ]]; then | ||
>&2 echo "Using protoc version baked into the container: ${DOCKER_PROTOC_VERSION}" | ||
echo "${DOCKER_PROTOC_VERSION}" | ||
fi |
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.
I guess we can return this function early?
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.
This became obsolete as we moved this if statement outside of download_protoc
Removed.
Co-authored-by: Joe Wang <106995533+JoeWang1127@users.noreply.github.com>
@@ -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 comment
The 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.
@@ -15,24 +15,35 @@ | |||
# build from the root of this repo: | |||
FROM gcr.io/cloud-devrel-public-resources/python | |||
|
|||
ARG SYNTHTOOL_COMMITTISH=a2c9b4a5da2d7f583c8a1869fd2843c206145834 | |||
SHELL [ "/bin/bash", "-c" ] |
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 is bash
based. Using sh
makes the following line to have no effects.
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash |
Please retry analysis of this Pull-Request directly on SonarCloud |
Quality Gate passed for 'java_showcase_integration_tests'Issues Measures |
### Does the config work with renovate bot? Yes. After a local run using `LOG_LEVEL=debug npx --yes --package renovate -- renovate --platform=local &> renovate.out`, we obtained a dependency update in the logs: ``` { "deps": [ { "depName": "protocolbuffers/protobuf", "currentValue": "25.2", "datasource": "github-releases", "extractVersion": "^v(?<version>.*)$", "replaceString": "ARG PROTOC_VERSION=25.2\n", "updates": [ { "bucket": "non-major", "newVersion": "25.3", "newValue": "25.3", "releaseTimestamp": "2024-02-15T23:20:43.000Z", "newMajor": 25, "newMinor": 3, "updateType": "minor", "branchName": "renovate/protocolbuffers-protobuf-25.x" }, { "bucket": "major", "newVersion": "26.1", "newValue": "26.1", "releaseTimestamp": "2024-03-27T20:28:47.000Z", "newMajor": 26, "newMinor": 1, "updateType": "major", "branchName": "renovate/protocolbuffers-protobuf-26.x" } ], "packageName": "protocolbuffers/protobuf", "versioning": "semver-coerced", "warnings": [], "sourceUrl": "https://github.com/protocolbuffers/protobuf", "registryUrl": "https://github.com", "currentVersion": "25.2", "currentVersionTimestamp": "2024-01-09T23:52:55.000Z", "isSingleVersion": true, "fixedVersion": "25.2" } ], ``` However, we disabled the setting for now. This log entry confirms it. `DEBUG: Dependency: protocolbuffers/protobuf, is disabled (repository=local)` --------- Co-authored-by: Joe Wang <106995533+JoeWang1127@users.noreply.github.com>
…3045) This PR bakes the gRPC plugin in the hermetic library generation image. The approach is very similar to #2707 * The docker image will have a configurable `ARG` for the gRPC plugin * The docker image will download the gRPC plugin at the version specified in the previous point * The docker image will set the variables DOCKER_GRPC_VERSION and DOCKER_GRPC_LOCATION * `generate_library.sh` will now be able to avoid downloading the gRPC plugin if the computed plugin version is the same as DOCKER_GRPC_VERSION (all this via `utilities.sh`). --------- Co-authored-by: Blake Li <blakeli@google.com>
Does the config work with renovate bot?
Yes. After a local run using
LOG_LEVEL=debug npx --yes --package renovate -- renovate --platform=local &> renovate.out
, we obtained a dependency update in the logs:However, we disabled the setting for now. This log entry confirms it.
DEBUG: Dependency: protocolbuffers/protobuf, is disabled (repository=local)