Skip to content

Commit 23ce3db

Browse files
committed
Add a CI Check that fails if Spotless does not pass, to enforce project style guidelines.
I will also show how to fix things running ./gradlew spotlessApply Signed-off-by: Alfredo Gutierrez <[email protected]>
1 parent 207993b commit 23ce3db

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/spotless-check.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Spotless Check
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
spotless:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Harden Runner
11+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
12+
with:
13+
egress-policy: audit
14+
15+
- name: Checkout code
16+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up JDK 21
21+
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
22+
with:
23+
distribution: 'temurin'
24+
java-version: '21'
25+
26+
- name: Cache Gradle packages
27+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
28+
with:
29+
path: |
30+
~/.gradle/caches
31+
~/.gradle/wrapper
32+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
33+
restore-keys: |
34+
${{ runner.os }}-gradle-
35+
36+
- name: Run Spotless Check
37+
run: |
38+
./gradlew spotlessCheck
39+
if [ $? -ne 0 ]; then
40+
echo "Spotless found formatting issues. Please run './gradlew spotlessApply' to fix them."
41+
exit 1
42+
fi
43+
continue-on-error: false

0 commit comments

Comments
 (0)