From 6b0f19a31b931fb7b78102737deb18aba9200a15 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 2 Oct 2024 09:34:51 -0400 Subject: [PATCH 1/2] chore: use composite action --- .../scripts/hermetic_library_generation.sh | 116 ------------------ .../hermetic_library_generation.yaml | 19 +-- 2 files changed, 5 insertions(+), 130 deletions(-) delete mode 100644 .github/scripts/hermetic_library_generation.sh diff --git a/.github/scripts/hermetic_library_generation.sh b/.github/scripts/hermetic_library_generation.sh deleted file mode 100644 index 49a7414cf..000000000 --- a/.github/scripts/hermetic_library_generation.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -set -e -# 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): -# 1. Find whether the last commit in this pull request contains changes to -# the generation configuration and exit early if it doesn't have such a change -# since the generation result would be the same. -# 2. Compare generation configurations in the current branch (with which the -# pull request associated) and target branch (into which the pull request is -# merged); -# 3. Generate changed libraries using library_generation image; -# 4. Commit the changes to the pull request, if any. -# 5. Edit the PR body with generated pull request description, if applicable. - -# The following commands need to be installed before running the script: -# 1. git -# 2. gh -# 3. docker - -# The parameters of this script is: -# 1. target_branch, the branch into which the pull request is merged. -# 2. current_branch, the branch with which the pull request is associated. -# 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 - --target_branch) - target_branch="$2" - shift - ;; - --current_branch) - current_branch="$2" - shift - ;; - --generation_config) - generation_config="$2" - shift - ;; - *) - echo "Invalid option: [$1]" - exit 1 - ;; -esac -shift -done - -if [ -z "${target_branch}" ]; then - echo "missing required argument --target_branch" - exit 1 -fi - -if [ -z "${current_branch}" ]; then - echo "missing required argument --current_branch" - exit 1 -fi - -if [ -z "${generation_config}" ]; then - generation_config=generation_config.yaml - echo "Using default generation config: ${generation_config}" -fi - -workspace_name="/workspace" -baseline_generation_config="baseline_generation_config.yaml" -message="chore: generate libraries at $(date)" - -git checkout "${target_branch}" -git checkout "${current_branch}" - -# copy generation configuration from target branch to current branch. -git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}" - -# parse image tag from the generation configuration. -image_tag=$(grep "gapic_generator_version" "${generation_config}" | cut -d ':' -f 2 | xargs) - -repo_root_dir=$(pwd) -mkdir -p "${repo_root_dir}/output" -# download api definitions from googleapis repository -googleapis_commitish=$(grep googleapis_commitish "${generation_config}" | cut -d ":" -f 2 | xargs) -api_def_dir=$(mktemp -d) -git clone https://github.com/googleapis/googleapis.git "${api_def_dir}" -pushd "${api_def_dir}" -git checkout "${googleapis_commitish}" -cp -r google/ grafeas/ "${repo_root_dir}/output" -popd - -# run hermetic code generation docker image. -docker run \ - --rm \ - -u "$(id -u):$(id -g)" \ - -v "$(pwd):${workspace_name}" \ - gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \ - --baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \ - --current-generation-config-path="${workspace_name}/${generation_config}" - -# remove api definitions after generation -rm -rf "${api_def_dir}" - -# commit the change to the pull request. -rm -rdf output googleapis "${baseline_generation_config}" -git add --all -- ':!pr_description.txt' ':!hermetic_library_generation.sh' -changed_files=$(git diff --cached --name-only) -if [[ "${changed_files}" != "" ]]; then - echo "Commit changes..." - git commit -m "${message}" - git push -else - echo "There is no generated code change, skip commit." -fi - -# set pr body if pr_description.txt is generated. -if [[ -f "pr_description.txt" ]]; then - pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number") - gh pr edit "${pr_num}" --body "$(cat pr_description.txt)" -fi diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml index 0266fbc96..4caa5567a 100644 --- a/.github/workflows/hermetic_library_generation.yaml +++ b/.github/workflows/hermetic_library_generation.yaml @@ -20,7 +20,6 @@ on: env: REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }} GITHUB_REPOSITORY: ${{ github.repository }} - jobs: library_generation: runs-on: ubuntu-latest @@ -38,17 +37,9 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} - - name: Generate changed libraries + - uses: googleapis/sdk-platform-java/.github/scripts@v2.46.0 if: env.SHOULD_RUN == 'true' - shell: bash - run: | - set -ex - [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" - [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" - bash .github/scripts/hermetic_library_generation.sh \ - --target_branch "${BASE_REF}" \ - --current_branch "${HEAD_REF}" - env: - BASE_REF: ${{ github.base_ref }} - HEAD_REF: ${{ github.head_ref }} - GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + with: + base_ref: ${{ github.base_ref }} + head_ref: ${{ github.head_ref }} + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} From 865d77c015db57413a6e7463e8c9bbf19756bf04 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Wed, 2 Oct 2024 13:38:12 +0000 Subject: [PATCH 2/2] chore: generate libraries at Wed Oct 2 13:35:35 UTC 2024 --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 144f2e567..da7d93a81 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: com.google.cloud libraries-bom - 26.45.0 + 26.47.0 pom import @@ -42,7 +42,7 @@ If you are using Maven without the BOM, add this to your dependencies: com.google.cloud google-cloud-datastore - 2.21.3 + 2.22.0 ``` @@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-datastore' If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-datastore:2.21.3' +implementation 'com.google.cloud:google-cloud-datastore:2.22.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-datastore" % "2.21.3" +libraryDependencies += "com.google.cloud" % "google-cloud-datastore" % "2.22.0" ``` @@ -370,7 +370,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-datastore/tre | Sum Aggregation With Limit | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.java) | | Sum Aggregation With Order By | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.java) | | Sum Aggregation With Property Filter | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.java) | +| Indexing Consideration Query | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java) | | Create a union between two filters | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.java) | +| Order Fields Query | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java) | | Query Profile Explain | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.java) | | Query Profile Explain Aggregation | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.java) | | Query Profile Explain Analyze | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.java) | @@ -479,7 +481,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-datastore/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-datastore.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-datastore/2.21.3 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-datastore/2.22.0 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles