Skip to content

Commit 33ff9f1

Browse files
committed
[CI] Unified diff coverage upload logic
1 parent 109d48e commit 33ff9f1

File tree

7 files changed

+108
-302
lines changed

7 files changed

+108
-302
lines changed

.github/workflows/_unit_test_coverage.yml

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
if: needs.check_cov_skip.outputs.can-skip != 'true'
4747
outputs:
4848
diff_cov_file_url: ${{ steps.cov_upload.outputs.diff_cov_file_url }}
49+
all_cov_file_url: ${{ steps.cov_upload.outputs.all_cov_file_url }}
4950
unittest_failed_url: ${{ steps.cov_upload.outputs.unittest_failed_url }}
5051
diff_cov_result_json_url: ${{ steps.cov_upload.outputs.diff_cov_result_json_url }}
5152
steps:
@@ -266,6 +267,14 @@ jobs:
266267
echo "diff_cov_result_json_url=${DIFF_COV_JSON_URL}" >> $GITHUB_OUTPUT
267268
echo "diff_cov_result_json_url=${DIFF_COV_JSON_URL}" >> $GITHUB_ENV
268269
fi
270+
271+
all_coverage_file="python_coverage_all.xml"
272+
if [ -f ${all_coverage_file} ]; then
273+
python ${push_file} ${all_coverage_file} ${target_path}/CoverageData
274+
ALL_COV_FILE_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${all_coverage_file}
275+
echo "all_cov_file_url=${ALL_COV_FILE_URL}" >> $GITHUB_OUTPUT
276+
echo "all_cov_file_url=${ALL_COV_FILE_URL}" >> $GITHUB_ENV
277+
fi
269278
fi
270279
271280
HAS_FAILED_TESTS=false
@@ -352,28 +361,54 @@ jobs:
352361
runs-on: ubuntu-latest
353362
timeout-minutes: 15
354363
env:
355-
fd_archive_url: ${{ inputs.FASTDEPLOY_ARCHIVE_URL }}
364+
diff_cov_file_url: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url }}
365+
all_cov_file_url: ${{ needs.run_tests_with_coverage.outputs.all_cov_file_url }}
356366
steps:
357-
- name: coverage diff file download
367+
- name: Clone FastDeploy
368+
uses: actions/checkout@v4
369+
with:
370+
fetch-depth: 0
371+
- uses: actions/setup-python@v5
372+
with:
373+
python-version: '3.10'
374+
- name: Fetch base branch
375+
run: |
376+
echo "Fetching base branch: ${{ github.event.pull_request.base.ref }}"
377+
git fetch origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}
378+
379+
- name: Download diff coverage file
358380
shell: bash
359-
env:
360-
diff_cov_file_url: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url }}
361381
run: |
362-
wget -q --no-proxy ${fd_archive_url}
363-
tar -xf FastDeploy.tar.gz
364-
cd FastDeploy
365382
if [ -z "${diff_cov_file_url}" ]; then
366383
echo "No diff coverage file URL provided."
367384
exit 0
368385
fi
369-
wget "${diff_cov_file_url}" -O ./diff_coverage.xml || echo "Download cov file failed, but continuing..."
386+
387+
echo "Downloading diff coverage file..."
388+
if ! wget --no-proxy "${diff_cov_file_url}" -O diff_coverage.xml; then
389+
echo "Download failed, skipping upload."
390+
exit 0
391+
fi
392+
393+
echo "Downloading all coverage file..."
394+
if ! wget --no-proxy "${all_cov_file_url}" -O python_coverage_all.xml; then
395+
echo "Download failed, skipping upload."
396+
exit 0
397+
fi
398+
399+
if [ ! -s diff_coverage.xml ]; then
400+
echo "Downloaded diff coverage file is empty!"
401+
exit 0
402+
fi
403+
sed -i 's|<source>/workspace/FastDeploy/fastdeploy</source>|<source>fastdeploy</source>|' diff_coverage.xml
404+
sed -i 's|<source>/workspace/FastDeploy/fastdeploy</source>|<source>fastdeploy</source>|' python_coverage_all.xml
405+
370406
- name: Upload diff coverage report
371-
if: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url != null && needs.run_tests_with_coverage.outputs.diff_cov_file_url != '' }}
372-
uses: codecov/codecov-action@v5
407+
if: always() && hashFiles('diff_coverage.xml') != ''
408+
uses: codecov/codecov-action@v4
373409
with:
374-
files: ./FastDeploy/diff_coverage.xml
410+
files: ./diff_coverage.xml, ./python_coverage_all.xml
411+
flags: diff
375412
name: python diff coverage
413+
fail_ci_if_error: false
376414
verbose: true
377-
disable_search: true
378-
commit_parent: false
379-
flags: diff

.github/workflows/ci_hpu.yml

Lines changed: 0 additions & 85 deletions
This file was deleted.

.github/workflows/ci_iluvatar.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

.github/workflows/ci_xpu.yml

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)