Skip to content

[CI] Add coverage failed tips and rerun #72392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/check-bypass/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
- id: check-bypass
name: Check Bypass
env:
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1"]'
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1", "XieYunshen"]'
uses: PFCCLab/ci-bypass@v1
with:
github-token: ${{ inputs.github-token }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: CI
on:
pull_request:
types: [opened, synchronize]
branches: [develop, release/**]

permissions: read-all

Expand Down Expand Up @@ -35,7 +36,7 @@ jobs:
needs: clone

coverage:
name: PR-CI-Coverage
name: Coverage
uses: ./.github/workflows/_Coverage.yml
needs: clone

Expand Down
59 changes: 36 additions & 23 deletions .github/workflows/_Coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR-CI-Coverage
name: Coverage

on:
workflow_call:
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
rm -rf ./python/build/lib.linux-x86_64-3.9/
cd "${work_dir}/build/third_party" && find $(ls | grep -v "dlpack" | grep -v "install" | grep -v "eigen3" | grep -v "gflags") -type f ! -name "*.so" -a ! -name "libdnnl.so*" -delete
cd /
tar --use-compress-program="pzstd -1" -cpf Paddle.tar.gz paddle
tar --use-compress-program="pzstd -1" -cf Paddle.tar.gz paddle
'

- name: Upload coverage product
Expand Down Expand Up @@ -218,21 +218,8 @@ jobs:
needs: build
if: needs.build.outputs.can-skip != 'true'
runs-on:
group: BD_BJ_v100
group: BD_BJ-V100
steps:
- name: Download paddle.tar.gz and update test branch
run: |
set -e
echo "Downloading Paddle.tar.gz"
wget -q --no-proxy https://paddle-github-action.bj.bcebos.com/PR/coverage/${PR_ID}/${COMMIT_ID}/Paddle.tar.gz --no-check-certificate
echo "Extracting Paddle.tar.gz"
tar --use-compress-program='pzstd -1' -xpf Paddle.tar.gz --strip-components=1
rm Paddle.tar.gz
source ${{ github.workspace }}/../../../proxy
git checkout test
echo "Pull upstream develop"
git pull upstream $BRANCH --no-edit

- name: Check docker image and run container
env:
CACHE_DIR: "/root/.cache/coverage"
Expand Down Expand Up @@ -303,6 +290,22 @@ jobs:
-e GITHUB_API_TOKEN \
-w /paddle --network host ${docker_image}

- name: Download paddle.tar.gz and update test branch
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
rm -rf * .[^.]*
set -e
echo "Downloading Paddle.tar.gz"
wget -q --no-proxy https://paddle-github-action.bj.bcebos.com/PR/coverage/${PR_ID}/${COMMIT_ID}/Paddle.tar.gz --no-check-certificate
echo "Extracting Paddle.tar.gz"
tar --use-compress-program="pzstd -1" -xf Paddle.tar.gz --strip-components=1
rm Paddle.tar.gz
source ${{ github.workspace }}/../../../proxy
git checkout test
echo "Pull upstream develop"
git pull upstream $BRANCH --no-edit
'

- name: Test
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
Expand All @@ -315,33 +318,43 @@ jobs:
fi
'

- name: Check coverage data
- name: Generate coverage information
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
source ~/.bashrc
unset GREP_OPTIONS
source ${{ github.workspace }}/../../../proxy
source ${ci_scripts}/utils.sh; check_coverage
COVERAGE_EXIT_CODE=$?
echo "COVERAGE_EXIT_CODE=${COVERAGE_EXIT_CODE}" >> ${{ github.env }}
'

- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
directory: build/coverage_files

- name: Judge coverage passed or not
- name: Determine whether the coverage rate reaches 90%
run: |
if [ "${{ env.COVERAGE_EXIT_CODE }}" -ne 0 ]; then
echo "Coverage failed"
exit ${{ env.COVERAGE_EXIT_CODE }}
docker exec -t ${{ env.container_name }} /bin/bash -c '
source ~/.bashrc
unset GREP_OPTIONS
source ${{ github.workspace }}/../../../proxy
source ${ci_scripts}/utils.sh
bash $ci_scripts/coverage_judge.sh
COVERAGE_EXIT_CODE=$?
echo $COVERAGE_EXIT_CODE
if [ "$COVERAGE_EXIT_CODE" -ne 0 ]; then
echo "Coverage check failed, unit tests have all passed, please do not rerun, check whether the newly added code lines are fully covered by unit tests. If you have any questions, please contact XieYunshen."
exit $COVERAGE_EXIT_CODE
else
echo "Coverage passed"
fi
'

- name: Terminate and delete the container
if: always()
run: |
set +e
rm Paddle.tar.gz
docker exec -t ${{ env.container_name }} /bin/bash -c 'rm -rf * .[^.]*'
docker stop ${{ env.container_name }}
docker rm ${{ env.container_name }}
152 changes: 0 additions & 152 deletions .github/workflows/_Py3.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/_SOT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
-e CCACHE_DIR \
-w /paddle --network host ${docker_image}

- name: Download paddle.tar.gz and merge $BRANCH
- name: Download paddle.tar.gz and merge target branch
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
rm -rf * .[^.]*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-bypass.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
permissions:
contents: read
env:
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1"]'
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1", "XieYunshen"]'
outputs:
can-skip: ${{ steps.check-bypass.outputs.can-skip }}
steps:
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/re-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ jobs:
REPO: ${{ github.event.repository.name }}
JOB_NAME: 'PR-CI-Inference / Test'

- name: Rerun coverage
if: ${{ contains(env.comment_body, 'coverage') && !contains(env.comment_body, 'test') }}
uses: ./.github/actions/rerun-workflow
with:
PR_ID: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
JOB_NAME: 'Coverage / Coverage build'

- name: Rerun coverage test
if: ${{ contains(env.comment_body, 'coverage') && contains(env.comment_body, 'test') }}
uses: ./.github/actions/rerun-workflow
with:
PR_ID: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
JOB_NAME: 'Coverage / Coverage test'

- name: Rerun XPU
if: ${{ contains(env.comment_body, 'xpu') && !contains(env.comment_body, 'build') && !contains(env.comment_body, 'test') }}
uses: ./.github/actions/rerun-workflow
Expand Down
26 changes: 0 additions & 26 deletions ci/coverage_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,29 +218,3 @@ python ${PADDLE_ROOT}/ci/coverage_diff.py python-coverage-diff.info python-git-d
mv -f python-coverage-diff.tmp python-coverage-diff.info

cp python-coverage-diff.info coverage_files

# assert coverage lines

echo "Assert Diff Coverage"

python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py coverage-diff.info 0.9 || COVERAGE_LINES_ASSERT=1

echo "Assert Python Diff Coverage"

if [ ${WITH_XPU:-OFF} == "ON" ]; then
echo "XPU has no python coverage!"
else
if [[ "${NO_PYTHON_COVERAGE_DATA}" != "1" ]];then
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1
fi
fi

if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then
echo "exit 9" > /tmp/paddle_coverage.result
python ${PADDLE_ROOT}/tools/get_pr_title.py skip_coverage_check && NOT_CHECK_COVERAGE_PR=1
if [[ "${NOT_CHECK_COVERAGE_PR}" = "1" ]];then
echo "Skip coverage check in the PR-CI-Coverage pipeline."
exit 0
fi
exit 9
fi
Loading