Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/actions/format/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Format Java Code'
description: 'Runs mvn spotless:apply'
inputs:
path:
description: 'Path to the java repository'
required: true
runs:
using: 'composite'
steps:
- name: Set up JDK 20 for formatting
uses: actions/setup-java@v4
with:
java-version: '20'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The project's pom.xml specifies Java 11 as the source and target version, but this action is setting up JDK 20. It's best practice to use the same Java version for formatting as the project itself to ensure consistency and avoid potential incompatibilities.

        java-version: '11'

distribution: 'adopt'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The adopt distribution for setup-java is deprecated and will be removed in a future version. It is recommended to use temurin instead to ensure future compatibility.

        distribution: 'temurin'


- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's more precise and a common practice to cache the ~/.m2/repository directory instead of the whole ~/.m2 directory. This avoids caching logs and other non-repository files.

        path: ~/.m2/repository

key: ${{ runner.os }}-m2-${{ hashFiles(format('{0}/**/pom.xml', inputs.path)) }}
restore-keys: |
${{ runner.os }}-m2-

- name: Run Spotless Apply
run: mvn spotless:apply
shell: bash
working-directory: ${{ inputs.path }}
Loading