Skip to content

Commit 6e0b04d

Browse files
authored
Merge branch 'main' into datastore-csm-impl-2
2 parents 7418242 + 8095342 commit 6e0b04d

2,915 files changed

Lines changed: 164184 additions & 12362 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.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
name: java-development
3+
description: General guidance on Java development practices, building, testing, and style in the monorepo. Use this skill when working on Java code across the repository.
4+
---
5+
6+
# Java Development Guide
7+
8+
This skill provides general guidelines for Java development inside the monorepo. It covers building, formatting, testing, and style conventions to ensure consistency across modules.
9+
10+
## Workflow
11+
12+
### 1. Building the Project
13+
14+
The repository uses Maven as its primary build system.
15+
16+
* **Build All Modules**: To build all modules from the root of the repository, run:
17+
```bash
18+
mvn install -T 1C -P quick-build
19+
```
20+
> [!TIP]
21+
> Use `-T 1C` to build modules in parallel (one thread per CPU core) and `-P quick-build` to skip unnecessary plugins for faster builds.
22+
* **Build a Specific Module**: You can also run Maven commands within a specific module directory (e.g., `java-bigquery`) to build only that module.
23+
24+
### 2. Code Formatting
25+
26+
Code formatting is enforced using the `fmt-maven-plugin`.
27+
28+
* **Check Formatting**: To check for formatting issues without modifying files, run:
29+
```bash
30+
mvn fmt:check -T 1C
31+
```
32+
* **Apply Formatting**: To automatically format the code according to the project style, run:
33+
```bash
34+
mvn fmt:format -T 1C
35+
```
36+
> [!TIP]
37+
> To save time, run `mvn fmt:format` within the specific module directory you are working on, rather than at the root.
38+
> [!NOTE]
39+
> Always run `mvn fmt:format` before committing changes to avoid build failures due to formatting.
40+
41+
### 3. Testing Strategy
42+
43+
* **Unit Tests**: Traditional unit tests should be added for individual classes and methods. Run them using:
44+
```bash
45+
mvn test -T 1C
46+
```
47+
* **Integration Tests**: Many modules have integration tests that run against live services or emulators. These may require specific profiles or environment variables. Refer to the specific module's README for details.
48+
49+
### 4. Style Guide
50+
51+
Follow these general rules to maintain code quality and consistency:
52+
53+
1. **Minimize Visibility**: Default to the most restrictive access level possible. Avoid using `public` unless the class or method is intended to be part of the public API.
54+
2. Avoid Fully Qualified Names: Use imports to keep class names short and readable, rather than using fully qualified names in the code.
55+
3. **Avoid Obsolete APIs**: Do not call methods marked with `@ObsoleteApi` or `@Deprecated` unless there are no viable alternatives.
56+
4. **Clean Diffs**: Avoid unnecessary formatting changes or whitespace modifications to keep diffs clean and easy to review.
57+
58+
### 5. Dependency Management
59+
60+
* **Version Bumps**: Try not to bump any external dependency versions unless there is a known security vulnerability (CVE) or a critical bug fix.
61+
* **New Dependencies**: Avoid introducing new external dependencies. If a new dependency is required, provide a strong justification in the pull request.
62+
* **Standard Library First**: Prefer to use features from the Java standard library, followed by existing dependencies in the project (preferably Google-managed dependencies).
63+
64+
### 6. Contribution Guidelines
65+
66+
* **Commit Messages**: Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification. Include the module as the scope (e.g., `feat(spanner): ...`, `fix(bigquery): ...`).
67+
* **Pull Requests**: All code changes must be submitted via a pull request and require review. Ensure you pull the latest changes from `main` and resolve any conflicts before submitting.

.github/workflows/ci.yaml

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ jobs:
4040
src:
4141
- '**/*.java'
4242
- '**/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/**'
4351
ci:
4452
- '.github/workflows/ci.yaml'
4553
- '.kokoro/**'
@@ -116,15 +124,55 @@ jobs:
116124
- uses: dorny/paths-filter@v4
117125
id: filter
118126
with:
127+
# For each library, run CI in split repos where there are changes in:
128+
# 1. Changes inside the split repo's module
129+
# 2. Java code changes in upstream modules: Auth Library and Sdk-Platform-Java
130+
# 3. Upstream dependency version changes: Shared-Deps and Gapic-Generator-Pom-Parent
119131
filters: |
120-
java-bigquery: java-bigquery/**
121-
java-bigquerystorage: java-bigquerystorage/**
122-
java-datastore: java-datastore/**
123-
java-logging-logback: java-logging-logback/**
124-
java-logging: java-logging/**
125-
java-spanner: java-spanner/**
126-
java-storage: java-storage/**
127-
sdk-platform-java: sdk-platform-java/**
132+
google-auth-library-java:
133+
- 'google-auth-library-java/**'
134+
java-bigquery:
135+
- 'java-bigquery/**'
136+
- 'google-auth-library-java/**/*.java'
137+
- 'sdk-platform-java/**/*.java'
138+
- 'sdk-platform-java/java-shared-dependencies/**/pom.xml'
139+
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
140+
java-bigquerystorage:
141+
- 'java-bigquerystorage/**'
142+
- 'google-auth-library-java/**/*.java'
143+
- 'sdk-platform-java/**/*.java'
144+
- 'sdk-platform-java/java-shared-dependencies/**/pom.xml'
145+
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
146+
java-datastore:
147+
- 'java-datastore/**'
148+
- 'google-auth-library-java/**/*.java'
149+
- 'sdk-platform-java/**/*.java'
150+
- 'sdk-platform-java/java-shared-dependencies/**/pom.xml'
151+
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
152+
java-logging-logback:
153+
- 'java-logging-logback/**'
154+
- 'google-auth-library-java/**/*.java'
155+
- 'sdk-platform-java/**/*.java'
156+
- 'sdk-platform-java/java-shared-dependencies/**/pom.xml'
157+
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
158+
java-logging:
159+
- 'java-logging/**'
160+
- 'google-auth-library-java/**/*.java'
161+
- 'sdk-platform-java/**/*.java'
162+
- 'sdk-platform-java/java-shared-dependencies/**/pom.xml'
163+
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
164+
java-spanner:
165+
- 'java-spanner/**'
166+
- 'google-auth-library-java/**/*.java'
167+
- 'sdk-platform-java/**/*.java'
168+
- 'sdk-platform-java/java-shared-dependencies/**/pom.xml'
169+
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
170+
java-storage:
171+
- 'java-storage/**'
172+
- 'google-auth-library-java/**/*.java'
173+
- 'sdk-platform-java/**/*.java'
174+
- 'sdk-platform-java/java-shared-dependencies/**/pom.xml'
175+
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
128176
split-units:
129177
runs-on: ubuntu-latest
130178
needs: changes

.github/workflows/sdk-platform-java-create_additional_release_tag.yaml renamed to .github/workflows/create_additional_release_tag.yaml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
name: sdk-platform-java Create additional tags for each release
1+
name: Create additional tags for each release
22

33
on:
44
release:
55
types: [published]
66
workflow_dispatch:
7-
8-
env:
9-
BUILD_SUBDIR: sdk-platform-java
107
jobs:
11-
filter:
12-
runs-on: ubuntu-latest
13-
outputs:
14-
library: ${{ steps.filter.outputs.library }}
15-
steps:
16-
- uses: actions/checkout@v4
17-
- uses: dorny/paths-filter@v3
18-
id: filter
19-
with:
20-
filters: |
21-
library:
22-
- 'sdk-platform-java/**'
238
build:
24-
needs: filter
25-
if: ${{ needs.filter.outputs.library == 'true' }}
269
runs-on: ubuntu-latest
2710
permissions:
2811
# Permission to create tag
@@ -32,7 +15,7 @@ jobs:
3215
- name: Checkout code
3316
uses: actions/checkout@v4
3417
with:
35-
token: ${{ secrets.GITHUB_TOKEN }}
18+
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
3619
- name: Set up Git
3720
run: |
3821
git config --local user.email "action@github.com"

.github/workflows/generated_files_sync.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
pull_request:
1818
name: generation diff
1919
env:
20-
library_generation_image_tag: 2.70.0 # {x-version-update:gapic-generator-java:current}
20+
library_generation_image_tag: 2.71.0 # {x-version-update:gapic-generator-java:current}
2121
jobs:
2222
root-pom:
2323
# root pom.xml does not have diff from generated one

.github/workflows/hermetic_library_generation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ jobs:
4444
head_ref: ${{ github.head_ref }}
4545
token: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
4646
force_regenerate_all: ${{ github.event.pull_request.head.ref == 'generate-libraries-main' }}
47-
image_tag: 2.70.0 # {x-version-update:gapic-generator-java:current}
47+
image_tag: 2.71.0 # {x-version-update:gapic-generator-java:current}

.github/workflows/sdk-platform-java-ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
filters: |
1818
library:
1919
- 'sdk-platform-java/**'
20+
- 'google-auth-library-java/**'
21+
- '.github/workflows/ci.yaml'
2022
build:
2123
needs: filter
2224
if: ${{ needs.filter.outputs.library == 'true' }}

.github/workflows/sdk-platform-java-downstream.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
filters: |
2424
library:
2525
- 'sdk-platform-java/**'
26+
- .kokoro/downstream-compatibility.sh
2627
downstream-compatibility:
2728
needs: filter
2829
if: ${{ needs.filter.outputs.library == 'true' }}

.github/workflows/sdk-platform-java-downstream_unmanaged_dependency_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
repo:
3434
- java-bigtable
3535
- java-firestore
36-
- java-logging
36+
- java-pubsub
3737
steps:
3838
- name: Checkout sdk-platform-java
3939
uses: actions/checkout@v3

.github/workflows/unmanaged_dependency_check.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ jobs:
1010
with:
1111
distribution: temurin
1212
java-version: 11
13-
- name: Install modules
13+
- name: Install all modules first
1414
shell: bash
15-
run: mvn install -B -ntp -T 1C -DskipTests -Pquick-build
15+
run: .kokoro/build.sh
16+
env:
17+
BUILD_SUBDIR: sdk-platform-java
18+
JOB_TYPE: install
1619
- name: Unmanaged dependency check
1720
uses: ./sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check
1821
with:

.kokoro/downstream-compatibility.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
2727
cd "${scriptDir}/.." # cd to the root of this repo
2828
source "$scriptDir/common.sh"
2929

30-
setup_maven_mirror
31-
3230
install_modules "sdk-platform-java"
3331
cd sdk-platform-java
3432

@@ -42,6 +40,9 @@ for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
4240
git clone "https://github.com/googleapis/$repo.git" --depth=1 --branch "v$last_release"
4341
update_all_poms_dependency "$repo" google-cloud-shared-dependencies "$SHARED_DEPS_VERSION"
4442
pushd "$repo"
43+
echo "Diff to run the test with modified dependencies:"
44+
git --no-pager diff
45+
echo "---------------"
4546
JOB_TYPE="test" ./.kokoro/build.sh
4647
popd
4748
done

0 commit comments

Comments
 (0)