fix:code check plugin(Checkstyle +PMD+SpotBugs) #188
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Checkstyle Code Quality | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| pull_request: | |
| branches: | |
| - develop | |
| 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 }} | |
| # ==================== 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 }} | |
| # ==================== 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 }} | |
| # ==================== 调试:列出所有报告 ==================== | |
| - 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() # 即使失败也上传报告 | |
| 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() | |
| 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() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: spotbugs-report | |
| path: | | |
| **/target/spotbugsXml.xml | |
| **/target/spotbugs*.html | |
| **/target/spotbugs-reports/ | |
| if-no-files-found: warn | |