Skip to content

Commit df57a56

Browse files
authored
Merge branch 'main' into partial-release-script
2 parents 0dd0fd6 + 3d65c78 commit df57a56

211 files changed

Lines changed: 5245 additions & 583 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
ci: ${{ steps.filter.outputs.ci }}
3232
steps:
3333
- uses: actions/checkout@v4
34-
- uses: dorny/paths-filter@v3
34+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
3535
id: filter
3636
with:
3737
# we want to run tests if source code is changed or the scripts
@@ -121,7 +121,7 @@ jobs:
121121
outputs:
122122
packages: ${{ steps.filter.outputs.changes }}
123123
steps:
124-
- uses: dorny/paths-filter@v4
124+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
125125
id: filter
126126
with:
127127
# For each library, run CI in split repos where there are changes in:

.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/google-auth-library-java-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
library: ${{ steps.filter.outputs.library }}
2929
steps:
3030
- uses: actions/checkout@v4
31-
- uses: dorny/paths-filter@v3
31+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
3232
id: filter
3333
with:
3434
filters: |

.github/workflows/java-bigquery-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
library: ${{ steps.filter.outputs.library }}
2727
steps:
2828
- uses: actions/checkout@v4
29-
- uses: dorny/paths-filter@v3
29+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
3030
id: filter
3131
with:
3232
filters: |

.github/workflows/java-spanner-integration-tests-against-emulator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
library: ${{ steps.filter.outputs.library }}
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: dorny/paths-filter@v3
14+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
1515
id: filter
1616
with:
1717
filters: |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
library: ${{ steps.filter.outputs.library }}
2929
steps:
3030
- uses: actions/checkout@v4
31-
- uses: dorny/paths-filter@v3
31+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
3232
id: filter
3333
with:
3434
filters: |

.github/workflows/java-spanner-jdbc-integration-tests-against-emulator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
library: ${{ steps.filter.outputs.library }}
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: dorny/paths-filter@v3
16+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
1717
id: filter
1818
with:
1919
filters: |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
library: ${{ steps.filter.outputs.library }}
2626
steps:
2727
- uses: actions/checkout@v4
28-
- uses: dorny/paths-filter@v3
28+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
2929
id: filter
3030
with:
3131
filters: |

.github/workflows/java-spanner-jdbc-sample-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
library: ${{ steps.filter.outputs.library }}
2626
steps:
2727
- uses: actions/checkout@v4
28-
- uses: dorny/paths-filter@v3
28+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
2929
id: filter
3030
with:
3131
filters: |

0 commit comments

Comments
 (0)