3939 secrets :
4040 github-token :
4141 required : true
42+ outputs :
43+ coverage_data_url :
44+ description : " URL of the coverage data archive"
45+ value : ${{ jobs.run_xpu_4cards_cases.outputs.coverage_data_url }}
4246
4347jobs :
4448 check_bypass :
5357 needs : check_bypass
5458 if : ${{ inputs.FASTDEPLOY_WHEEL_URL != '' && needs.check_bypass.outputs.can-skip != 'true' }}
5559 timeout-minutes : 60
60+ outputs :
61+ coverage_data_url : ${{ steps.upload_coverage.outputs.coverage_data_url }}
5662 steps :
5763 - name : Print current runner name
5864 run : |
@@ -188,19 +194,30 @@ jobs:
188194 python -m pip install openai -U
189195 python -m pip install pytest
190196 python -m pip install pytest-timeout
197+ python -m pip install coverage
191198 unset http_proxy
192199 unset https_proxy
193200 echo "============================开始运行pytest测试============================"
194201 export PYTHONPATH=/workspace/FastDeploy/
195202 export PYTHONPATH=$(pwd)/tests/xpu_ci:$PYTHONPATH
196- mkdir -p case_logs
203+ export COVERAGE_RCFILE=/workspace/FastDeploy/scripts/.coveragerc_xpu
204+ mkdir -p case_logs coveragedata
197205 set +e
198- python -m pytest -v -s --tb=short tests/xpu_ci/4cards_cases/
206+ COVERAGE_FILE=/workspace/FastDeploy/coveragedata/.coverage.4cards \
207+ python -m coverage run --rcfile=${COVERAGE_RCFILE} -m pytest -v -s --tb=short tests/xpu_ci/4cards_cases/
199208 exit_code=$?
200209 set -e
201210
211+ # 合并覆盖率数据
212+ cd /workspace/FastDeploy
213+ COVERAGE_FILE=/workspace/FastDeploy/coveragedata/.coverage.4cards \
214+ python -m coverage combine --rcfile=${COVERAGE_RCFILE} coveragedata/ || true
215+ tar -czf /workspace/FastDeploy/coverage_4cards.tar.gz -C coveragedata .
216+
202217 # 修改case_logs权限,确保Docker外部的runner用户可以读取并上传
203218 chmod -R a+rX case_logs/ 2>/dev/null || true
219+ chmod -R a+rX coveragedata/ 2>/dev/null || true
220+ chmod a+r /workspace/FastDeploy/coverage_4cards.tar.gz 2>/dev/null || true
204221
205222 if [ $exit_code -eq 0 ]; then
206223 echo "============================4卡cases测试通过!============================"
@@ -219,3 +236,33 @@ jobs:
219236 path : FastDeploy/case_logs/
220237 retention-days : 7
221238 if-no-files-found : ignore
239+
240+ - name : Upload coverage data to BOS
241+ id : upload_coverage
242+ if : always()
243+ run : |
244+ set -x
245+ if [[ "${{ github.event_name }}" == "pull_request" ]];then
246+ commit_id=${{ github.event.pull_request.head.sha }}
247+ pr_num=${{ github.event.pull_request.number }}
248+ target_path=paddle-github-action/PR/FastDeploy/${pr_num}/${commit_id}/xpu_coverage
249+ else
250+ commit_id=${{ github.sha }}
251+ branch_name=${{ github.ref_name }}
252+ target_path=paddle-github-action/BRANCH/FastDeploy/${branch_name}/${commit_id}/xpu_coverage
253+ fi
254+ wget -q --no-proxy --no-check-certificate https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddlePaddle/PaddleTest/tools/bos_tools.py
255+ push_file=$(realpath bos_tools.py)
256+ python3 -m pip install -q bce-python-sdk==0.9.29
257+ COV_FILE="coverage_4cards.tar.gz"
258+ if [ -f "FastDeploy/${COV_FILE}" ]; then
259+ cd FastDeploy
260+ python3 ${push_file} ${COV_FILE} ${target_path}
261+ cd ..
262+ target_path_stripped="${target_path#paddle-github-action/}"
263+ COV_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/coverage_4cards.tar.gz
264+ echo "coverage_data_url=${COV_URL}" >> $GITHUB_OUTPUT
265+ else
266+ echo "No coverage data found, skipping upload."
267+ echo "coverage_data_url=" >> $GITHUB_OUTPUT
268+ fi
0 commit comments