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

chore: change protobuf_version to protoc_version #2686

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library_generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ They are shared by library level parameters.
| Name | Required | Notes |
|:------------------------|:--------:|:---------------------------------------------|
| gapic_generator_version | Yes | |
| protobuf_version | No | inferred from the generator if not specified |
| protoc_version | No | inferred from the generator if not specified |
| grpc_version | No | inferred from the generator if not specified |
| googleapis-commitish | Yes | |
| libraries_bom_version | Yes | |
Expand Down Expand Up @@ -146,7 +146,7 @@ The GAPIC level parameters define how to generate a GAPIC library.

```yaml
gapic_generator_version: 2.34.0
protobuf_version: 25.2
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
Expand Down
2 changes: 1 addition & 1 deletion library_generation/generate_composed_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __construct_tooling_arg(config: GenerationConfig) -> List[str]:
arguments = []
arguments += util.create_argument("gapic_generator_version", config)
arguments += util.create_argument("grpc_version", config)
arguments += util.create_argument("protobuf_version", config)
arguments += util.create_argument("protoc_version", config)

return arguments

Expand Down
10 changes: 5 additions & 5 deletions library_generation/generate_library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ case $key in
export gapic_generator_version
shift
;;
--protobuf_version)
protobuf_version="$2"
--protoc_version)
protoc_version="$2"
shift
;;
--grpc_version)
Expand Down Expand Up @@ -82,8 +82,8 @@ if [ -z "${gapic_generator_version}" ]; then
exit 1
fi

if [ -z "${protobuf_version}" ]; then
protobuf_version=$(get_protobuf_version "${gapic_generator_version}")
if [ -z "${protoc_version}" ]; then
protoc_version=$(get_protoc_version "${gapic_generator_version}")
fi

if [ -z "${grpc_version}" ]; then
Expand Down Expand Up @@ -177,7 +177,7 @@ case "${proto_path}" in
;;
esac
# download gapic-generator-java, protobuf and grpc plugin.
download_tools "${gapic_generator_version}" "${protobuf_version}" "${grpc_version}" "${os_architecture}"
download_tools "${gapic_generator_version}" "${protoc_version}" "${grpc_version}" "${os_architecture}"
##################### Section 1 #####################
# generate grpc-*/
#####################################################
Expand Down
6 changes: 3 additions & 3 deletions library_generation/model/generation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(
template_excludes: List[str],
libraries: List[LibraryConfig],
grpc_version: Optional[str] = None,
protobuf_version: Optional[str] = None,
protoc_version: Optional[str] = None,
):
self.gapic_generator_version = gapic_generator_version
self.googleapis_commitish = googleapis_commitish
Expand All @@ -45,7 +45,7 @@ def __init__(
self.template_excludes = template_excludes
self.libraries = libraries
self.grpc_version = grpc_version
self.protobuf_version = protobuf_version
self.protoc_version = protoc_version

def get_proto_path_to_library_name(self) -> dict[str, str]:
"""
Expand Down Expand Up @@ -116,7 +116,7 @@ def from_yaml(path_to_yaml: str) -> GenerationConfig:
parsed_config = GenerationConfig(
gapic_generator_version=__required(config, "gapic_generator_version"),
grpc_version=__optional(config, "grpc_version", None),
protobuf_version=__optional(config, "protobuf_version", None),
protoc_version=__optional(config, "protoc_version", None),
googleapis_commitish=__required(config, "googleapis_commitish"),
libraries_bom_version=__required(config, "libraries_bom_version"),
owlbot_cli_image=__required(config, "owlbot_cli_image"),
Expand Down
52 changes: 26 additions & 26 deletions library_generation/test/generate_library_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ get_grpc_version_failed_with_invalid_generator_version_test() {
assertEquals 1 $((res))
}

get_protobuf_version_succeed_with_valid_generator_version_test() {
get_protoc_version_succeed_with_valid_generator_version_test() {
local actual_version
actual_version=$(get_protobuf_version "2.24.0")
actual_version=$(get_protoc_version "2.24.0")
assertEquals "23.2" "${actual_version}"
rm "gapic-generator-java-pom-parent-2.24.0.pom"
}

get_protobuf_version_failed_with_invalid_generator_version_test() {
get_protoc_version_failed_with_invalid_generator_version_test() {
local res=0
$(get_protobuf_version "1.99.0") || res=$?
$(get_protoc_version "1.99.0") || res=$?
assertEquals 1 $((res))
}

Expand Down Expand Up @@ -110,27 +110,27 @@ download_generator_failed_with_invalid_version_test() {
assertEquals 1 $((res))
}

download_protobuf_succeed_with_valid_version_linux_test() {
download_protobuf "23.2" "linux-x86_64"
assertFileOrDirectoryExists "protobuf-23.2"
rm -rf "protobuf-23.2"
download_protoc_succeed_with_valid_version_linux_test() {
download_protoc "23.2" "linux-x86_64"
assertFileOrDirectoryExists "protoc-23.2"
rm -rf "protoc-23.2"
}

download_protobuf_succeed_with_valid_version_macos_test() {
download_protobuf "23.2" "osx-x86_64"
assertFileOrDirectoryExists "protobuf-23.2"
rm -rf "protobuf-23.2" "google"
download_protoc_succeed_with_valid_version_macos_test() {
download_protoc "23.2" "osx-x86_64"
assertFileOrDirectoryExists "protoc-23.2"
rm -rf "protoc-23.2" "google"
}

download_protobuf_failed_with_invalid_version_linux_test() {
download_protoc_failed_with_invalid_version_linux_test() {
local res=0
$(download_protobuf "22.99" "linux-x86_64") || res=$?
$(download_protoc "22.99" "linux-x86_64") || res=$?
assertEquals 1 $((res))
}

download_protobuf_failed_with_invalid_arch_test() {
download_protoc_failed_with_invalid_arch_test() {
local res=0
$(download_protobuf "23.2" "customized-x86_64") || res=$?
$(download_protoc "23.2" "customized-x86_64") || res=$?
assertEquals 1 $((res))
}

Expand Down Expand Up @@ -166,7 +166,7 @@ generate_library_failed_with_invalid_generator_version() {
-p google/cloud/alloydb/v1 \
-d ../"${destination}" \
--gapic_generator_version 1.99.0 \
--protobuf_version 23.2 \
--protoc_version 23.2 \
--grpc_version 1.55.1 \
--transport grpc+rest \
--rest_numeric_enums true || res=$?
Expand All @@ -175,15 +175,15 @@ generate_library_failed_with_invalid_generator_version() {
cleanup "${destination}"
}

generate_library_failed_with_invalid_protobuf_version() {
generate_library_failed_with_invalid_protoc_version() {
local destination="google-cloud-alloydb-v1-java"
local res=0
cd "${script_dir}/resources"
bash "${script_dir}"/../generate_library.sh \
-p google/cloud/alloydb/v1 \
-d ../"${destination}" \
--gapic_generator_version 2.24.0 \
--protobuf_version 22.99 \
--protoc_version 22.99 \
--grpc_version 1.55.1 \
--transport grpc+rest \
--rest_numeric_enums true || res=$?
Expand Down Expand Up @@ -256,24 +256,24 @@ test_list=(
extract_folder_name_test
get_grpc_version_succeed_with_valid_generator_version_test
get_grpc_version_failed_with_invalid_generator_version_test
get_protobuf_version_succeed_with_valid_generator_version_test
get_protobuf_version_failed_with_invalid_generator_version_test
get_protoc_version_succeed_with_valid_generator_version_test
get_protoc_version_failed_with_invalid_generator_version_test
get_gapic_opts_with_rest_test
get_gapic_opts_without_rest_test
get_gapic_opts_with_non_default_test
remove_grpc_version_test
download_generator_success_with_valid_version_test
download_generator_failed_with_invalid_version_test
download_protobuf_succeed_with_valid_version_linux_test
download_protobuf_succeed_with_valid_version_macos_test
download_protobuf_failed_with_invalid_version_linux_test
download_protobuf_failed_with_invalid_arch_test
download_protoc_succeed_with_valid_version_linux_test
download_protoc_succeed_with_valid_version_macos_test
download_protoc_failed_with_invalid_version_linux_test
download_protoc_failed_with_invalid_arch_test
download_grpc_plugin_succeed_with_valid_version_linux_test
download_grpc_plugin_succeed_with_valid_version_macos_test
download_grpc_plugin_failed_with_invalid_version_linux_test
download_grpc_plugin_failed_with_invalid_arch_test
generate_library_failed_with_invalid_generator_version
generate_library_failed_with_invalid_protobuf_version
generate_library_failed_with_invalid_protoc_version
generate_library_failed_with_invalid_grpc_version
copy_directory_if_exists_valid_folder_succeeds
copy_directory_if_exists_invalid_folder_does_not_copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_generate_pr_description_with_same_googleapis_commits(self):
synthtool_commitish="",
template_excludes=[],
grpc_version="",
protobuf_version="",
protoc_version="",
libraries=[],
),
baseline_commit=commit_sha,
Expand Down
2 changes: 1 addition & 1 deletion library_generation/test/model/config_change_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def __get_a_gen_config(
synthtool_commitish="",
template_excludes=[],
grpc_version="",
protobuf_version="",
protoc_version="",
libraries=libraries,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GenerationConfigTest(unittest.TestCase):
def test_from_yaml_succeeds(self):
config = from_yaml(f"{test_config_dir}/generation_config.yaml")
self.assertEqual("2.34.0", config.gapic_generator_version)
self.assertEqual(25.2, config.protobuf_version)
self.assertEqual(25.2, config.protoc_version)
self.assertEqual(
"1a45bf7393b52407188c82e63101db7dc9c72026", config.googleapis_commitish
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gapic_generator_version: 2.38.1
protobuf_version: 25.2
protoc_version: 25.2
googleapis_commitish: a17d4caf184b050d50cacf2b0d579ce72c31ce74
libraries_bom_version: 26.37.0
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gapic_generator_version: 2.38.1
protobuf_version: 25.2
protoc_version: 25.2
googleapis_commitish: 4ce0ff67a3d4509be641cbe47a35844ddc1268fc
libraries_bom_version: 26.37.0
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gapic_generator_version: 2.37.0
protobuf_version: 25.2
protoc_version: 25.2
googleapis_commitish: 9868a57470a969ffa1d21194a5c05d7a6e4e98cc
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
synthtool_commitish: a6fb7d5f072b75698af1cbf06c5b001565753cfb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gapic_generator_version: 2.34.0
protobuf_version: 25.2
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setUp(self) -> None:
synthtool_commitish="",
template_excludes=[],
grpc_version="",
protobuf_version="",
protoc_version="",
libraries=[self.baseline_library],
)
self.current_config = GenerationConfig(
Expand All @@ -55,7 +55,7 @@ def setUp(self) -> None:
synthtool_commitish="",
template_excludes=[],
grpc_version="",
protobuf_version="",
protoc_version="",
libraries=[self.current_library],
)

Expand Down Expand Up @@ -136,8 +136,8 @@ def test_compare_config_synthtool_update(self):
self.assertEqual("commit456", config_change.current_value)

def test_compare_protobuf_update(self):
self.baseline_config.protobuf_version = "3.25.2"
self.current_config.protobuf_version = "3.27.0"
self.baseline_config.protoc_version = "3.25.2"
self.current_config.protoc_version = "3.27.0"
result = compare_config(
baseline_config=self.baseline_config,
current_config=self.current_config,
Expand All @@ -146,7 +146,7 @@ def test_compare_protobuf_update(self):
len(result.change_to_libraries[ChangeType.REPO_LEVEL_CHANGE]) == 1
)
config_change = result.change_to_libraries[ChangeType.REPO_LEVEL_CHANGE][0]
self.assertEqual("protobuf_version", config_change.changed_param)
self.assertEqual("protoc_version", config_change.changed_param)
self.assertEqual("3.27.0", config_change.current_value)

def test_compare_config_grpc_update(self):
Expand Down
30 changes: 15 additions & 15 deletions library_generation/utils/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,25 @@ get_grpc_version() {
echo "${grpc_version}"
}

get_protobuf_version() {
get_protoc_version() {
local gapic_generator_version=$1
local protobuf_version
local protoc_version
pushd "${output_folder}" > /dev/null
# get protobuf version from gapic-generator-java-pom-parent/pom.xml
download_gapic_generator_pom_parent "${gapic_generator_version}"
protobuf_version=$(grep protobuf.version "gapic-generator-java-pom-parent-${gapic_generator_version}.pom" | sed 's/<protobuf\.version>\(.*\)<\/protobuf\.version>/\1/' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | cut -d "." -f2-)
protoc_version=$(grep protobuf.version "gapic-generator-java-pom-parent-${gapic_generator_version}.pom" | sed 's/<protobuf\.version>\(.*\)<\/protobuf\.version>/\1/' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | cut -d "." -f2-)
popd > /dev/null
echo "${protobuf_version}"
echo "${protoc_version}"
}

download_tools() {
local gapic_generator_version=$1
local protobuf_version=$2
local protoc_version=$2
local grpc_version=$3
local os_architecture=$4
pushd "${output_folder}"
download_generator_artifact "${gapic_generator_version}" "gapic-generator-java-${gapic_generator_version}.jar"
download_protobuf "${protobuf_version}" "${os_architecture}"
download_protoc "${protoc_version}" "${os_architecture}"
download_grpc_plugin "${grpc_version}" "${os_architecture}"
popd
}
Expand Down Expand Up @@ -154,22 +154,22 @@ download_generator_artifact() {
fi
}

download_protobuf() {
local protobuf_version=$1
download_protoc() {
local protoc_version=$1
local os_architecture=$2
if [ ! -d "protobuf-${protobuf_version}" ]; then
if [ ! -d "protoc-${protoc_version}" ]; then
# pull proto files and protoc from protobuf repository as maven central
# doesn't have proto files
download_from \
"https://github.com/protocolbuffers/protobuf/releases/download/v${protobuf_version}/protoc-${protobuf_version}-${os_architecture}.zip" \
"protobuf-${protobuf_version}.zip" \
"https://github.com/protocolbuffers/protobuf/releases/download/v${protoc_version}/protoc-${protoc_version}-${os_architecture}.zip" \
"protoc-${protoc_version}.zip" \
"GitHub"
unzip -o -q "protobuf-${protobuf_version}.zip" -d "protobuf-${protobuf_version}"
cp -r "protobuf-${protobuf_version}/include/google" .
rm "protobuf-${protobuf_version}.zip"
unzip -o -q "protoc-${protoc_version}.zip" -d "protoc-${protoc_version}"
cp -r "protoc-${protoc_version}/include/google" .
rm "protoc-${protoc_version}.zip"
fi

protoc_path="${output_folder}/protobuf-${protobuf_version}/bin"
protoc_path="${output_folder}/protoc-${protoc_version}/bin"
}

download_grpc_plugin() {
Expand Down
Loading