-
-
Notifications
You must be signed in to change notification settings - Fork 86
chore: add spotless code style check #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,30 @@ jobs: | |
| - name: Compile | ||
| run: mvn -B clean compile -Dmaven.gitcommitid.skip=true | ||
|
|
||
| code-style-check: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK 8 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 8 | ||
| - name: Cache Maven packages | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.m2/repository | ||
| key: ${{ runner.os }}-maven-spotless-${{ hashFiles('**/pom.xml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-maven-spotless- | ||
| ${{ runner.os }}-maven- | ||
| - name: Code Style Check | ||
| run: mvn -B spotless:check -Dmaven.gitcommitid.skip=true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Check the separate compatibility-test reactor as well. The root Maven reactor does not include |
||
| - name: Code Style Check (compat-tests reactor) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] Please document why both Maven aggregation entry points must be handled. This repository has two independent Maven reactor entry points:
Because the root POM does not list Please add an Apollo Java-specific mvn -B spotless:apply -Dmaven.gitcommitid.skip=true
mvn -B -f apollo-compat-tests/pom.xml spotless:apply -Dmaven.gitcommitid.skip=true
mvn -B spotless:check -Dmaven.gitcommitid.skip=true
mvn -B -f apollo-compat-tests/pom.xml spotless:check -Dmaven.gitcommitid.skip=trueThe Apollo server contributing guide currently linked by the PR template only documents the root |
||
| run: mvn -B -f apollo-compat-tests/pom.xml spotless:check -Dmaven.gitcommitid.skip=true | ||
|
|
||
| unit-integration-pr: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,4 @@ target | |
| # git | ||
| *.orig | ||
| .flattened-pom.xml | ||
|
|
||
| config-cache/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Contributing to Apollo Java | ||
|
|
||
| Thanks for contributing to [apolloconfig/apollo-java](https://github.com/apolloconfig/apollo-java)! This | ||
| guide covers the project-specific steps needed before opening a pull request. The default branch of this | ||
| repository is `main`. | ||
|
|
||
| For general guidance on writing a good pull request description, see the | ||
| [Apollo server contributing guide](https://github.com/apolloconfig/apollo/blob/master/CONTRIBUTING.md) — note | ||
| that it documents the `apollo` (server) repository, so its build/format commands do not apply here. | ||
|
|
||
| ## Building and testing | ||
|
|
||
| ```bash | ||
| mvn clean test | ||
| ``` | ||
|
|
||
| ## Code style (Spotless) | ||
|
|
||
| This repository is split across **two independent Maven reactors**: | ||
|
|
||
| - the root [`pom.xml`](pom.xml), which aggregates the regular client modules | ||
| (`apollo-core`, `apollo-client`, `apollo-client-config-data`, `apollo-mockserver`, `apollo-openapi`, | ||
| `apollo-plugin`); | ||
| - [`apollo-compat-tests/pom.xml`](apollo-compat-tests/pom.xml), which separately aggregates the | ||
| compatibility-test modules (`apollo-api-compat-it`, `apollo-spring-compat-it`, | ||
| `apollo-spring-boot-compat-it`). | ||
|
|
||
| The root POM's `<modules>` list does **not** include `apollo-compat-tests`, so running Spotless from the | ||
| repository root never touches the compatibility-test modules, and vice versa. CI checks both reactors as | ||
| separate steps, so you must format and check **both** before pushing — running only the root command will | ||
| pass locally and still fail CI. | ||
|
|
||
| Format your code: | ||
|
|
||
| ```bash | ||
| mvn -B spotless:apply -Dmaven.gitcommitid.skip=true | ||
| mvn -B -f apollo-compat-tests/pom.xml spotless:apply -Dmaven.gitcommitid.skip=true | ||
| ``` | ||
|
|
||
| Verify formatting (this is what CI runs): | ||
|
|
||
| ```bash | ||
| mvn -B spotless:check -Dmaven.gitcommitid.skip=true | ||
| mvn -B -f apollo-compat-tests/pom.xml spotless:check -Dmaven.gitcommitid.skip=true | ||
| ``` | ||
|
|
||
| ## Updating the changelog | ||
|
|
||
| Update the [`CHANGES` log](CHANGES.md) to describe your change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Make this a real merge gate.
Apollo
masterrequirescode-style-checkin both Mergify queue rules and in branch protection. Apollo Java currently does neither, so this job may fail while the PR still satisfies the enforced merge conditions. Please addcheck-success = code-style-checkto both queue rules; a maintainer should also add this context to themainrequired status checks before merge.