Skip to content

Commit bd317e2

Browse files
committed
Fix CI against standard
2 parents 4d41c82 + 2cab2e0 commit bd317e2

432 files changed

Lines changed: 12238 additions & 4132 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/.OwlBot-hermetic.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
docker:
2-
image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest"
3-
41
deep-remove-regex:
52
- "/grpc-google-.*/src"
63
- "/proto-google-.*/src"

.github/CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
# for handwritten libraries, keep codeowner_team in .repo-metadata.json as owner
1111
**/*.java @googleapis/api-firestore @googleapis/firestore-dpe
1212

13+
# For generated Java code
14+
proto-*/ @googleapis/yoshi-java @googleapis/api-firestore @googleapis/firestore-dpe
15+
grpc-*/ @googleapis/yoshi-java @googleapis/api-firestore @googleapis/firestore-dpe
16+
# Generated code pattern in google-cloud-firestore and google-cloud-firestore-admin
17+
**/*Client.java @googleapis/yoshi-java @googleapis/api-firestore @googleapis/firestore-dpe
18+
**/*Settings.java @googleapis/yoshi-java @googleapis/api-firestore @googleapis/firestore-dpe
19+
**/*ClientHttpJsonTest.java @googleapis/yoshi-java @googleapis/api-firestore @googleapis/firestore-dpe
20+
**/*ClientTest.java @googleapis/yoshi-java @googleapis/api-firestore @googleapis/firestore-dpe
1321

1422
# The java-samples-reviewers team is the default owner for samples changes
1523
samples/**/*.java @googleapis/java-samples-reviewers

.github/generated-files-bot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ externalManifests:
66
file: '.github/readme/synth.metadata/synth.metadata'
77
jsonpath: '$.generatedFiles[*]'
88
ignoreAuthors:
9+
- 'cloud-java-bot'
910
- 'renovate-bot'
1011
- 'yoshi-automation'
1112
- 'release-please[bot]'

.github/release-please.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ branches:
66
handleGHRelease: true
77
releaseType: java-yoshi
88
branch: java7
9+
- bumpMinorPreMajor: true
10+
handleGHRelease: true
11+
releaseType: java-yoshi
12+
branch: protobuf-4.x-rc
13+
manifest: true

.github/scripts/hermetic_library_generation.sh

Lines changed: 0 additions & 117 deletions
This file was deleted.

.github/scripts/update_generation_config.sh

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -e
2+
set -ex
33
# This script should be run at the root of the repository.
44
# This script is used to update googleapis_commitish, gapic_generator_version,
55
# and libraries_bom_version in generation configuration at the time of running
@@ -15,8 +15,17 @@ set -e
1515
function get_latest_released_version() {
1616
local group_id=$1
1717
local artifact_id=$2
18-
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)
19-
echo "${latest}"
18+
group_id_url_path="$(sed 's|\.|/|g' <<< "${group_id}")"
19+
url="https://repo1.maven.org/maven2/${group_id_url_path}/${artifact_id}/maven-metadata.xml"
20+
xml_content=$(curl -s --fail "${url}")
21+
latest=$(xmllint --xpath 'metadata/versioning/latest/text()' - <<< "${xml_content}")
22+
if [[ -z "${latest}" ]]; then
23+
echo "The latest version of ${group_id}:${artifact_id} is empty."
24+
echo "The returned json from maven.org is invalid: ${json_content}"
25+
exit 1
26+
else
27+
echo "${latest}"
28+
fi
2029
}
2130

2231
# Update a key to a new value in the generation config.
@@ -28,11 +37,23 @@ function update_config() {
2837
sed -i -e "s/^${key_word}.*$/${key_word}: ${new_value}/" "${file}"
2938
}
3039

40+
# Update an action to a new version in GitHub action.
41+
function update_action() {
42+
local key_word=$1
43+
local new_value=$2
44+
local file=$3
45+
echo "Update ${key_word} to ${new_value} in ${file}"
46+
# use a different delimiter because the key_word contains "/".
47+
sed -i -e "s|${key_word}@v.*$|${key_word}@v${new_value}|" "${file}"
48+
}
49+
3150
# The parameters of this script is:
3251
# 1. base_branch, the base branch of the result pull request.
3352
# 2. repo, organization/repo-name, e.g., googleapis/google-cloud-java
3453
# 3. [optional] generation_config, the path to the generation configuration,
3554
# the default value is generation_config.yaml in the repository root.
55+
# 4. [optional] workflow, the library generation workflow file,
56+
# the default value is .github/workflows/hermetic_library_generation.yaml.
3657
while [[ $# -gt 0 ]]; do
3758
key="$1"
3859
case "${key}" in
@@ -48,6 +69,10 @@ case "${key}" in
4869
generation_config="$2"
4970
shift
5071
;;
72+
--workflow)
73+
workflow="$2"
74+
shift
75+
;;
5176
*)
5277
echo "Invalid option: [$1]"
5378
exit 1
@@ -71,21 +96,34 @@ if [ -z "${generation_config}" ]; then
7196
echo "Use default generation config: ${generation_config}"
7297
fi
7398

99+
if [ -z "${workflow}" ]; then
100+
workflow=".github/workflows/hermetic_library_generation.yaml"
101+
echo "Use default library generation workflow file: ${workflow}"
102+
fi
103+
74104
current_branch="generate-libraries-${base_branch}"
75105
title="chore: Update generation configuration at $(date)"
76106

77-
# try to find a open pull request associated with the branch
107+
git checkout "${base_branch}"
108+
# Try to find a open pull request associated with the branch
78109
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
79-
# create a branch if there's no open pull request associated with the
110+
# Create a branch if there's no open pull request associated with the
80111
# branch; otherwise checkout the pull request.
81112
if [ -z "${pr_num}" ]; then
82113
git checkout -b "${current_branch}"
114+
# Push the current branch to remote so that we can
115+
# compare the commits later.
116+
git push -u origin "${current_branch}"
83117
else
84118
gh pr checkout "${pr_num}"
85119
fi
86120

121+
# Only allow fast-forward merging; exit with non-zero result if there's merging
122+
# conflict.
123+
git merge -m "chore: merge ${base_branch} into ${current_branch}" "${base_branch}"
124+
87125
mkdir tmp-googleapis
88-
# use partial clone because only commit history is needed.
126+
# Use partial clone because only commit history is needed.
89127
git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis
90128
pushd tmp-googleapis
91129
git pull
@@ -94,25 +132,43 @@ popd
94132
rm -rf tmp-googleapis
95133
update_config "googleapis_commitish" "${latest_commit}" "${generation_config}"
96134

97-
# update gapic-generator-java version to the latest
135+
# Update gapic-generator-java version to the latest
98136
latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java")
99137
update_config "gapic_generator_version" "${latest_version}" "${generation_config}"
100138

101-
# update libraries-bom version to the latest
139+
# Update composite action version to latest gapic-generator-java version
140+
update_action "googleapis/sdk-platform-java/.github/scripts" \
141+
"${latest_version}" \
142+
"${workflow}"
143+
144+
# Update libraries-bom version to the latest
102145
latest_version=$(get_latest_released_version "com.google.cloud" "libraries-bom")
103146
update_config "libraries_bom_version" "${latest_version}" "${generation_config}"
104147

105-
git add "${generation_config}"
148+
git add "${generation_config}" "${workflow}"
106149
changed_files=$(git diff --cached --name-only)
107150
if [[ "${changed_files}" == "" ]]; then
108151
echo "The latest generation config is not changed."
109152
echo "Skip committing to the pull request."
153+
else
154+
git commit -m "${title}"
155+
fi
156+
157+
# There are potentially at most two commits: merge commit and change commit.
158+
# We want to exit the script if no commit happens (otherwise this will be an
159+
# infinite loop).
160+
# `git cherry` is a way to find whether the local branch has commits that are
161+
# not in the remote branch.
162+
# If we find any such commit, push them to remote branch.
163+
unpushed_commit=$(git cherry -v "origin/${current_branch}" | wc -l)
164+
if [[ "${unpushed_commit}" -eq 0 ]]; then
165+
echo "No unpushed commits, exit"
110166
exit 0
111167
fi
112-
git commit -m "${title}"
168+
113169
if [ -z "${pr_num}" ]; then
114170
git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git"
115-
git fetch -q --unshallow remote_repo
171+
git fetch -q remote_repo
116172
git push -f remote_repo "${current_branch}"
117173
gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}"
118174
else

.github/sync-repo-settings.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ branchProtectionRules:
1616
- 'Kokoro - Test: Integration'
1717
- 'Kokoro - Test: Integration Against Named DB'
1818
- cla/google
19-
- 'Kokoro - Test: Java GraalVM Native Image'
20-
- 'Kokoro - Test: Java 17 GraalVM Native Image'
19+
- 'Kokoro - Test: Java GraalVM Native Image A'
20+
- 'Kokoro - Test: Java GraalVM Native Image B'
21+
- 'Kokoro - Test: Java GraalVM Native Image C'
2122
- javadoc
23+
- library_generation
24+
- unmanaged_dependency_check
2225
- pattern: java7
2326
isAdminEnforced: true
2427
requiredApprovingReviewCount: 1

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
java: [11, 17, 21]
28+
java: [11, 17, 21, 25]
2929
steps:
3030
- uses: actions/checkout@v3
3131
- uses: actions/setup-java@v3
@@ -104,7 +104,7 @@ jobs:
104104
- uses: actions/setup-java@v3
105105
with:
106106
distribution: temurin
107-
java-version: 11
107+
java-version: 17
108108
- run: java -version
109109
- run: .kokoro/build.sh
110110
env:

.github/workflows/hermetic_library_generation.yaml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,29 @@ name: Hermetic library generation upon generation config change through pull req
1717
on:
1818
pull_request:
1919

20+
env:
21+
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
22+
GITHUB_REPOSITORY: ${{ github.repository }}
2023
jobs:
2124
library_generation:
22-
# skip pull requests coming from a forked repository
23-
if: github.event.pull_request.head.repo.full_name == github.repository
2425
runs-on: ubuntu-latest
2526
steps:
27+
- name: Determine whether the pull request comes from a fork
28+
run: |
29+
if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then
30+
echo "This PR comes from a fork. Skip library generation."
31+
echo "SHOULD_RUN=false" >> $GITHUB_ENV
32+
else
33+
echo "SHOULD_RUN=true" >> $GITHUB_ENV
34+
fi
2635
- uses: actions/checkout@v4
36+
if: env.SHOULD_RUN == 'true'
2737
with:
2838
fetch-depth: 0
2939
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
30-
- name: Generate changed libraries
31-
shell: bash
32-
run: |
33-
set -x
34-
[ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com"
35-
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
36-
bash .github/scripts/hermetic_library_generation.sh \
37-
--target_branch ${{ github.base_ref }} \
38-
--current_branch ${{ github.head_ref }}
39-
env:
40-
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
40+
- uses: googleapis/sdk-platform-java/.github/scripts@v2.64.2
41+
if: env.SHOULD_RUN == 'true'
42+
with:
43+
base_ref: ${{ github.base_ref }}
44+
head_ref: ${{ github.head_ref }}
45+
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}

.github/workflows/renovate_config_check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
renovate_bot_config_validation:
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-24.04
1111

1212
steps:
1313
- name: Checkout code
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Node.js
1717
uses: actions/setup-node@v3
1818
with:
19-
node-version: '20'
19+
node-version: '22'
2020

2121
- name: Install Renovate and Config Validator
2222
run: |

0 commit comments

Comments
 (0)