Skip to content

Commit f5a4826

Browse files
committed
Merge branch 'observability/test/compute-integration-test' of https://github.com/googleapis/google-cloud-java into observability/test/compute-integration-test
2 parents 2b26d95 + 819169c commit f5a4826

1,426 files changed

Lines changed: 12177 additions & 4932 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/release-note-generation/split_release_note.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def detect_modules(root_directory: Path):
6969
tree = ET.parse(module_pom_xml)
7070
root = tree.getroot()
7171
version = root.find('mvn:version', POM_NAMESPACES).text
72+
api_name = None
7273
if owlbot_yaml_path.exists():
7374
# If OwlBot configuration file exists (most cases), it's the better
7475
# source to get the OwlBot-generated pull request title prefix than
@@ -78,21 +79,21 @@ def detect_modules(root_directory: Path):
7879
match = re.search(r'api-name: (.+)', owlbot_yaml_content)
7980
if match:
8081
api_name = match.group(1)
81-
modules.append(LibraryModule(module_path, api_name,
82-
version,
83-
changelog))
82+
83+
if not api_name:
84+
# Fallback to repo-metadata.json (e.g. for vertexai or Spanner transitional state)
85+
if repo_metadata_path.exists():
86+
with open(repo_metadata_path, 'r') as file:
87+
repo_metadata = json.load(file)
88+
api_name = repo_metadata.get('api_shortname')
89+
90+
if api_name:
91+
modules.append(LibraryModule(module_path, api_name,
92+
version,
93+
changelog))
8494
else:
85-
# vertexai (handwritten) does not have OwlBot yaml file
86-
with open(repo_metadata_path, 'r') as file:
87-
repo_metadata = json.load(file)
88-
api_name = repo_metadata['api_shortname']
89-
if api_name:
90-
modules.append(LibraryModule(repo_metadata_path.parent, api_name,
91-
version,
92-
changelog))
93-
else:
94-
raise Exception(f'repo_metadata_path {repo_metadata_path} does'
95-
f' not have api_shortname field')
95+
raise Exception(f'Could not determine api-name for {repo_metadata_path}')
96+
9697

9798
return modules
9899

@@ -133,7 +134,7 @@ def group_changes_by_api(main_changes: [str]):
133134
elif section == BUG_FIXES_SECTION:
134135
api_to_changelog[api_name].bug_fixes.append(note)
135136
elif section == DEPENDENCIES_SECTION:
136-
api_to_changelog[api_name].dependencies.append(note)
137+
api_to_changelog[api_name].dependency_upgrades.append(note)
137138
return api_to_changelog
138139

139140

.github/release-note-generation/unit_test.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import unittest
2+
import tempfile
3+
import json
4+
from pathlib import Path
25

36
# Unit tests for split_release_note.py
47

5-
from split_release_note import LibraryModule, create_changelog_entry, group_changes_by_api, ChangesOnApi
6-
from pathlib import Path
8+
from split_release_note import LibraryModule, create_changelog_entry, group_changes_by_api, ChangesOnApi, detect_modules
79

810
dummy_module = LibraryModule(
911
Path('release-note-generation/test/java-analyics-admin'),
@@ -81,6 +83,31 @@ def test_group_changes_by_api(self):
8183
['No change']),
8284
['No change'])
8385

86+
def test_detect_modules_fallback(self):
87+
with tempfile.TemporaryDirectory() as tmpdirname:
88+
tmp_path = Path(tmpdirname)
89+
module_path = tmp_path / "java-spanner"
90+
module_path.mkdir()
91+
92+
# Create minimal pom.xml
93+
pom_path = module_path / "pom.xml"
94+
with open(pom_path, "w") as f:
95+
f.write('<project xmlns:mvn="http://maven.apache.org/POM/4.0.0"><mvn:version>1.0.0</mvn:version></project>')
96+
97+
# Create .repo-metadata.json with api_shortname
98+
metadata_path = module_path / ".repo-metadata.json"
99+
with open(metadata_path, "w") as f:
100+
json.dump({"api_shortname": "spanner"}, f)
101+
102+
# Create CHANGELOG.md
103+
changelog_path = module_path / "CHANGELOG.md"
104+
changelog_path.touch()
105+
106+
modules = detect_modules(tmp_path)
107+
self.assertEqual(len(modules), 1)
108+
self.assertEqual(modules[0].api_name, "spanner")
109+
self.assertEqual(modules[0].version, "1.0.0")
110+
84111

85112
if __name__ == "__main__":
86113
unittest.main()

.github/workflows/ci.yaml

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,11 @@ jobs:
3434
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
3535
id: filter
3636
with:
37-
# we want to run tests if source code is changed or the scripts
38-
# used to run the unit tests
3937
filters: |
4038
src:
41-
- '**/*.java'
42-
- '**/pom.xml'
43-
- '!java-bigquery/**'
44-
- '!java-bigquerystorage/**'
45-
- '!java-datastore/**'
46-
- '!java-logging-logback/**'
47-
- '!java-logging/**'
48-
- '!java-spanner/**'
49-
- '!java-storage/**'
50-
- '!google-auth-library-java/**'
39+
- '!(java-bigquery|java-bigquerystorage|java-datastore|java-logging-logback|java-logging|java-spanner|java-storage|google-auth-library-java)/**/*.java'
40+
- '!(java-bigquery|java-bigquerystorage|java-datastore|java-logging-logback|java-logging|java-spanner|java-storage|google-auth-library-java)/**/pom.xml'
41+
- 'pom.xml'
5142
ci:
5243
- '.github/workflows/ci.yaml'
5344
- '.kokoro/**'
@@ -246,6 +237,37 @@ jobs:
246237
JOB_TYPE: test
247238
JOB_NAME: units-8-runtime-${{matrix.java}}
248239
working-directory: ${{matrix.package}}
240+
split-clirr:
241+
runs-on: ubuntu-latest
242+
needs: changes
243+
strategy:
244+
matrix:
245+
package: ${{ fromJSON(needs.changes.outputs.packages) }}
246+
steps:
247+
- name: Get current week within the year
248+
id: date
249+
run: echo "::set-output name=week_of_year::$(date +'%W' --utc)"
250+
- uses: actions/checkout@v4
251+
- uses: actions/setup-java@v4
252+
with:
253+
distribution: temurin
254+
java-version: 11
255+
- run: .kokoro/build.sh
256+
env:
257+
BUILD_SUBDIR: ${{matrix.package}}
258+
JOB_TYPE: clirr
259+
JOB_NAME: clirr-${{matrix.package}}
260+
required:
261+
needs: [ changes, split-units, split-clirr ]
262+
name: conditional-required-check
263+
if: ${{ always() }} # Always run even if any "needs" jobs fail
264+
runs-on: ubuntu-22.04
265+
steps:
266+
- name: Fail if any previous failure
267+
if: ${{ needs.changes.outputs.packages != '[]' && contains(needs.*.result, 'failure') }}
268+
run: exit 1
269+
- name: Success otherwise
270+
run: echo "Success!"
249271
windows:
250272
runs-on: windows-latest
251273
steps:
@@ -332,30 +354,3 @@ jobs:
332354
env:
333355
library_generation_image_tag: 2.68.0
334356
workspace_name: /workspace
335-
336-
# TODO: Uncomment the needed Github Actions
337-
# dependencies:
338-
# runs-on: ubuntu-latest
339-
# strategy:
340-
# matrix:
341-
# java: [8, 11, 17]
342-
# steps:
343-
# - uses: actions/checkout@v3
344-
# - uses: actions/setup-java@v3
345-
# with:
346-
# distribution: zulu
347-
# java-version: ${{matrix.java}}
348-
# - run: java -version
349-
# - run: .kokoro/dependencies.sh
350-
# clirr:
351-
# runs-on: ubuntu-latest
352-
# steps:
353-
# - uses: actions/checkout@v3
354-
# - uses: actions/setup-java@v3
355-
# with:
356-
# distribution: zulu
357-
# java-version: 8
358-
# - run: java -version
359-
# - run: .kokoro/build.sh
360-
# env:
361-
# JOB_TYPE: clirr

.github/workflows/google-auth-library-java-ci.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
filters: |
3535
library:
3636
- 'google-auth-library-java/**'
37+
- '.github/workflows/google-auth-library-java-ci.yaml'
3738
units-logging:
3839
needs: filter
3940
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -54,3 +55,30 @@ jobs:
5455
BUILD_SUBDIR: google-auth-library-java
5556
JOB_TYPE: test
5657
SUREFIRE_JVM_OPT: "-P '!slf4j2x,slf4j2x-test'"
58+
clirr:
59+
needs: filter
60+
if: ${{ needs.filter.outputs.library == 'true' }}
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v3
64+
- uses: actions/setup-java@v3
65+
with:
66+
distribution: temurin
67+
java-version: 11
68+
- run: java -version
69+
- run: .kokoro/build.sh
70+
env:
71+
JOB_TYPE: clirr
72+
BUILD_SUBDIR: google-auth-library-java
73+
74+
required:
75+
needs: [ units-logging, clirr ]
76+
name: conditional-required-check
77+
if: ${{ always() }} # Always run even if any "needs" jobs fail
78+
runs-on: ubuntu-22.04
79+
steps:
80+
- name: Fail if any previous failure
81+
if: ${{ contains(needs.*.result, 'failure') }}
82+
run: exit 1
83+
- name: Success otherwise
84+
run: echo "Success!"

.github/workflows/sdk-platform-java-verify_library_generation.yaml renamed to .github/workflows/hermetic-build-scripts-ci.yaml

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
on:
22
pull_request:
33

4-
name: sdk-platform-java verify_library_generation
5-
env:
6-
BUILD_SUBDIR: sdk-platform-java
4+
name: hermetic build scripts
75
jobs:
86
filter:
97
runs-on: ubuntu-latest
@@ -16,48 +14,14 @@ jobs:
1614
with:
1715
filters: |
1816
library:
19-
- 'sdk-platform-java/**'
20-
should-run-library-generation-tests:
21-
needs: filter
22-
if: ${{ needs.filter.outputs.library == 'true' }}
23-
runs-on: ubuntu-22.04
24-
outputs:
25-
should_run: ${{ steps.get_changed_directories.outputs.should_run }}
26-
steps:
27-
- uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 0
30-
- name: get changed directories in the pull request
31-
id: get_changed_directories
32-
shell: bash
33-
run: |
34-
set -ex
35-
# PRs that come from a fork need to be handled differently
36-
if [[ ${head_repo_name} == ${base_repo} ]]; then
37-
git checkout ${base_ref}
38-
git checkout ${head_ref}
39-
changed_directories="$(git diff --name-only ${base_ref} ${head_ref})"
40-
else
41-
git remote add fork ${head_repo_url}
42-
git fetch fork # create a mapping of the fork
43-
git checkout -b "${head_ref}" fork/${head_ref}
44-
changed_directories="$(git diff --name-only "fork/${head_ref}" "origin/${base_ref}")"
45-
fi
46-
if [[ ${changed_directories} =~ "sdk-platform-java/hermetic_build/" ]] || [[ ${changed_directories} =~ "sdk-platform-java/.cloudbuild/library_generation/" ]]; then
47-
echo "should_run=true" >> $GITHUB_OUTPUT
48-
else
49-
echo "should_run=false" >> $GITHUB_OUTPUT
50-
fi
51-
env:
52-
base_ref: ${{ github.event.pull_request.base.ref }}
53-
head_ref: ${{ github.event.pull_request.head.ref }}
54-
head_repo_url: ${{ github.event.pull_request.head.repo.html_url }}
55-
head_repo_name: ${{ github.event.pull_request.head.repo.full_name }}
56-
base_repo: ${{ github.repository }}
17+
- 'sdk-platform-java/hermetic_build/**'
18+
- 'sdk-platform-java/.cloudbuild/library_generation/**'
19+
- '.github/workflows/hermetic-build-scripts-ci.yaml'
5720
library-generation-unit-tests:
58-
needs: [filter, should-run-library-generation-tests]
59-
if: needs.filter.outputs.library == 'true' && needs.should-run-library-generation-tests.outputs.should_run == 'true'
21+
needs: filter
22+
if: needs.filter.outputs.library == 'true'
6023
runs-on: ubuntu-22.04
24+
name: hermetic build units (python)
6125
defaults:
6226
run:
6327
working-directory: sdk-platform-java
@@ -86,9 +50,10 @@ jobs:
8650
set -x
8751
python -m unittest discover -s hermetic_build -p "*unit_tests.py"
8852
library-generation-lint-shell:
89-
needs: [filter, should-run-library-generation-tests]
90-
if: needs.filter.outputs.library == 'true' && needs.should-run-library-generation-tests.outputs.should_run == 'true'
53+
needs: filter
54+
if: needs.filter.outputs.library == 'true'
9155
runs-on: ubuntu-22.04
56+
name: hermetic build lint (shell)
9257
defaults:
9358
run:
9459
working-directory: sdk-platform-java
@@ -103,9 +68,10 @@ jobs:
10368
ignore_paths:
10469
.kokoro
10570
library-generation-lint-python:
106-
needs: [filter, should-run-library-generation-tests]
107-
if: needs.filter.outputs.library == 'true' && needs.should-run-library-generation-tests.outputs.should_run == 'true'
71+
needs: filter
72+
if: needs.filter.outputs.library == 'true'
10873
runs-on: ubuntu-22.04
74+
name: hermetic build lint (python)
10975
defaults:
11076
run:
11177
working-directory: sdk-platform-java
@@ -131,3 +97,14 @@ jobs:
13197
# exclude generated golden files
13298
# exclude owlbot until further refaction
13399
black --check hermetic_build --exclude "(library_generation/tests/resources/goldens)"
100+
required:
101+
needs: [ library-generation-unit-tests, library-generation-lint-shell, library-generation-lint-python ]
102+
name: conditional-required-check
103+
if: ${{ always() }} # Always run even if any "needs" jobs fail
104+
runs-on: ubuntu-22.04
105+
steps:
106+
- name: Fail if any previous failure
107+
if: ${{ contains(needs.*.result, 'failure') }}
108+
run: exit 1
109+
- name: Success otherwise
110+
run: echo "Success!"

.github/workflows/hermetic_library_generation.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ jobs:
4747
head_ref: ${{ github.head_ref }}
4848
token: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
4949
force_regenerate_all: ${{ github.event.pull_request.head.ref == 'generate-libraries-main' }}
50+
showcase_mode: true
5051
image_tag: ${{ env.GENERATOR_VERSION }}

.github/workflows/java-spanner-jdbc-ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
filters: |
3535
library:
3636
- 'java-spanner-jdbc/**'
37+
- '.github/workflows/java-spanner-jdbc-ci.yaml'
3738
units:
3839
needs: filter
3940
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -141,3 +142,14 @@ jobs:
141142
JOB_TYPE: lint
142143
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
143144
BASE_SHA: ${{ github.event.pull_request.base.sha }}
145+
required:
146+
needs: [ units, units-java8, windows, dependencies, javadoc, lint ]
147+
name: conditional-required-check
148+
if: ${{ always() }} # Always run even if any "needs" jobs fail
149+
runs-on: ubuntu-22.04
150+
steps:
151+
- name: Fail if any previous failure
152+
if: ${{ contains(needs.*.result, 'failure') }}
153+
run: exit 1
154+
- name: Success otherwise
155+
run: echo "Success!"

.github/workflows/java-storage-nio-ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
filters: |
3535
library:
3636
- 'java-storage-nio/**'
37+
- '.github/workflows/java-storage-nio-ci.yaml'
3738
units:
3839
needs: filter
3940
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -141,3 +142,14 @@ jobs:
141142
JOB_TYPE: lint
142143
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
143144
BASE_SHA: ${{ github.event.pull_request.base.sha }}
145+
required:
146+
needs: [ units, units-java8, windows, dependencies, javadoc, lint ]
147+
name: conditional-required-check
148+
if: ${{ always() }} # Always run even if any "needs" jobs fail
149+
runs-on: ubuntu-22.04
150+
steps:
151+
- name: Fail if any previous failure
152+
if: ${{ contains(needs.*.result, 'failure') }}
153+
run: exit 1
154+
- name: Success otherwise
155+
run: echo "Success!"

0 commit comments

Comments
 (0)