-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2030s-checkstyle.yml
55 lines (48 loc) · 1.59 KB
/
2030s-checkstyle.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
51
52
53
54
55
name: 2030s-checkstyle
on: [push, pull_request]
jobs:
save-2-marks:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache binary and config
id: cache-stuffs
uses: actions/cache@v3
with:
path: |
checkstyle.jar
checks.xml
key: 'idt_i_gotta_change_this'
- name: Get checkstyle 8.39
if: steps.cache-stuffs.outputs.cache-hit != 'true'
run: |
wget https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.39/checkstyle-8.39-all.jar --output-document=checkstyle.jar
- name: Get CS2030S checkstyle config
if: steps.cache-stuffs.outputs.cache-hit != 'true'
run: |
wget https://raw.githubusercontent.com/kokrui-at-nus/CS2030S/main/checks.xml --output-document=checks.xml
- name: List changed files
id: changed-files
uses: tj-actions/changed-files@v32
- name: Checkstyle changed non-test files
run: |
flg=0
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $file == *"Test"* || $file != *".java" ]]; then
echo "Skipping $file"
else
java -jar checkstyle.jar $file -c checks.xml > out
cat out
if grep -Fq "[WARN]" out
then
flg=1
fi
fi
done
if [ "$flg" -eq "1" ]; then
exit 1
fi