Skip to content

Commit 7bacd23

Browse files
committed
fix:code check root pom
1 parent f662105 commit 7bacd23

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

.github/workflows/checkstyle.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
9393
# 如果检查失败,仍然上传报告供查看
9494
- name: Upload Checkstyle report
95-
if: always() # 即使失败也上传报告
95+
if: ${{ always() && hashFiles('**/target/checkstyle-result.xml', '**/target/checkstyle-checker.xml', '**/target/reports/**') != '' }}
9696
uses: actions/upload-artifact@v7
9797
with:
9898
name: checkstyle-report
@@ -103,7 +103,7 @@ jobs:
103103
if-no-files-found: warn
104104

105105
- name: Upload PMD report
106-
if: always()
106+
if: ${{ always() && hashFiles('target/pmd-report.xml', 'target/pmd-report.html') != '' }}
107107
uses: actions/upload-artifact@v7
108108
with:
109109
name: pmd-report
@@ -113,7 +113,7 @@ jobs:
113113
if-no-files-found: warn
114114

115115
- name: Upload SpotBugs report
116-
if: always()
116+
if: ${{ always() && hashFiles('**/target/spotbugsXml.xml', '**/target/spotbugs-reports/**') != '' }}
117117
uses: actions/upload-artifact@v7
118118
with:
119119
name: spotbugs-report
@@ -122,4 +122,3 @@ jobs:
122122
**/target/spotbugs*.html
123123
**/target/spotbugs-reports/
124124
if-no-files-found: warn
125-

.github/workflows/pmd.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,26 @@ jobs:
9999
100100

101101
- name: Install sarif-tools and convert to HTML
102+
if: ${{ always() && hashFiles('pmd-report.sarif') != '' }}
102103
run: |
103104
pip install sarif-tools
104105
sarif html pmd-report.sarif --output pmd-report.html
105106
106107
- name: Upload SARIF file
108+
if: ${{ always() && hashFiles('pmd-report.sarif') != '' }}
107109
uses: github/codeql-action/upload-sarif@v4
108110
with:
109111
sarif_file: pmd-report.sarif
110112

111113
- name: Upload SARIF file as artifact
114+
if: ${{ always() && hashFiles('pmd-report.sarif') != '' }}
112115
uses: actions/upload-artifact@v7
113116
with:
114117
name: pmd-sarif-report # 给工件起一个有意义的名字
115118
path: pmd-report.sarif
116119

117120
- name: Upload HTML report
121+
if: ${{ always() && hashFiles('pmd-report.html') != '' }}
118122
uses: actions/upload-artifact@v7
119123
with:
120124
name: pmd-html-report
@@ -128,4 +132,4 @@ jobs:
128132
else
129133
echo "❌ PMD 发现 ${{ steps.pmd.outputs.violations }} 个代码问题,构建失败。"
130134
exit 1
131-
fi
135+
fi

pom.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<langchain4j-rag.version>1.5.0-beta11</langchain4j-rag.version>
4141
<bcprov-jdk18on.version>1.79</bcprov-jdk18on.version>
4242
<tiny-engine.version>1.0-SNAPSHOT</tiny-engine.version>
43+
<checkstyle.failOnViolation>false</checkstyle.failOnViolation>
4344
</properties>
4445
<dependencies>
4546
<dependency>
@@ -244,8 +245,8 @@
244245
<!-- java编码规范的配置文件 -->
245246
<!--suppress UnresolvedMavenProperty -->
246247
<configLocation>${maven.multiModuleProjectDirectory}/checkstyle/code-check-checkstyle.xml</configLocation>
247-
<!-- 检查失败时构建失败(阻止CI通过) -->
248-
<failOnViolation>true</failOnViolation>
248+
<!-- Default is non-blocking; enable via profile or -Dcheckstyle.failOnViolation=true -->
249+
<failOnViolation>${checkstyle.failOnViolation}</failOnViolation>
249250
<violationSeverity>warning</violationSeverity>
250251
<!-- 输出格式 -->
251252
<outputFileFormat>xml</outputFileFormat>
@@ -336,4 +337,13 @@
336337

337338
</plugins>
338339
</build>
340+
341+
<profiles>
342+
<profile>
343+
<id>checkstyle-enforce</id>
344+
<properties>
345+
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
346+
</properties>
347+
</profile>
348+
</profiles>
339349
</project>

0 commit comments

Comments
 (0)