forked from robolectric/robolectric
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (41 loc) · 1.56 KB
/
check_code_formatting.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Check Code Formatting
on:
push:
branches: [ master, 'robolectric-*.x' ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master, google ]
paths-ignore:
- '**.md'
permissions:
contents: read
jobs:
check_code_formatting:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
- uses: gradle/gradle-build-action@v2
- name: Download google-java-format 1.9
run: |
curl -L -o $HOME/google-java-format.jar https://github.com/google/google-java-format/releases/download/v1.15.0/google-java-format-1.15.0-all-deps.jar
curl -L -o $HOME/google-java-format-diff.py https://raw.githubusercontent.com/google/google-java-format/v1.15.0/scripts/google-java-format-diff.py
chmod +x $HOME/google-java-format-diff.py
- name: Check Java formatting
run: |
diff=$(git diff -U0 $(git merge-base HEAD origin/master) | $HOME/google-java-format-diff.py --google-java-format-jar=$HOME/google-java-format.jar -p1)
if [[ $diff ]]; then
echo "Please run google-java-format on the changes in this pull request"
git diff -U0 $(git merge-base HEAD origin/master) | $HOME/google-java-format-diff.py --google-java-format-jar=$HOME/google-java-format.jar -p1
exit 1
fi
- name: Check Kotlin formatting
run: |
./gradlew spotlessCheck