Modify the existing coverage collection method (#3573)

fix cov report
This commit is contained in:
YUNSHEN XIE
2025-08-25 10:35:35 +08:00
committed by GitHub
parent 7821534ff5
commit 46664985fc
4 changed files with 23 additions and 5 deletions

View File

@@ -175,7 +175,7 @@ jobs:
bash scripts/coverage_run.sh || TEST_EXIT_CODE=8 bash scripts/coverage_run.sh || TEST_EXIT_CODE=8
git diff origin/${BASE_REF}..HEAD --unified=0 > diff.txt git diff origin/${BASE_REF}..HEAD --unified=0 > diff.txt
echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> exit_code.env echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> exit_code.env
coverage combine coveragedata/ coverage combine coveragedata/ || echo "No data to combine"
coverage xml -o python_coverage_all.xml coverage xml -o python_coverage_all.xml
COVERAGE_EXIT_CODE=0 COVERAGE_EXIT_CODE=0
if [[ "$IS_PR" == "true" ]]; then if [[ "$IS_PR" == "true" ]]; then
@@ -276,12 +276,17 @@ jobs:
needs: run_tests_with_coverage needs: run_tests_with_coverage
if: always() if: always()
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
fd_archive_url: ${{ inputs.FASTDEPLOY_ARCHIVE_URL }}
steps: steps:
- name: coverage diff file download - name: coverage diff file download
shell: bash shell: bash
env: env:
diff_cov_file_url: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url }} diff_cov_file_url: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url }}
run: | run: |
wget ${fd_archive_url}
tar -xf FastDeploy.tar.gz
cd FastDeploy
if [ -z "${diff_cov_file_url}" ]; then if [ -z "${diff_cov_file_url}" ]; then
echo "No diff coverage file URL provided." echo "No diff coverage file URL provided."
exit 0 exit 0
@@ -291,6 +296,9 @@ jobs:
if: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url != null && needs.run_tests_with_coverage.outputs.diff_cov_file_url != '' }} if: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url != null && needs.run_tests_with_coverage.outputs.diff_cov_file_url != '' }}
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v5
with: with:
files: ./diff_coverage.xml files: ./FastDeploy/diff_coverage.xml
name: python diff coverage name: python diff coverage
verbose: true verbose: true
disable_search: true
commit_parent: false
flags: diff

View File

@@ -1,4 +1,5 @@
[run] [run]
branch = True
source = fastdeploy source = fastdeploy
parallel = True parallel = True
concurrency = multiprocessing concurrency = multiprocessing
@@ -15,3 +16,4 @@ omit =
*/site-packages/*/tests/* */site-packages/*/tests/*
*/site-packages/setuptools/* */site-packages/setuptools/*
*/dist-packages/* */dist-packages/*
*/site-packages/*/fastdeploy/model_executor/ops/gpu*

View File

@@ -1,7 +1,11 @@
#!/bin/bash #!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
run_path="$DIR/../tests/" run_path="$DIR/../tests/"
export PYTEST_INI="$DIR/../tests/pytest.ini" export PYTEST_INI="$DIR/../tests/cov_pytest.ini"
export COVERAGE_FILE=${COVERAGE_FILE:-$DIR/../coveragedata/.coverage}
export COVERAGE_RCFILE=${COVERAGE_RCFILE:-$DIR/../scripts/.coveragerc}
export COVERAGE_PROCESS_START=${COVERAGE_PROCESS_START:-$DIR/../scripts/.coveragerc}
cd "$run_path" || exit 1 cd "$run_path" || exit 1
failed_tests_file="failed_tests.log" failed_tests_file="failed_tests.log"
@@ -46,7 +50,7 @@ done
# 执行 pytest每个文件单独跑 # 执行 pytest每个文件单独跑
################################## ##################################
# 收集 pytest 文件 # 收集 pytest 文件
TEST_FILES=$(python -m pytest --collect-only -q -c pytest.ini --disable-warnings | grep -Eo '^.*test_.*\.py' | sort | uniq) TEST_FILES=$(python -m pytest --collect-only -q -c ${PYTEST_INI} --disable-warnings | grep -Eo '^.*test_.*\.py' | sort | uniq)
failed_pytest=0 failed_pytest=0
@@ -54,7 +58,7 @@ success_pytest=0
for file in $TEST_FILES; do for file in $TEST_FILES; do
echo "Running pytest file: $file" echo "Running pytest file: $file"
python -m coverage run --parallel-mode -m pytest "$file" -vv -s python -m pytest -c ${PYTEST_INI} --cov-config=${COVERAGE_RCFILE} "$file" -vv -s
status=$? status=$?
if [ "$status" -ne 0 ]; then if [ "$status" -ne 0 ]; then
echo "$file" >> "$failed_tests_file" echo "$file" >> "$failed_tests_file"

View File

@@ -22,6 +22,10 @@ addopts =
--ignore=operators/test_flash_mask_attn.py --ignore=operators/test_flash_mask_attn.py
--ignore=operators/test_w4afp8_gemm.py --ignore=operators/test_w4afp8_gemm.py
--ignore=operators/test_tree_mask.py --ignore=operators/test_tree_mask.py
--cov=fastdeploy
--cov-branch
--cov-append
--cov-report=
# 输出更详细的结果 # 输出更详细的结果
console_output_style = progress console_output_style = progress