Compare commits

..

No commits in common. "c7c01ddc2103403c549eab3569b837432f1be2bf" and "b5b5d1e2992d2f91a04c6230edf0bd77b8e0f8c3" have entirely different histories.

View File

@ -6,8 +6,9 @@ trigger:
event:
- pull_request
branch:
- main # <<< 确保分支名称与您的主分支一致
- main
# 克隆策略:只拉最新 commit加速
clone:
depth: 0
image: drone/git:latest
@ -21,11 +22,11 @@ steps:
environment:
MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
commands:
# 在当前工作目录而非 ~ 下创建 .m2 目录,避免权限问题
- mkdir -p .m2/repository
# 动态生成 settings.xml
# 先创建 .m2 目录
- mkdir -p ~/.m2
# 动态生成 settings.xml(仅用于 CI
- |
cat > settings.xml << 'EOF'
cat > ~/.m2/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"
@ -40,28 +41,24 @@ steps:
</mirrors>
</settings>
EOF
# 使用自定义 settings.xml
- mvn -s settings.xml clean verify
- mvn clean verify
- if [ -f pom.xml ]; then mvn clean compile; fi
when:
path:
include:
- pom.xml # 仅当存在 pom.xml 文件时运行
event: [ push, pull_request ]
# 自动检测是否存在 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
- pip install -r requirements.txt
- python -m pytest test_example.py -v
- 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
when:
path:
include:
- requirements.txt # 仅当存在 requirements.txt 文件时运行
event: [ push, pull_request ]
# 最终报告(无论成功失败都运行)
- name: summary
image: alpine