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

feat: generate showcase using docker image #3568

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f61c630
feat: generate showcase with hermetic build image
diegomarquezp Jan 10, 2025
99c711f
add showcase generation files
diegomarquezp Jan 10, 2025
7c0ed51
exclude bom generation
diegomarquezp Jan 10, 2025
0328d96
fix owlbot-cli config
diegomarquezp Jan 10, 2025
c1d1696
fix paths in owlbot cli
diegomarquezp Jan 10, 2025
bb28ae6
add historical bazel file
diegomarquezp Jan 10, 2025
85201ee
fix owlbot yaml
diegomarquezp Jan 10, 2025
cad57f6
parse additional protos also including gapic targets
diegomarquezp Jan 14, 2025
bfc9bba
fix service yaml and gapic config
diegomarquezp Jan 14, 2025
b4aa910
adapt to docker image generation
diegomarquezp Jan 14, 2025
779d011
update proto, gapic and grpc
diegomarquezp Jan 14, 2025
d29ce8c
add samples
diegomarquezp Jan 14, 2025
334384a
adapt showcase readme
diegomarquezp Jan 14, 2025
66e7366
explain new input in generation config
diegomarquezp Jan 14, 2025
f0a7d53
uncomment image building
diegomarquezp Jan 14, 2025
072ee70
ignore full generation when only generating showcase
diegomarquezp Jan 14, 2025
0214666
add showcase to versions.txt
diegomarquezp Jan 14, 2025
2f47daa
do not generate showcase automatically on generation config changes
diegomarquezp Jan 15, 2025
3063dab
update gapic showcase files
diegomarquezp Jan 15, 2025
e1c270a
fix build rule patterns
diegomarquezp Jan 15, 2025
1514dd7
lint
diegomarquezp Jan 15, 2025
6476131
skip generation on no target libraries
diegomarquezp Jan 15, 2025
4880451
exit early when no libraries need to be generated
diegomarquezp Jan 15, 2025
c29ce8c
Revert "explain new input in generation config"
diegomarquezp Jan 21, 2025
55141af
restore use of folder name
diegomarquezp Jan 21, 2025
2711c7d
use proto_library_with_info to obtain additional protos
diegomarquezp Jan 21, 2025
0a0726c
optimize image building
diegomarquezp Jan 21, 2025
2d6802f
Merge remote-tracking branch 'origin/main' into hermetic-build-showcase
diegomarquezp Jan 21, 2025
5bf0a5b
restore units
diegomarquezp Jan 21, 2025
8afe6a4
rename showcase folder to java-showcase
diegomarquezp Jan 21, 2025
3a839bf
script cleanup, use function to download showcase
diegomarquezp Jan 21, 2025
702644b
fix partial build file
diegomarquezp Jan 22, 2025
8728b79
chore: generate libraries at Wed Jan 22 12:52:18 AM UTC 2025
diegomarquezp Jan 22, 2025
37d1a95
fix references to java-showcase
diegomarquezp Jan 22, 2025
c8bc219
rename variable
diegomarquezp Jan 22, 2025
812f3d9
temporarily cd into showcase
diegomarquezp Jan 22, 2025
2d879f2
remove unnecessary whitespace
diegomarquezp Jan 22, 2025
d1f2d20
use showcase_version
diegomarquezp Jan 22, 2025
52d65f6
add readme instructions on docker
diegomarquezp Jan 22, 2025
5f07086
fix kokoro tests
diegomarquezp Jan 22, 2025
4246310
chore: generate libraries at Wed Jan 22 05:37:23 UTC 2025
cloud-java-bot Jan 22, 2025
e55ab79
fix showcase-native
diegomarquezp Jan 22, 2025
1e33cde
fix root pom
diegomarquezp Jan 22, 2025
4cdb78a
Merge remote-tracking branch 'origin/hermetic-build-showcase' into he…
diegomarquezp Jan 22, 2025
9868bc7
remove unwanted script
diegomarquezp Jan 22, 2025
5647988
update action.yaml to use showcase mode
diegomarquezp Jan 24, 2025
405108d
Merge branch 'main' into hermetic-build-showcase
diegomarquezp Jan 24, 2025
a6447c3
add showcase mode to script
diegomarquezp Jan 30, 2025
e122029
Merge remote-tracking branch 'origin/hermetic-build-showcase' into he…
diegomarquezp Jan 30, 2025
493b5a4
Merge remote-tracking branch 'origin/main' into hermetic-build-showcase
diegomarquezp Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 8 additions & 8 deletions .cloudbuild/library_generation/library_generation.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ RUN source /src/library_generation/utils/utilities.sh \
# similar to protoc, we indicate grpc is available in the container via env vars
ENV DOCKER_GRPC_LOCATION="/grpc/protoc-gen-grpc-java.exe"

# Here we transfer gapic-generator-java from the previous stage.
# Note that the destination is a well-known location that will be assumed at runtime
# We hard-code the location string to avoid making it configurable (via ARG) as
# well as to avoid it making it overridable at runtime (via ENV).
COPY --from=ggj-build "/sdk-platform-java/gapic-generator-java.jar" "${HOME}/.library_generation/gapic-generator-java.jar"
RUN chmod 755 "${HOME}/.library_generation/gapic-generator-java.jar"
ENV GAPIC_GENERATOR_LOCATION="${HOME}/.library_generation/gapic-generator-java.jar"

RUN python -m pip install --upgrade pip

# install main scripts as a python package
Expand All @@ -125,6 +117,14 @@ RUN owl-bot copy-code --version
RUN chmod o+rx $(which owl-bot)
RUN apk del -r npm && apk cache clean

# Here we transfer gapic-generator-java from the previous stage.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the generator jar copy later in the final stage so the previous steps can run in parallel with mvn install. It saves dozens of seconds.

# Note that the destination is a well-known location that will be assumed at runtime
# We hard-code the location string to avoid making it configurable (via ARG) as
# well as to avoid it making it overridable at runtime (via ENV).
COPY --from=ggj-build "/sdk-platform-java/gapic-generator-java.jar" "${HOME}/.library_generation/gapic-generator-java.jar"
RUN chmod 755 "${HOME}/.library_generation/gapic-generator-java.jar"
ENV GAPIC_GENERATOR_LOCATION="${HOME}/.library_generation/gapic-generator-java.jar"

# download the Java formatter
ADD https://maven-central.storage-download.googleapis.com/maven2/com/google/googlejavaformat/google-java-format/${JAVA_FORMAT_VERSION}/google-java-format-${JAVA_FORMAT_VERSION}-all-deps.jar \
"${HOME}"/.library_generation/google-java-format.jar
Expand Down
5 changes: 5 additions & 0 deletions .github/scripts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ inputs:
image_tag:
description: the tag of hermetic build image
required: false
showcase_mode:
description: true if we need to download the showcase api definitions
required: false
token:
description: Personal Access Token
required: true
Expand Down Expand Up @@ -72,9 +75,11 @@ runs:
bash hermetic_library_generation.sh \
--target_branch "${BASE_REF}" \
--current_branch "${HEAD_REF}" \
--showcase_mode "${SHOWCASE_MODE}" \
--image_tag "${IMAGE_TAG}"
env:
BASE_REF: ${{ inputs.base_ref }}
HEAD_REF: ${{ inputs.head_ref }}
IMAGE_TAG: ${{ inputs.image_tag }}
SHOWCASE_MODE: ${{ inputs.showcase_mode }}
GH_TOKEN: ${{ inputs.token }}
19 changes: 17 additions & 2 deletions .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -ex
# This script should be run at the root of the repository.
# This script is used to, when a pull request changes the generation
# configuration (generation_config.yaml by default) or Dockerfile:
Expand All @@ -25,6 +25,8 @@ set -e
# 3. [optional] image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation.
# 4. [optional] generation_config, the path to the generation configuration,
# the default value is generation_config.yaml in the repository root.
# 5. [optional] showcase_mode, true if we wish to download the showcase api
# definitions, which are necessary for generating the showcase library.
while [[ $# -gt 0 ]]; do
key="$1"
case "${key}" in
Expand All @@ -44,6 +46,10 @@ case "${key}" in
generation_config="$2"
shift
;;
--showcase_mode)
showcase_mode="$2"
shift
;;
*)
echo "Invalid option: [$1]"
exit 1
Expand All @@ -62,6 +68,10 @@ if [ -z "${current_branch}" ]; then
exit 1
fi

if [ -z "${download_showcase}" ]; then
download_showcase="false"
fi

if [ -z "${generation_config}" ]; then
generation_config=generation_config.yaml
echo "Use default generation config: ${generation_config}"
Expand Down Expand Up @@ -89,6 +99,12 @@ pushd "${api_def_dir}"
git checkout "${googleapis_commitish}"
popd

# we also setup showcase
if [[ "${showcase_mode}" == "true" ]]; then
source java-showcase/scripts/showcase_utilities.sh
append_showcase_to_api_defs "${api_def_dir}"
fi

# get changed library list.
changed_libraries=$(python hermetic_build/common/cli/get_changed_libraries.py create \
--baseline-generation-config-path="${baseline_generation_config}" \
Expand All @@ -98,7 +114,6 @@ echo "Changed libraries are: ${changed_libraries:-"No changed library"}."
# run hermetic code generation docker image.
docker run \
--rm \
--quiet \
-u "$(id -u):$(id -g)" \
-v "$(pwd):${workspace_name}" \
-v "${api_def_dir}:${workspace_name}/googleapis" \
Expand Down
2 changes: 1 addition & 1 deletion .github/snippet-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ alwaysCreateStatusCheck: false
ignoreFiles:
- src/test/**
- test/**
- showcase/**
- java-showcase/**
- library_generation/owlbot/templates/java_library/samples/install-without-bom/pom.xml
- library_generation/owlbot/synthtool/gcp/snippets.py
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,18 @@ jobs:
run: |
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip
- name: Java Linter
working-directory: showcase
working-directory: java-showcase
run: |
mvn -B -ntp fmt:check
- name: Showcase golden tests
working-directory: showcase
working-directory: java-showcase
run: |
mvn test \
-P enable-golden-tests \
--batch-mode \
--no-transfer-progress
- name: Parse showcase version
working-directory: showcase/gapic-showcase
working-directory: java-showcase/gapic-showcase
run: echo "SHOWCASE_VERSION=$(mvn help:evaluate -Dexpression=gapic-showcase.version -q -DforceStdout)" >> "$GITHUB_ENV"
- name: Install showcase server
run: |
Expand All @@ -249,7 +249,7 @@ jobs:
./gapic-showcase run &
cd -
- name: Showcase integration tests
working-directory: showcase
working-directory: java-showcase
run: |
mvn verify \
-P enable-integration-tests \
Expand Down Expand Up @@ -282,7 +282,7 @@ jobs:
run: mvn install -B -ntp -T 1C -DskipTests
# Showcase golden test ensures that src changes are already reflected in the PR.
- name: Clirr check
working-directory: showcase
working-directory: java-showcase
run: |
mvn versions:set -B -ntp -DnewVersion=local
mvn clirr:check -B -ntp -Dclirr.skip=false -DcomparisonVersion=$SHOWCASE_CLIENT_VERSION
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ jobs:
head_ref: ${{ github.head_ref }}
image_tag: ${{ env.GENERATOR_VERSION }}
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
showcase_mode: true
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
- name: Install modules to local maven
run: |
mvn install -T 1C -DskipTests -ntp -B
cd showcase
cd java-showcase
mvn install -T 1C -DskipTests -ntp -B
- name: Parse showcase version
working-directory: showcase/gapic-showcase
working-directory: java-showcase/gapic-showcase
run: echo "SHOWCASE_VERSION=$(mvn help:evaluate -Dexpression=gapic-showcase.version -q -DforceStdout)" >> "$GITHUB_ENV"
- name: Install showcase server
run: |
Expand Down
6 changes: 3 additions & 3 deletions .kokoro/presubmit/common_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cd target
function test_find_all_poms_with_versioned_dependency {
mkdir -p test_find_all_poms_with_dependency
pushd test_find_all_poms_with_dependency
cp ../../showcase/gapic-showcase/pom.xml pom.xml
cp ../../java-showcase/gapic-showcase/pom.xml pom.xml

find_all_poms_with_versioned_dependency 'truth'
if [ "${#POMS[@]}" != 1 ]; then
Expand All @@ -45,7 +45,7 @@ function test_find_all_poms_with_versioned_dependency {
function test_update_pom_dependency {
mkdir -p test_update_pom_dependency
pushd test_update_pom_dependency
cp ../../showcase/gapic-showcase/pom.xml pom.xml
cp ../../java-showcase/gapic-showcase/pom.xml pom.xml

update_pom_dependency . truth "99.88.77"

Expand All @@ -66,7 +66,7 @@ EOF
function test_parse_pom_version {
mkdir -p test_parse_pom_version
pushd test_parse_pom_version
cp ../../showcase/gapic-showcase/pom.xml pom.xml
cp ../../java-showcase/gapic-showcase/pom.xml pom.xml

VERSION=$(parse_pom_version .)
if [ "$VERSION" != "0.0.1-SNAPSHOT" ]; then
Expand Down
4 changes: 2 additions & 2 deletions .kokoro/presubmit/showcase-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mvn install --projects '!gapic-generator-java' \
SHARED_DEPS_VERSION=$(parse_pom_version java-shared-dependencies)

# Run showcase integration tests in GraalVM
pushd showcase/gapic-showcase
pushd java-showcase/gapic-showcase
SHOWCASE_VERSION=$(mvn help:evaluate -Dexpression=gapic-showcase.version -q -DforceStdout)
popd
# Start showcase server
Expand All @@ -52,7 +52,7 @@ tar -xf showcase-*
popd

# Run showcase tests with `native` profile
pushd showcase
pushd java-showcase
mvn test -Pnative,-showcase \
-Denforcer.skip=true \
-Dcheckstyle.skip \
Expand Down
10 changes: 10 additions & 0 deletions generation_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ googleapis_commitish: 27aa9d542f54ae1ea1277580550dd04aeb5b09f9
# java-{library.library_name} or java-{library.api-shortname} when
# library.library_name is not defined.
libraries:
- api_shortname: showcase
folder_name: showcase # prevents java-showcase
diegomarquezp marked this conversation as resolved.
Show resolved Hide resolved
excluded_poms: gapic-showcase-bom
name_pretty: Showcase
api_description: Showcase module
product_documentation: https://cloud.google.com/dummy
distribution_name: com.google.cloud:gapic-showcase
library_type: OTHER
GAPICs:
- proto_path: schema/google/showcase/v1beta1
- api_shortname: common-protos
name_pretty: Common Protos
product_documentation: https://github.com/googleapis/api-common-protos
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
java_gapic_library(
deps = [
"//google/cloud/location:location_java_proto",
"//google/iam/v1:iam_java_proto"
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
proto_library_with_info(
# this comment should not indicate an end of a pattern match )
deps = [
"//google/cloud/location:location_proto",
]
)

java_gapic_library(
# this comment should not indicate an end of a pattern match )
deps = [
"//google/iam/v1:iam_java_proto"
],
)
35 changes: 35 additions & 0 deletions java-showcase/.OwlBot-hermetic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


deep-remove-regex:
- "/showcase/grpc-gapic-showcase-v1beta1/src"
- "/showcase/proto-gapic-showcase-v1beta1/src"
- "/showcase/gapic-showcase/src"
- "/showcase/samples/snippets/generated"

deep-preserve-regex:
- "/showcase/gapic-showcase/src/test"

deep-copy-regex:
- source: "/schema/google/showcase/(v.*)/.*-java/proto-.*/src"
dest: "/owl-bot-staging/showcase/$1/proto-gapic-showcase-$1/src"
- source: "/schema/google/showcase/(v.*)/.*-java/grpc-.*/src"
dest: "/owl-bot-staging/showcase/$1/grpc-gapic-showcase-$1/src"
- source: "/schema/google/showcase/(v.*)/.*-java/gapic-.*/src"
dest: "/owl-bot-staging/showcase/$1/gapic-showcase/src"
- source: "/schema/google/showcase/(v.*)/.*-java/samples/snippets/generated"
dest: "/owl-bot-staging/showcase/$1/samples/snippets/generated"

api-name: showcase
16 changes: 16 additions & 0 deletions java-showcase/.repo-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"api_shortname": "showcase",
"name_pretty": "Showcase",
"product_documentation": "https://cloud.google.com/dummy",
"api_description": "Showcase module",
"client_documentation": "https://cloud.google.com/java/docs/reference/gapic-showcase/latest/overview",
"release_level": "preview",
"transport": "both",
"language": "java",
"repo": "googleapis/sdk-platform-java",
"repo_short": "java-showcase",
"distribution_name": "com.google.cloud:gapic-showcase",
"library_type": "OTHER",
"requires_billing": true,
"excluded_poms": "gapic-showcase-bom"
}
22 changes: 13 additions & 9 deletions showcase/README.md → java-showcase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,32 @@ gapic-showcase run
## Running the Integration Tests

Open a new terminal window in the root project directory.
This step does not require Docker.

```shell
cd showcase
mvn verify -P enable-integration-tests -P enable-golden-tests
mvn verify -P enable-integration-tests
```

Note:
## Running the Golden tests

**NOTE** This requires Docker to be installed in your machine.
Open a new terminal window in the root project directory.

```shell
cd java-showcase
mvn verify -P enable-golden-tests
```

* `-P enable-golden-tests` is optional. These tests do not require a local server.

## Update the Golden Showcase Files

**NOTE** This requires Docker to be installed in your machine.
Open a new terminal window in the root project directory.
Note that the underlying scripts will modify your `$HOME` folder by creating a
`.library_generation` folder.
This is the well-known location of the artifacts the generation scripts use.
For more details see the
[development guide](https://github.com/googleapis/sdk-platform-java/blob/main/library_generation/DEVELOPMENT.md#the-hermetic-builds-well-known-folder)

```shell
# In repository's root directory
mvn clean install -DskipTests
cd showcase
cd java-showcase
mvn compile -P update
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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">
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>gapic-showcase</artifactId>
Expand Down Expand Up @@ -104,6 +102,7 @@
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.StubSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.location.GetLocationRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.ServerStreamingCallSettings;
import com.google.api.gax.rpc.StreamingCallSettings;
import com.google.api.gax.rpc.StubSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.location.GetLocationRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.StubSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.location.GetLocationRequest;
Expand Down
Loading
Loading