From a4773ccea3e0ac5be758080e0a2714ef4ec06372 Mon Sep 17 00:00:00 2001 From: dongzi Date: Wed, 3 Jun 2026 15:12:25 +0800 Subject: [PATCH] test --- .gitea/workflows/api-change-check.yml | 61 +++++++++++++-------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/.gitea/workflows/api-change-check.yml b/.gitea/workflows/api-change-check.yml index 50581e3..ebce322 100644 --- a/.gitea/workflows/api-change-check.yml +++ b/.gitea/workflows/api-change-check.yml @@ -1,22 +1,26 @@ # Gitea Actions:push 后检测 Controller 接口参数变更 # 工具代码与配置均位于 .gitea/ 目录,与业务代码解耦 +# 检出方式:使用 gitea.token 直连内网 Git 仓库(避免 actions/checkout 网络问题) -name: API Parameter Change Check +name: API接口参数变更检测 +run-name: ${{ gitea.actor }}的API参数变更检测 -on: - push: - branches: - - '**' +on: [push] jobs: api-param-check: + # 排除指定分支(与现有 AI 审查 workflow 保持一致,可按需修改) + if: ${{ gitea.ref != 'refs/heads/pre' && gitea.ref != 'refs/heads/dev' && gitea.ref != 'refs/heads/master-2.0' }} runs-on: ubuntu-latest steps: - - name: 检出代码 - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: 内置权限检出代码 + run: | + git config --global http.sslVerify false + git clone "https://${{ gitea.token }}@git.niujiekeji.com/${{ gitea.repository }}.git" . + git checkout ${{ gitea.sha }} + echo "当前提交: $(git rev-parse HEAD)" + echo "上一提交: $(git rev-parse HEAD~1 2>/dev/null || echo '无')" - name: 检查配置文件 run: | @@ -26,37 +30,30 @@ jobs: fi echo "使用 .gitea/config.yaml" - - name: 安装 Java 11 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: '11' - cache: maven + - name: 安装 Java、Maven 和 Python + run: | + echo "安装运行环境..." + sudo apt-get update + sudo apt-get install -y openjdk-11-jdk maven python3 python3-pip + java -version + mvn -version + python3 --version + echo "环境准备完成" - - name: 安装 Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' + - name: 安装 Python 依赖 + run: | + python3 -m pip install --break-system-packages -r .gitea/checker/requirements.txt - name: 构建 AST 解析器 working-directory: .gitea/java-parser run: mvn -q package -DskipTests - - name: 安装 Python 依赖 - run: pip install -r .gitea/checker/requirements.txt - - name: 检测 Controller 接口参数变更 run: | - python .gitea/checker/main.py \ + echo "执行 API 参数变更检测..." + COMMIT_TIME=$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S') + python3 .gitea/checker/main.py \ --config .gitea/config.yaml \ --repo-root . \ "${{ gitea.actor }}" \ - "$(git log -1 --format=%ci)" - - - name: 上传变更日志 - if: always() - uses: actions/upload-artifact@v4 - with: - name: api-change-logs - path: .gitea/logs/api-changes/ - if-no-files-found: ignore + "$COMMIT_TIME"