Skip to content

Commit

Permalink
Merge branch 'main' into change-streams-txn-exclusion-sample
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Oct 11, 2024
2 parents fc78608 + 6dfc494 commit 87cfe16
Show file tree
Hide file tree
Showing 738 changed files with 81,409 additions and 18,243 deletions.
4 changes: 0 additions & 4 deletions .github/.OwlBot.yaml → .github/.OwlBot-hermetic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
# 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.

docker:
image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest"

deep-remove-regex:
- "/grpc-google-.*/src"
- "/proto-google-.*/src"
Expand Down
17 changes: 0 additions & 17 deletions .github/.OwlBot.lock.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ branches:
bumpMinorPreMajor: true
handleGHRelease: true
branch: 6.55.x
- releaseType: java-backport
bumpMinorPreMajor: true
handleGHRelease: true
branch: 6.67.x
- releaseType: java-backport
bumpMinorPreMajor: true
handleGHRelease: true
branch: 6.66.x
121 changes: 121 additions & 0 deletions .github/scripts/update_generation_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/bin/bash
set -e
# This script should be run at the root of the repository.
# This script is used to update googleapis_commitish, gapic_generator_version,
# and libraries_bom_version in generation configuration at the time of running
# and create a pull request.

# The following commands need to be installed before running the script:
# 1. git
# 2. gh
# 3. jq

# Utility functions
# Get the latest released version of a Maven artifact.
function get_latest_released_version() {
local group_id=$1
local artifact_id=$2
latest=$(curl -s "https://search.maven.org/solrsearch/select?q=g:${group_id}+AND+a:${artifact_id}&core=gav&rows=500&wt=json" | jq -r '.response.docs[] | select(.v | test("^[0-9]+(\\.[0-9]+)*$")) | .v' | sort -V | tail -n 1)
echo "${latest}"
}

# Update a key to a new value in the generation config.
function update_config() {
local key_word=$1
local new_value=$2
local file=$3
echo "Update ${key_word} to ${new_value} in ${file}"
sed -i -e "s/^${key_word}.*$/${key_word}: ${new_value}/" "${file}"
}

# The parameters of this script is:
# 1. base_branch, the base branch of the result pull request.
# 2. repo, organization/repo-name, e.g., googleapis/google-cloud-java
# 3. [optional] generation_config, the path to the generation configuration,
# the default value is generation_config.yaml in the repository root.
while [[ $# -gt 0 ]]; do
key="$1"
case "${key}" in
--base_branch)
base_branch="$2"
shift
;;
--repo)
repo="$2"
shift
;;
--generation_config)
generation_config="$2"
shift
;;
*)
echo "Invalid option: [$1]"
exit 1
;;
esac
shift
done

if [ -z "${base_branch}" ]; then
echo "missing required argument --base_branch"
exit 1
fi

if [ -z "${repo}" ]; then
echo "missing required argument --repo"
exit 1
fi

if [ -z "${generation_config}" ]; then
generation_config="generation_config.yaml"
echo "Use default generation config: ${generation_config}"
fi

current_branch="generate-libraries-${base_branch}"
title="chore: Update generation configuration at $(date)"

# try to find a open pull request associated with the branch
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
# create a branch if there's no open pull request associated with the
# branch; otherwise checkout the pull request.
if [ -z "${pr_num}" ]; then
git checkout -b "${current_branch}"
else
gh pr checkout "${pr_num}"
fi

mkdir tmp-googleapis
# use partial clone because only commit history is needed.
git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis
pushd tmp-googleapis
git pull
latest_commit=$(git rev-parse HEAD)
popd
rm -rf tmp-googleapis
update_config "googleapis_commitish" "${latest_commit}" "${generation_config}"

# update gapic-generator-java version to the latest
latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java")
update_config "gapic_generator_version" "${latest_version}" "${generation_config}"

# update libraries-bom version to the latest
latest_version=$(get_latest_released_version "com.google.cloud" "libraries-bom")
update_config "libraries_bom_version" "${latest_version}" "${generation_config}"

git add "${generation_config}"
changed_files=$(git diff --cached --name-only)
if [[ "${changed_files}" == "" ]]; then
echo "The latest generation config is not changed."
echo "Skip committing to the pull request."
exit 0
fi
git commit -m "${title}"
if [ -z "${pr_num}" ]; then
git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git"
git fetch -q --unshallow remote_repo
git push -f remote_repo "${current_branch}"
gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}"
else
git push
gh pr edit "${pr_num}" --title "${title}" --body "${title}"
fi
21 changes: 19 additions & 2 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ branchProtectionRules:
- checkstyle
- compile (8)
- compile (11)
- OwlBot Post Processor
- units-with-multiplexed-session (8)
- units-with-multiplexed-session (11)
- pattern: 3.3.x
Expand Down Expand Up @@ -141,7 +140,25 @@ branchProtectionRules:
- checkstyle
- compile (8)
- compile (11)
- OwlBot Post Processor
- pattern: 6.66.x
isAdminEnforced: true
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: false
requiredStatusCheckContexts:
- dependencies (17)
- lint
- javadoc
- units (8)
- units (11)
- 'Kokoro - Test: Integration'
- 'Kokoro - Test: Integration with Multiplexed Sessions'
- cla/google
- checkstyle
- compile (8)
- compile (11)
- units-with-multiplexed-session (8)
- units-with-multiplexed-session (11)
permissionRules:
- team: yoshi-admins
permission: admin
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/approve-readme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme'
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@v7
with:
github-token: ${{secrets.YOSHI_APPROVER_TOKEN}}
script: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- run: .kokoro/build.sh
env:
JOB_TYPE: test
GOOGLE_CLOUD_SPANNER_ENABLE_MULTIPLEXED_SESSIONS: true
GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS: true
units-java8:
# Building using Java 17 and run the tests with Java 8 runtime
name: "units (8)"
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
- run: .kokoro/build.sh
env:
JOB_TYPE: test
GOOGLE_CLOUD_SPANNER_ENABLE_MULTIPLEXED_SESSIONS: true
GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS: true
windows:
runs-on: windows-latest
steps:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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.
# GitHub action job to test core java library features on
# downstream client libraries before they are released.
name: Hermetic library generation upon generation config change through pull requests
on:
pull_request:

env:
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
jobs:
library_generation:
runs-on: ubuntu-latest
steps:
- name: Determine whether the pull request comes from a fork
run: |
if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then
echo "This PR comes from a fork. Skip library generation."
echo "SHOULD_RUN=false" >> $GITHUB_ENV
else
echo "SHOULD_RUN=true" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
if: env.SHOULD_RUN == 'true'
with:
fetch-depth: 0
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
- uses: googleapis/sdk-platform-java/.github/[email protected]
if: env.SHOULD_RUN == 'true'
with:
base_ref: ${{ github.base_ref }}
head_ref: ${{ github.head_ref }}
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
env:
JOB_TYPE: test
SPANNER_EMULATOR_HOST: localhost:9010
GOOGLE_CLOUD_SPANNER_ENABLE_MULTIPLEXED_SESSIONS: true
GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS: true
2 changes: 1 addition & 1 deletion .github/workflows/renovate_config_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unmanaged_dependency_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
# repository
.kokoro/build.sh
- name: Unmanaged dependency check
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.30.0
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.37.0
with:
bom-path: google-cloud-spanner-bom/pom.xml
42 changes: 42 additions & 0 deletions .github/workflows/update_generation_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.
# GitHub action job to test core java library features on
# downstream client libraries before they are released.
name: Update generation configuration
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:

jobs:
update-generation-config:
runs-on: ubuntu-24.04
env:
# the branch into which the pull request is merged
base_branch: main
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
- name: Update params in generation config to latest
shell: bash
run: |
set -x
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
bash .github/scripts/update_generation_config.sh \
--base_branch "${base_branch}"\
--repo ${{ github.repository }}
env:
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
15 changes: 15 additions & 0 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI
export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS})
fi

# Start the Spanner emulator if the environment variable for it has been set.
# TODO: Change if statement once the env var can be set in the config.
#if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then
if [[ "$JOB_TYPE" == "graalvm" ]] || [[ "$JOB_TYPE" == "graalvm17" ]]; then
echo "Starting emulator"
export SPANNER_EMULATOR_HOST=localhost:9010
docker pull gcr.io/cloud-spanner-emulator/emulator
docker run -d --rm --name spanner-emulator -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator
fi

# Kokoro integration test uses both JDK 11 and JDK 8. We ensure the generated class files
# are compatible with Java 8 when running tests.
if [ -n "${JAVA8_HOME}" ]; then
Expand Down Expand Up @@ -233,6 +243,11 @@ clirr)
;;
esac

if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then
echo "Stopping emulator"
docker container stop spanner-emulator
fi

if [ "${REPORT_COVERAGE}" == "true" ]
then
bash ${KOKORO_GFILE_DIR}/codecov.sh
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native-17.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.30.0"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.37.0"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.30.0"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.37.0"
}

env_vars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ env_vars: {
}

env_vars: {
key: "GOOGLE_CLOUD_SPANNER_ENABLE_MULTIPLEXED_SESSIONS"
key: "GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS"
value: "true"
}
}
Loading

0 comments on commit 87cfe16

Please sign in to comment.