forked from opentiny/tiny-engine-backend-java
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (115 loc) · 4.58 KB
/
Copy pathcheckstyle.yml
File metadata and controls
130 lines (115 loc) · 4.58 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Checkstyle Code Quality
on:
push:
branches:
- develop
pull_request:
branches:
- develop
permissions:
contents: read
jobs:
checkstyle:
runs-on: ubuntu-24.04
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # 必须拉取完整历史,才能比较分支差异
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
# 缓存 Maven 依赖,加速构建
- name: Cache Maven dependencies
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# 新增:安装所有模块到本地仓库,解决依赖解析
- name: Install project (for dependency resolution)
id: install
run: mvn install -DskipTests -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dpmd.skip=true -Dspotbugs.skip=true -Dcpd.skip=true
# 直接运行 Checkstyle 检查(不执行完整的 package)
- name: Run Checkstyle
id: checkstyle
run: bash .github/scripts/checkstyle-pr.sh
env:
GITHUB_BASE_REF: ${{ github.base_ref }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_SHA: ${{ github.sha }}
# ==================== PMD 增量扫描 ====================
- name: Run PMD (incremental)
if: ${{ always() && steps.install.outcome == 'success' }}
id: pmd
run: bash .github/scripts/pmd-pr.sh
env:
GITHUB_BASE_REF: ${{ github.base_ref }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_SHA: ${{ github.sha }}
# ==================== SpotBugs 增量扫描 ====================
- name: Run SpotBugs (incremental)
if: ${{ always() && steps.install.outcome == 'success' }}
id: spotbugs
run: bash .github/scripts/spotbugs-incremental.sh
env:
GITHUB_BASE_REF: ${{ github.base_ref }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_SHA: ${{ github.sha }}
# ==================== 调试:列出所有报告 ====================
- name: Debug - list all reports
if: always()
run: |
echo "当前工作目录: $(pwd)"
echo "=== 查找所有检查报告 ==="
find . -type f \( -name "checkstyle-result.xml" -o -name "pmd-report.xml" -o -name "pmd-report.html" -o -name "cpd.xml" -o -name "spotbugsXml.xml" -o -name "spotbugs*.xml" -o -name "spotbugs*.html" \)
- name: Debug - list all checkstyle reports
if: always()
run: |
echo "当前工作目录: $(pwd)"
echo "=== 列出所有 target 目录 ==="
find . -type d -name "target" -exec echo "目录: {}" \; -exec ls -la {}/ \;
echo "=== 查找 checkstyle 文件 ==="
find . -name "checkstyle*.xml" -o -name "checkstyle*.html" | while read f; do echo "找到: $f"; done
- name: Debug - Check HTML existence
if: always()
run: |
echo "Searching for checkstyle.html:"
find . -name "checkstyle.html" -type f
echo "Also check reports directory:"
ls -la base/target/reports/ || echo "base/target/reports not found"
# 如果检查失败,仍然上传报告供查看
- name: Upload Checkstyle report
if: ${{ always() && hashFiles('**/target/checkstyle-result.xml', '**/target/checkstyle-checker.xml', '**/target/reports/**') != '' }}
uses: actions/upload-artifact@v7
with:
name: checkstyle-report
path: |
**/target/checkstyle-result.xml
**/target/checkstyle-checker.xml
**/target/reports/
if-no-files-found: warn
- name: Upload PMD report
if: ${{ always() && hashFiles('target/pmd-report.xml', 'target/pmd-report.html') != '' }}
uses: actions/upload-artifact@v7
with:
name: pmd-report
path: |
target/pmd-report.xml
target/pmd-report.html
if-no-files-found: warn
- name: Upload SpotBugs report
if: ${{ always() && hashFiles('**/target/spotbugsXml.xml', '**/target/spotbugs-reports/**') != '' }}
uses: actions/upload-artifact@v7
with:
name: spotbugs-report
path: |
**/target/spotbugsXml.xml
**/target/spotbugs*.html
**/target/spotbugs-reports/
if-no-files-found: warn