forked from jk_yinzy/cicd-test
33 lines
850 B
YAML
33 lines
850 B
YAML
|
|
kind: pipeline
|
|||
|
|
type: docker
|
|||
|
|
name: multi-lang-ci
|
|||
|
|
|
|||
|
|
# 克隆策略:只拉最新 commit,加速
|
|||
|
|
clone:
|
|||
|
|
depth: 1
|
|||
|
|
|
|||
|
|
steps:
|
|||
|
|
# 自动检测是否存在 Java (pom.xml)
|
|||
|
|
- name: java-build
|
|||
|
|
image: maven:3.8-eclipse-temurin-17
|
|||
|
|
commands:
|
|||
|
|
- if [ -f pom.xml ]; then mvn clean compile; fi
|
|||
|
|
when:
|
|||
|
|
event: [ push, pull_request ]
|
|||
|
|
|
|||
|
|
# 自动检测是否存在 Python (requirements.txt)
|
|||
|
|
- name: python-test
|
|||
|
|
image: python:3.9-slim
|
|||
|
|
commands:
|
|||
|
|
- 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:
|
|||
|
|
event: [ push, pull_request ]
|
|||
|
|
|
|||
|
|
# 最终报告(无论成功失败都运行)
|
|||
|
|
- name: summary
|
|||
|
|
image: alpine
|
|||
|
|
commands:
|
|||
|
|
- echo "✅ CI completed at $(date)"
|
|||
|
|
when:
|
|||
|
|
status: [ success, failure ]
|