更新ci #25

Merged
jk_yinzy merged 2 commits from jk_yinzy-patch-1 into main 2025-12-06 07:46:44 +08:00
Showing only changes of commit 102f5ca8f0 - Show all commits

View File

@ -6,9 +6,8 @@ trigger:
event:
- pull_request
branch:
- main
- main # <<< 确保分支名称与您的主分支一致
# 克隆策略:只拉最新 commit加速
clone:
depth: 0
image: drone/git:latest
@ -22,11 +21,11 @@ steps:
environment:
MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
commands:
# 先创建 .m2 目录
- mkdir -p ~/.m2
# 动态生成 settings.xml(仅用于 CI
# 在当前工作目录而非 ~ 下创建 .m2 目录,避免权限问题
- mkdir -p .m2/repository
# 动态生成 settings.xml
- |
cat > ~/.m2/settings.xml << 'EOF'
cat > settings.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@ -41,25 +40,30 @@ steps:
</mirrors>
</settings>
EOF
- mvn clean verify
- if [ -f pom.xml ]; then mvn clean compile; fi
# 使用自定义 settings.xml
- mvn -s settings.xml clean verify
when:
event: [ push, pull_request ]
path:
include:
- pom.xml # 仅当存在 pom.xml 文件时运行
# 自动检测是否存在 Python (requirements.txt)
- name: python-test
image: python:3.12.0-slim
pull: false
commands:
# 临时设置 pip 源(仅本次会话)
# 临时设置 pip 源
- pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
- pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- if [ -f test_example.py ]; then python -m pytest test_example.py -v; fi
- pip install -r requirements.txt
- python -m pytest test_example.py -v
when:
event: [ push, pull_request ]
path:
include:
- requirements.txt # 仅当存在 requirements.txt 文件时运行
# 最终报告(无论成功失败都运行)
告(无论成功失败都运行)
- name: summary
image: alpine
pull: false