-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (119 loc) · 3.81 KB
/
Copy pathCI.yml
File metadata and controls
143 lines (119 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: write
pull-requests: write
jobs:
test:
name: Python ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- "3.12"
os:
- ubuntu-latest
arch:
- x64
- x86
steps:
# Updated to v4
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage
pip install pytest pytest-cov
pip install -r requirements.txt
- name: Configure Coverage Parallel Mode
run: |
echo '[run]' > .coveragerc
echo 'parallel = True' >> .coveragerc
- name: Run tests (Parallel Data Collection)
run: |
export RANK=0
export LOCAL_RANK=0
export WORLD_SIZE=1
export MASTER_ADDR=localhost
export MASTER_PORT=12345
export PYTHONPATH=MCintegration
# 使用 coverage run 运行 pytest 以确保多进程/多核测试数据的收集
coverage run -m pytest --ignore=examples
# Updated to v4
- name: Upload coverage data artifact
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.os }}-${{ matrix.arch }}
# 修复:同时上传 .coverage (单进程默认) 和 .coverage.* (多进程并行) 文件
path: |
.coverage
.coverage.*
codecov:
name: Codecov Merge & Upload
runs-on: ubuntu-latest
needs: test
steps:
# Updated to v4
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install coverage (for combining)
run: pip install coverage
# Updated to v4
- name: Download all coverage data artifacts
uses: actions/download-artifact@v4
with:
path: coverage-artifacts
# 合并所有数据文件并生成最终 XML 报告
- name: Combine and Report
run: |
# 移动所有数据文件到根目录,以便 coverage combine 找到
# find 命令现在可以安全运行,因为 download-artifact 应该已创建目录
find coverage-artifacts -name ".coverage*" -exec mv {} . \;
# 合并所有 .coverage.* 文件,解决跨 Job 和多进程数据丢失问题
coverage combine
# 生成最终的 XML 报告
coverage xml
# 上传最终的合并报告
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
docs:
name: Documentation
runs-on: ubuntu-latest
needs: codecov
steps:
# Updated to v4
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install sphinx
pip install -r requirements.txt
- name: Build documentation
run: |
cd docs
sphinx-apidoc -o source ../MCintegration ../MCintegration/*_test.py
python ../clean_MCintegration_rst.py
make html
python ../clean_html_sidebar.py
- name: Deploy documentation to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html