-
Notifications
You must be signed in to change notification settings - Fork 13
ci: set up Spotless linting in CI (#351) #366
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: Spotless | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}" | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| spotless-check: | ||
| runs-on: ubuntu-latest | ||
| name: spotless-check | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Reclaim disk space | ||
| working-directory: .github/scripts | ||
| shell: bash | ||
| run: ./ci-reclaim-disk-space.sh | ||
|
|
||
| - name: Set up Java 17 | ||
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | ||
| with: | ||
| java-version: 17 | ||
| distribution: temurin | ||
|
|
||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2 | ||
|
|
||
| - name: Run Spotless check | ||
| run: | | ||
| if ! ./gradlew --no-daemon -Pjava.version=17 spotlessCheck; then | ||
| echo "::error title=Spotless check failed::Formatting violations were found." | ||
| echo "Fix options:" | ||
| echo " 1) Run: ./gradlew --no-daemon spotlessApply" | ||
| echo " 2) Ensure your IDE honors .editorconfig and reformat changed files" | ||
| echo "Then commit and push the updated files." | ||
| exit 1 | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ plugins { | |
| id("docling-shared") | ||
| `java-library` | ||
| `jacoco` | ||
| id("com.diffplug.spotless") | ||
| } | ||
|
|
||
| repositories { | ||
|
|
@@ -41,6 +42,19 @@ jacoco { | |
| toolVersion = libs.findVersion("jacoco").get().toString() | ||
| } | ||
|
|
||
| spotless { | ||
| lineEndings = com.diffplug.spotless.LineEnding.UNIX | ||
|
|
||
| java { | ||
| target("src/*/java/**/*.java") | ||
edeandrea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| target("src/*/java/module-info.java") | ||
| removeUnusedImports() | ||
| formatAnnotations() | ||
| trimTrailingWhitespace() | ||
| endWithNewline() | ||
| } | ||
| } | ||
|
Contributor
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. 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 Ideally I'd prefer control over formatting/etc to be defined in a single place, whether thats
Author
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. Yeah we can govern it using
Contributor
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. Does it use I see in the documentation it works that way for kotlin (ktlint) |
||
|
|
||
| tasks.withType<Test>().configureEach { | ||
| // Use JUnit Platform for unit tests. | ||
| useJUnitPlatform() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.