Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit 28e4bb8

Browse files
committed
restore saved files
1 parent f6c6f02 commit 28e4bb8

6 files changed

Lines changed: 435 additions & 0 deletions

.github/.OwlBot-hermetic.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
docker:
16+
image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest"
17+
18+
deep-remove-regex:
19+
- "/grpc-google-.*/src"
20+
- "/proto-google-.*/src"
21+
- "/google-.*/src"
22+
23+
deep-preserve-regex:
24+
- "/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java"
25+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/SchemaAwareStreamWriter.java"
26+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ToProtoConverter.java"
27+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/BigQuerySchemaUtil.java"
28+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/BigQuerySchemaUtilTest.java"
29+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerPoolTest.java"
30+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java"
31+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v.*/BigQueryReadSettings.java"
32+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v.*/BigQueryReadClient.java"
33+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/util"
34+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v.*/stub/BigQueryReadStubSettings.java"
35+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v.*/stub/EnhancedBigQueryReadStub.java"
36+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v.*/stub/EnhancedBigQueryReadStubSettings.java"
37+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v.*/stub/readrows"
38+
- "/google-cloud-bigquerystorage/src/test/proto"
39+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v.*/stub"
40+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v.*/it"
41+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/util"
42+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v.*/BigQueryReadClientTest.java"
43+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta1/BigQueryStorageClientTest.java"
44+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta1/it/SimpleRowReader.java"
45+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta1/stub/EnhancedBigQueryStorageStubSettingsTest.java"
46+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta1/stub/ResourceHeaderTest.java"
47+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta1/stub/readrows/ReadRowsRetryTest.java"
48+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/BQTableSchemaToProtoDescriptorTest.java"
49+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/BQV2ToBQStorageConverterTest.java"
50+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/BigDecimalByteStringEncoderTest.java"
51+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/BigQueryReadClientTest.java"
52+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/CivilTimeEncoderTest.java"
53+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/FakeBigQueryWrite.java"
54+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/FakeBigQueryWriteImpl.java"
55+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/FakeClock.java"
56+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/FakeScheduledExecutorService.java"
57+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/JsonStreamWriterTest.java"
58+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/JsonToProtoMessageTest.java"
59+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/ProtoSchemaConverterTest.java"
60+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/SchemaCompatibilityTest.java"
61+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/StreamWriterTest.java"
62+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/StreamWriterV2Test.java"
63+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/it/BigQueryResource.java"
64+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/it/SimpleRowReader.java"
65+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/stub/EnhancedBigQueryReadStubSettingsTest.java"
66+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/stub/ResourceHeaderTest.java"
67+
- "/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1.*/stub/readrows/ReadRowsRetryTest.java"
68+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta1/BigQueryStorageClient.java"
69+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta1/BigQueryStorageSettings.java"
70+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta1/stub/EnhancedBigQueryStorageStub.java"
71+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta1/stub/EnhancedBigQueryStorageStubSettings.java"
72+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/BQTableSchemaToProtoDescriptor.java"
73+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/BQV2ToBQStorageConverter.java"
74+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/BigDecimalByteStringEncoder.java"
75+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/CivilTimeEncoder.java"
76+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/JsonStreamWriter.java"
77+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/JsonToProtoMessage.java"
78+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/OnSchemaUpdateRunnable.java"
79+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/ProtoSchemaConverter.java"
80+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/SchemaCompatibility.java"
81+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/StreamConnection.java"
82+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/StreamWriter.java"
83+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/StreamWriterV2.java"
84+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1.*/Waiter.java"
85+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/Exceptions.java"
86+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java"
87+
- "/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerPool.java"
88+
- "/google-cloud-bigquerystorage/src/main/resources/META-INF/native-image/"
89+
90+
deep-copy-regex:
91+
- source: "/google/cloud/bigquery/storage/(v.*)/.*-java/proto-google-.*/src"
92+
dest: "/owl-bot-staging/$1/proto-google-cloud-bigquerystorage-$1/src"
93+
- source: "/google/cloud/bigquery/storage/(v.*)/.*-java/grpc-google-.*/src"
94+
dest: "/owl-bot-staging/$1/grpc-google-cloud-bigquerystorage-$1/src"
95+
- source: "/google/cloud/bigquery/storage/(v.*)/.*-java/gapic-google-.*/src"
96+
dest: "/owl-bot-staging/$1/google-cloud-bigquerystorage/src"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# GitHub action job to test core java library features on
15+
# downstream client libraries before they are released.
16+
name: Hermetic library generation upon generation config change through pull requests
17+
on:
18+
pull_request:
19+
20+
jobs:
21+
library_generation:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
28+
- name: Generate changed libraries
29+
shell: bash
30+
run: |
31+
set -x
32+
[ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com"
33+
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
34+
bash generation/hermetic_library_generation.sh \
35+
--target_branch ${{ github.base_ref }} \
36+
--current_branch ${{ github.head_ref }} \
37+
--image_tag $(cat generation_config.yaml | yq .gapic_generator_version)
38+
env:
39+
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# GitHub action job to test core java library features on
15+
# downstream client libraries before they are released.
16+
name: Update googleapis commit
17+
on:
18+
schedule:
19+
- cron: '0 2 * * *'
20+
workflow_dispatch:
21+
22+
jobs:
23+
update-googleapis-committish:
24+
runs-on: ubuntu-22.04
25+
env:
26+
# the branch into which the pull request is merged
27+
base_branch: main
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
32+
- name: Update googleapis committish to latest
33+
shell: bash
34+
run: |
35+
set -x
36+
[ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com"
37+
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
38+
bash generation/update_googleapis_committish.sh \
39+
--base_branch "${base_branch}"\
40+
--repo ${{ github.repository }}
41+
env:
42+
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
set -e
3+
# This script should be run at the root of the repository.
4+
# This script is used to, when a pull request changes the generation
5+
# configuration (generation_config.yaml by default):
6+
# 1. Find whether the last commit in this pull request contains changes to
7+
# the generation configuration and exit early if it doesn't have such a change
8+
# since the generation result would be the same.
9+
# 2. Compare generation configurations in the current branch (with which the
10+
# pull request associated) and target branch (into which the pull request is
11+
# merged);
12+
# 3. Generate changed libraries using library_generation image;
13+
# 4. Commit the changes to the pull request, if any.
14+
# 5. Edit the PR body with generated pull request description, if applicable.
15+
16+
# The following commands need to be installed before running the script:
17+
# 1. git
18+
# 2. gh
19+
# 3. docker
20+
21+
# The parameters of this script is:
22+
# 1. target_branch, the branch into which the pull request is merged.
23+
# 2. current_branch, the branch with which the pull request is associated.
24+
# 3. image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation.
25+
# 3. [optional] generation_config, the path to the generation configuration,
26+
# the default value is generation_config.yaml in the repository root.
27+
while [[ $# -gt 0 ]]; do
28+
key="$1"
29+
case "${key}" in
30+
--target_branch)
31+
target_branch="$2"
32+
shift
33+
;;
34+
--current_branch)
35+
current_branch="$2"
36+
shift
37+
;;
38+
--image_tag)
39+
image_tag="$2"
40+
shift
41+
;;
42+
--generation_config)
43+
generation_config="$2"
44+
shift
45+
;;
46+
*)
47+
echo "Invalid option: [$1]"
48+
exit 1
49+
;;
50+
esac
51+
shift
52+
done
53+
54+
if [ -z "${target_branch}" ]; then
55+
echo "missing required argument --target_branch"
56+
exit 1
57+
fi
58+
59+
if [ -z "${current_branch}" ]; then
60+
echo "missing required argument --current_branch"
61+
exit 1
62+
fi
63+
64+
if [ -z "${image_tag}" ]; then
65+
echo "missing required argument --image_tag"
66+
exit 1
67+
fi
68+
69+
if [ -z "${generation_config}" ]; then
70+
generation_config=generation_config.yaml
71+
echo "Use default generation config: ${generation_config}"
72+
fi
73+
74+
workspace_name="/workspace"
75+
baseline_generation_config="baseline_generation_config.yaml"
76+
message="chore: generate libraries at $(date)"
77+
78+
git checkout "${target_branch}"
79+
git checkout "${current_branch}"
80+
# if the last commit doesn't contain changes to generation configuration,
81+
# do not generate again as the result will be the same.
82+
change_of_last_commit="$(git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r)"
83+
if [[ ! ("${change_of_last_commit}" == *"${generation_config}"*) ]]; then
84+
echo "The last commit doesn't contain any changes to the generation_config.yaml, skipping the whole generation process." || true
85+
exit 0
86+
fi
87+
# copy generation configuration from target branch to current branch.
88+
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"
89+
config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true)
90+
91+
# run hermetic code generation docker image.
92+
docker run \
93+
--rm \
94+
-u "$(id -u):$(id -g)" \
95+
-v "$(pwd):${workspace_name}" \
96+
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \
97+
--baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \
98+
--current-generation-config-path="${workspace_name}/${generation_config}"
99+
100+
101+
# commit the change to the pull request.
102+
if [[ $(basename $(pwd)) == "google-cloud-java" ]]; then
103+
git add java-* pom.xml gapic-libraries-bom/pom.xml versions.txt
104+
else
105+
# The image leaves intermediate folders and files it works with. Here we remove them
106+
rm -rdf output googleapis "${baseline_generation_config}"
107+
git add --all -- ':!pr_description.txt'
108+
fi
109+
changed_files=$(git diff --cached --name-only)
110+
if [[ "${changed_files}" == "" ]]; then
111+
echo "There is no generated code change with the generation config change ${config_diff}."
112+
echo "Skip committing to the pull request."
113+
exit 0
114+
fi
115+
116+
echo "Configuration diff:"
117+
echo "${config_diff}"
118+
git commit -m "${message}"
119+
git push
120+
# set pr body if pr_description.txt is generated.
121+
if [[ -f "pr_description.txt" ]]; then
122+
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
123+
gh pr edit "${pr_num}" --body "$(cat pr_description.txt)"
124+
fi
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
set -e
3+
# This script should be run at the root of the repository.
4+
# This script is used to update googleapis committish to latest in generation
5+
# configuration at the time of running and create a pull request.
6+
7+
# The following commands need to be installed before running the script:
8+
# 1. git
9+
# 2. gh
10+
11+
# The parameters of this script is:
12+
# 1. base_branch, the base branch of the result pull request.
13+
# 2. repo, organization/repo-name, e.g., googleapis/google-cloud-java
14+
# 3. [optional] generation_config, the path to the generation configuration,
15+
# the default value is generation_config.yaml in the repository root.
16+
while [[ $# -gt 0 ]]; do
17+
key="$1"
18+
case "${key}" in
19+
--base_branch)
20+
base_branch="$2"
21+
shift
22+
;;
23+
--repo)
24+
repo="$2"
25+
shift
26+
;;
27+
--generation_config)
28+
generation_config="$2"
29+
shift
30+
;;
31+
*)
32+
echo "Invalid option: [$1]"
33+
exit 1
34+
;;
35+
esac
36+
shift
37+
done
38+
39+
if [ -z "${base_branch}" ]; then
40+
echo "missing required argument --base_branch"
41+
exit 1
42+
fi
43+
44+
if [ -z "${repo}" ]; then
45+
echo "missing required argument --repo"
46+
exit 1
47+
fi
48+
49+
if [ -z "${generation_config}" ]; then
50+
generation_config="generation_config.yaml"
51+
echo "Use default generation config: ${generation_config}"
52+
fi
53+
54+
current_branch="generate-libraries-${base_branch}"
55+
title="chore: update googleapis committish at $(date)"
56+
57+
# try to find a open pull request associated with the branch
58+
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
59+
# create a branch if there's no open pull request associated with the
60+
# branch; otherwise checkout the pull request.
61+
if [ -z "${pr_num}" ]; then
62+
git checkout -b "${current_branch}"
63+
else
64+
gh pr checkout "${pr_num}"
65+
fi
66+
67+
mkdir tmp-googleapis
68+
# use partial clone because only commit history is needed.
69+
git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis
70+
pushd tmp-googleapis
71+
git pull
72+
latest_commit=$(git rev-parse HEAD)
73+
popd
74+
rm -rf tmp-googleapis
75+
sed -i -e "s/^googleapis_commitish.*$/googleapis_commitish: ${latest_commit}/" "${generation_config}"
76+
77+
git add "${generation_config}"
78+
changed_files=$(git diff --cached --name-only)
79+
if [[ "${changed_files}" == "" ]]; then
80+
echo "The latest googleapis commit is not changed."
81+
echo "Skip committing to the pull request."
82+
exit 0
83+
fi
84+
git commit -m "${title}"
85+
if [ -z "${pr_num}" ]; then
86+
git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git"
87+
git fetch -q --unshallow remote_repo
88+
git push -f remote_repo "${current_branch}"
89+
gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}"
90+
else
91+
git push
92+
fi

0 commit comments

Comments
 (0)