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