ci: set up Spotless linting in CI (#351)#366
ci: set up Spotless linting in CI (#351)#366KaleabArgaw wants to merge 1 commit intodocling-project:mainfrom
Conversation
|
Thanks @KaleabArgaw for this! I'll give it a look through later today or tomorrow! I am going to have copilot do an automated review of it too, but please don't take any actions yet based on what it says. I'm really just testing it out to see if I trust it or not :) |
|
@all-contributors add @KaleabArgaw for code documentation |
|
I've put up a pull request to add @KaleabArgaw! 🎉 |
There was a problem hiding this comment.
Pull request overview
This PR integrates Spotless code linting into the CI pipeline to enforce consistent code formatting across the Java codebase. The implementation uses an incremental rollout strategy via ratchetFrom("origin/main"), which checks only files changed from the main branch. This allows for gradual adoption without requiring all existing code to be reformatted immediately.
Changes:
- Adds Spotless Gradle plugin (version 7.2.1) to the project dependencies
- Configures Spotless in the shared Java convention plugin with basic formatting rules (remove unused imports, format annotations, trim trailing whitespace, end with newline)
- Adds a new
lintCI job that runs Spotless formatting checks on all pull requests - Updates CONTRIBUTING.md with instructions for running Spotless locally
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| gradle/libs.versions.toml | Adds Spotless version (7.2.1) and plugin dependency declaration to the version catalog |
| buildSrc/build.gradle.kts | Adds Spotless Gradle plugin as a buildSrc dependency, making it available to convention plugins |
| buildSrc/src/main/kotlin/docling-java-shared.gradle.kts | Applies Spotless plugin and configures it with ratchetFrom strategy and basic Java formatting rules |
| .github/workflows/build.yml | Adds new lint job that checks out code with full history (fetch-depth: 0), runs spotlessApply, and verifies no formatting changes are needed |
| CONTRIBUTING.md | Documents new Spotless commands (spotlessCheck and spotlessApply) for contributors |
:java_duke: JaCoCo coverage report
|
|
||||||||||||||
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
f41a996 to
0169818
Compare
edeandrea
left a comment
There was a problem hiding this comment.
See comments in-line.
I'd also like @ThomasVitale to take a look.
|
|
||
| spotless { | ||
| // Roll out linting incrementally by checking only files changed from main. | ||
| ratchetFrom("origin/main") |
There was a problem hiding this comment.
This is causing a build failure in the docs module that needs to be investigated.
| trimTrailingWhitespace() | ||
| endWithNewline() | ||
| } | ||
| } |
There was a problem hiding this comment.
I haven't read up on spotless and its configuration - is there a way to specify the configuration outside of the gradle dsl? And is there a way to get it to respect what we have in .editorconfig?
Ideally I'd prefer control over formatting/etc to be defined in a single place, whether thats .editorconfig or somewhere else. It would also be nice if when a user loads the project into an IDE, the formatting rules are respected by the IDE. Anything we can do to make that easier is a win.
There was a problem hiding this comment.
Yeah we can govern it using .editorconfig
There was a problem hiding this comment.
Does it use .editorconfig by default if you don't add any additional config for java?
I see in the documentation it works that way for kotlin (ktlint)
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
feb364e to
ad6b1db
Compare
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
Hi @KaleabArgaw thank you so much for this! I've just downloaded & built this PR locally and purposefully introduced some things that should break the spotless check. When I run |
ad6b1db to
67ee6e3
Compare
|
Hey @edeandrea i removed the on build fail that's why you can check now locally. |
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
Fixes #351