-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a CI Check that fails if Spotless does not pass, to enforce proje…
…ct style guidelines. I will also show how to fix things running ./gradlew spotlessApply Signed-off-by: Alfredo Gutierrez <[email protected]>
- Loading branch information
1 parent
207993b
commit 23ce3db
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Spotless Check | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
spotless: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
|
||
- name: Cache Gradle packages | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Run Spotless Check | ||
run: | | ||
./gradlew spotlessCheck | ||
if [ $? -ne 0 ]; then | ||
echo "Spotless found formatting issues. Please run './gradlew spotlessApply' to fix them." | ||
exit 1 | ||
fi | ||
continue-on-error: false |