|
| 1 | +## |
| 2 | +# Copyright (C) 2024 Hedera Hashgraph, LLC |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +## |
| 16 | + |
| 17 | +name: Spotless Check |
| 18 | + |
| 19 | +on: [pull_request] |
| 20 | + |
| 21 | +jobs: |
| 22 | + spotless: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Harden Runner |
| 27 | + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 |
| 28 | + with: |
| 29 | + egress-policy: audit |
| 30 | + |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 33 | + with: |
| 34 | + fetch-depth: 0 |
| 35 | + |
| 36 | + - name: Expand Shallow Clone for Spotless |
| 37 | + run: | |
| 38 | + if [ -f .git/shallow ]; then |
| 39 | + git fetch --unshallow --no-recurse-submodules |
| 40 | + else |
| 41 | + echo "Repository is not shallow, no need to unshallow." |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Set up JDK 21 |
| 45 | + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 |
| 46 | + with: |
| 47 | + distribution: 'temurin' |
| 48 | + java-version: '21' |
| 49 | + |
| 50 | + - name: Cache Gradle packages |
| 51 | + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 |
| 52 | + with: |
| 53 | + path: | |
| 54 | + ~/.gradle/caches |
| 55 | + ~/.gradle/wrapper |
| 56 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 57 | + restore-keys: | |
| 58 | + ${{ runner.os }}-gradle- |
| 59 | +
|
| 60 | + - name: Run Spotless Check |
| 61 | + run: | |
| 62 | + ./gradlew spotlessCheck |
| 63 | + if [ $? -ne 0 ]; then |
| 64 | + echo "Spotless found formatting issues. Please run './gradlew spotlessApply' to fix them." |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + continue-on-error: false |
0 commit comments