name: CodeChecker 变更检测 run-name: ${{ gitea.actor }}的CodeChecker变更检测 on: push: branches: - class-check workflow_dispatch: jobs: code-check: if: ${{ gitea.ref != 'refs/heads/pre' && gitea.ref != 'refs/heads/dev' && gitea.ref != 'refs/heads/master-2.0' }} runs-on: jdk11 steps: - name: 检出代码 run: | git config --global http.sslVerify false git clone "https://${{ gitea.token }}@git.niujiekeji.com/${{ gitea.repository }}.git" . git checkout ${{ gitea.sha }} - name: 检查配置文件与预编译 jar run: | if [ ! -f .gitea/config.yaml ]; then echo "错误: 缺少 .gitea/config.yaml" exit 1 fi if [ ! -f .gitea/workflows/code-checker.jar ]; then echo "错误: 缺少 .gitea/workflows/code-checker.jar" echo "请本地执行: powershell -File scripts/build-code-checker.ps1" exit 1 fi - name: 验证 JDK run: | echo "Java: $(java -version 2>&1 | head -1)" - name: 执行 CodeChecker 变更检测 run: | OLD_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "") if [ -z "$OLD_SHA" ]; then echo "首次提交,跳过变更检测" exit 0 fi COMMIT_TIME=$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S') java -jar .gitea/workflows/code-checker.jar \ --config .gitea/config.yaml \ --repo-root . \ --old-sha "$OLD_SHA" \ --new-sha "$(git rev-parse HEAD)" \ --modifier "${{ gitea.actor }}" \ --modify-time "$COMMIT_TIME"