Skip to content

Commit 1b4bb4f

Browse files
committed
ci(workflows): add ci workflow and enhance release-test workflow_call support
Add new ci.yml workflow file and modify release-test.yml to support workflow_call with version bump inputs, enabling the workflow to be triggered automatically from other workflows with configurable version increment types. Added workflow_call trigger support with version_bump input parameter and default to 'patch' when no input is provided. ci(workflows): 添加 CI 工作流并增强 release-test 工作流调用支持 添加新的 ci.yml 工作流文件并修改 release-test.yml 以支持 workflow_call 和版本递增输入,使该工作流能够从其他工作流自动触发并配置版本递增类型。 添加了 workflow_call 触发支持和 version_bump 输入参数 并在没有输入时默认为 'patch'。 Added workflow_call trigger support with version_bump input parameter and default to 'patch' when no input is provided. 添加了工作流调用触发支持和版本递增输入参数 并在没有输入时默认为 'patch'。 Change-Id: I1948c3fb6e9daa4808ce3504353f175e4b5c863f Signed-off-by: OhYee <[email protected]>
1 parent b263f5e commit 1b4bb4f

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
# 仅在 push 时触发测试
5+
push:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ['3.10']
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # 获取完整历史用于增量覆盖率检查
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install uv
26+
run: |
27+
pip install uv
28+
echo "✅ uv installed: $(uv --version)"
29+
30+
- name: Install dependencies
31+
run: |
32+
uv sync \
33+
--python ${{ matrix.python-version }} \
34+
--dev \
35+
--all-extras
36+
37+
- name: Run type check (mypy)
38+
run: |
39+
uv run mypy --config-file mypy.ini .
40+
41+
- name: Run unit tests
42+
run: |
43+
uv run pytest tests/unittests/ -v
44+
45+
- name: Run coverage check
46+
run: |
47+
uv run python scripts/check_coverage.py --incremental
48+
49+
# 测试通过后自动构建测试包(仅在 push 到 main/master/develop 分支时触发)
50+
build-test-package:
51+
needs: test
52+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop'
53+
uses: ./.github/workflows/release-test.yml
54+
secrets: inherit
55+
with:
56+
version_bump: 'patch'
57+

.github/workflows/release-test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ on:
1313
- patch # 0.0.1 -> 0.0.2
1414
- minor # 0.0.1 -> 0.1.0
1515
- major # 0.0.1 -> 1.0.0
16+
17+
# 支持被其他工作流调用(CI 测试通过后自动触发)
18+
workflow_call:
19+
inputs:
20+
version_bump:
21+
description: '版本递增类型'
22+
required: false
23+
default: 'patch'
24+
type: string
1625

1726
jobs:
1827
release-test:
@@ -49,8 +58,8 @@ jobs:
4958
# 解析版本号
5059
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
5160
52-
# 根据用户选择递增版本
53-
BUMP_TYPE="${{ inputs.version_bump }}"
61+
# 根据用户选择递增版本(默认为 patch)
62+
BUMP_TYPE="${{ inputs.version_bump || 'patch' }}"
5463
case "$BUMP_TYPE" in
5564
major)
5665
MAJOR=$((MAJOR + 1))

0 commit comments

Comments
 (0)