Skip to content

Commit

Permalink
default to protoc version in docker image if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed May 14, 2024
1 parent 315feb9 commit 291f911
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library_generation/test/generate_library_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ get_grpc_version_failed_with_invalid_generator_version_test() {
assertEquals 1 $((res))
}

get_protoc_version_succeed_docker_env_var_test() {
local version_with_docker
local version_without_docker
export DOCKER_PROTOC_VERSION="9.9.9"
version_with_docker=$(get_protoc_version "2.24.0")
assertEquals "${DOCKER_PROTOC_VERSION}" "${version_with_docker}"
unset DOCKER_PROTOC_VERSION
version_without_docker=$(get_protoc_version "2.24.0")
assertEquals "23.2" "${version_without_docker}"
rm "gapic-generator-java-pom-parent-2.24.0.pom"
}

get_protoc_version_succeed_with_valid_generator_version_test() {
local actual_version
actual_version=$(get_protoc_version "2.24.0")
Expand Down Expand Up @@ -277,6 +289,7 @@ 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_protoc_version_succeed_docker_env_var_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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" child.project.url.inherit.append.path="false">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.api</groupId>
<artifactId>gapic-generator-java-pom-parent</artifactId>
<version>2.24.0</version><!-- {x-version-update:gapic-generator-java:current} -->
<packaging>pom</packaging>
<name>GAPIC Generator Java POM Parent</name>
<url>https://github.com/googleapis/sdk-platform-java</url>
<description>
The top-level parent for all modules in the repository.
</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-config</artifactId>
<version>1.5.7</version>
<relativePath/>
</parent>

<properties>
<skipUnitTests>false</skipUnitTests>
<checkstyle.header.file>java.header</checkstyle.header.file>

<!-- External dependencies, especially gRPC and Protobuf version, should be
consistent across modules in this repository -->
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<auto-value.version>1.10.2</auto-value.version>
<grpc.version>1.56.1</grpc.version>
<google.auth.version>1.19.0</google.auth.version>
<google.http-client.version>1.43.3</google.http-client.version>
<gson.version>2.10.1</gson.version>
<guava.version>32.1.2-jre</guava.version>
<!-- On next protobuf upgrade (to 3.23.3 or higher),
remove temporarily j2objc-annotations exclusions from protobuf-java-util dependencies.
For context: https://github.com/googleapis/sdk-platform-java/pull/1791-->
<protobuf.version>3.23.2</protobuf.version>
<maven.compiler.release>8</maven.compiler.release>
</properties>

<developers>
<developer>
<id>suztomo</id>
<name>Tomo Suzuki</name>
<email>suztomo@google.com</email>
<organization>Google</organization>
<roles>
<role>Developer</role>
</roles>
</developer>
</developers>
<organization>
<name>Google LLC</name>
</organization>
<scm child.scm.connection.inherit.append.path="false" child.scm.developerConnection.inherit.append.path="false"
child.scm.url.inherit.append.path="false">
<connection>scm:git:git@github.com:googleapis/sdk-platform-java.git</connection>
<developerConnection>scm:git:git@github.com:googleapis/sdk-platform-java.git</developerConnection>
<url>https://github.com/googleapis/sdk-platform-java</url>
<tag>HEAD</tag>
</scm>
<issueManagement>
<url>https://github.com/googleapis/sdk-platform-java/issues</url>
<system>GitHub Issues</system>
</issueManagement>

<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<profiles>
<profile>
<!-- Only run checkstyle plugin on Java 11+ (checkstyle artifact only supports Java 11+) -->
<id>checkstyle-tests</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<headerLocation>${checkstyle.header.file}</headerLocation>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>test-coverage</id>
<activation>
<property>
<name>enableShowcaseTestCoverage</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M8</version>
<configuration>
<!-- Excludes integration tests and smoke tests when unit tests are run -->
<excludes>
<exclude>**/*SmokeTest.java</exclude>
<exclude>**/IT*.java</exclude>
</excludes>
<reportNameSuffix>sponge_log</reportNameSuffix>
<argLine>${surefire.jacoco.args}</argLine>
<skipTests>${skipUnitTests}</skipTests>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<forkedProcessTimeoutInSeconds>3600</forkedProcessTimeoutInSeconds>
<reportNameSuffix>sponge_log</reportNameSuffix>
<includes>
<include>**/IT*.java</include>
<include>**/*SmokeTest.java</include>
</includes>
<argLine>${failsafe.jacoco.args}</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<id>unit-test-execution</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefire.jacoco.args</propertyName>
</configuration>
</execution>
<execution>
<id>integration-test-execution</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>failsafe.jacoco.args</propertyName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>google-maven-central-copy</id>
<name>Google Maven Central copy</name>
<url>https://maven-central.storage-download.googleapis.com/maven2</url>
</repository>
<repository>
<id>maven-central</id>
<name>Maven Central</name>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
</project>
3 changes: 3 additions & 0 deletions library_generation/utils/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ get_grpc_version() {
get_protoc_version() {
local gapic_generator_version=$1
local protoc_version
if [[ -n "${DOCKER_PROTOC_VERSION}" ]]; then
echo "${DOCKER_PROTOC_VERSION}"
fi
pushd "${output_folder}" > /dev/null
# get protobuf version from gapic-generator-java-pom-parent/pom.xml
download_gapic_generator_pom_parent "${gapic_generator_version}"
Expand Down

0 comments on commit 291f911

Please sign in to comment.