Skip to content

Commit f67da16

Browse files
authored
[CI] Add coverage failed tips and rerun (#72392)
1 parent 12f2dcc commit f67da16

File tree

10 files changed

+104
-208
lines changed

10 files changed

+104
-208
lines changed

.github/actions/check-bypass/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
- id: check-bypass
1919
name: Check Bypass
2020
env:
21-
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1"]'
21+
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1", "XieYunshen"]'
2222
uses: PFCCLab/ci-bypass@v1
2323
with:
2424
github-token: ${{ inputs.github-token }}

.github/workflows/CI.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: CI
33
on:
44
pull_request:
55
types: [opened, synchronize]
6+
branches: [develop, release/**]
67

78
permissions: read-all
89

@@ -35,7 +36,7 @@ jobs:
3536
needs: clone
3637

3738
coverage:
38-
name: PR-CI-Coverage
39+
name: Coverage
3940
uses: ./.github/workflows/_Coverage.yml
4041
needs: clone
4142

.github/workflows/_Coverage.yml

+36-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR-CI-Coverage
1+
name: Coverage
22

33
on:
44
workflow_call:
@@ -171,7 +171,7 @@ jobs:
171171
rm -rf ./python/build/lib.linux-x86_64-3.9/
172172
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
173173
cd /
174-
tar --use-compress-program="pzstd -1" -cpf Paddle.tar.gz paddle
174+
tar --use-compress-program="pzstd -1" -cf Paddle.tar.gz paddle
175175
'
176176
177177
- name: Upload coverage product
@@ -218,21 +218,8 @@ jobs:
218218
needs: build
219219
if: needs.build.outputs.can-skip != 'true'
220220
runs-on:
221-
group: BD_BJ_v100
221+
group: BD_BJ-V100
222222
steps:
223-
- name: Download paddle.tar.gz and update test branch
224-
run: |
225-
set -e
226-
echo "Downloading Paddle.tar.gz"
227-
wget -q --no-proxy https://paddle-github-action.bj.bcebos.com/PR/coverage/${PR_ID}/${COMMIT_ID}/Paddle.tar.gz --no-check-certificate
228-
echo "Extracting Paddle.tar.gz"
229-
tar --use-compress-program='pzstd -1' -xpf Paddle.tar.gz --strip-components=1
230-
rm Paddle.tar.gz
231-
source ${{ github.workspace }}/../../../proxy
232-
git checkout test
233-
echo "Pull upstream develop"
234-
git pull upstream $BRANCH --no-edit
235-
236223
- name: Check docker image and run container
237224
env:
238225
CACHE_DIR: "/root/.cache/coverage"
@@ -303,6 +290,22 @@ jobs:
303290
-e GITHUB_API_TOKEN \
304291
-w /paddle --network host ${docker_image}
305292
293+
- name: Download paddle.tar.gz and update test branch
294+
run: |
295+
docker exec -t ${{ env.container_name }} /bin/bash -c '
296+
rm -rf * .[^.]*
297+
set -e
298+
echo "Downloading Paddle.tar.gz"
299+
wget -q --no-proxy https://paddle-github-action.bj.bcebos.com/PR/coverage/${PR_ID}/${COMMIT_ID}/Paddle.tar.gz --no-check-certificate
300+
echo "Extracting Paddle.tar.gz"
301+
tar --use-compress-program="pzstd -1" -xf Paddle.tar.gz --strip-components=1
302+
rm Paddle.tar.gz
303+
source ${{ github.workspace }}/../../../proxy
304+
git checkout test
305+
echo "Pull upstream develop"
306+
git pull upstream $BRANCH --no-edit
307+
'
308+
306309
- name: Test
307310
run: |
308311
docker exec -t ${{ env.container_name }} /bin/bash -c '
@@ -315,33 +318,43 @@ jobs:
315318
fi
316319
'
317320
318-
- name: Check coverage data
321+
- name: Generate coverage information
319322
run: |
320323
docker exec -t ${{ env.container_name }} /bin/bash -c '
321324
source ~/.bashrc
322325
unset GREP_OPTIONS
323326
source ${{ github.workspace }}/../../../proxy
324327
source ${ci_scripts}/utils.sh; check_coverage
325-
COVERAGE_EXIT_CODE=$?
326-
echo "COVERAGE_EXIT_CODE=${COVERAGE_EXIT_CODE}" >> ${{ github.env }}
327328
'
328329
329330
- name: Upload coverage report
330331
uses: codecov/codecov-action@v4
331332
with:
332333
directory: build/coverage_files
333334

334-
- name: Judge coverage passed or not
335+
- name: Determine whether the coverage rate reaches 90%
335336
run: |
336-
if [ "${{ env.COVERAGE_EXIT_CODE }}" -ne 0 ]; then
337-
echo "Coverage failed"
338-
exit ${{ env.COVERAGE_EXIT_CODE }}
337+
docker exec -t ${{ env.container_name }} /bin/bash -c '
338+
source ~/.bashrc
339+
unset GREP_OPTIONS
340+
source ${{ github.workspace }}/../../../proxy
341+
source ${ci_scripts}/utils.sh
342+
bash $ci_scripts/coverage_judge.sh
343+
COVERAGE_EXIT_CODE=$?
344+
echo $COVERAGE_EXIT_CODE
345+
if [ "$COVERAGE_EXIT_CODE" -ne 0 ]; then
346+
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."
347+
exit $COVERAGE_EXIT_CODE
348+
else
349+
echo "Coverage passed"
339350
fi
351+
'
340352
341353
- name: Terminate and delete the container
342354
if: always()
343355
run: |
344356
set +e
357+
rm Paddle.tar.gz
345358
docker exec -t ${{ env.container_name }} /bin/bash -c 'rm -rf * .[^.]*'
346359
docker stop ${{ env.container_name }}
347360
docker rm ${{ env.container_name }}

.github/workflows/_Py3.yml

-152
This file was deleted.

.github/workflows/_SOT.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
-e CCACHE_DIR \
9595
-w /paddle --network host ${docker_image}
9696
97-
- name: Download paddle.tar.gz and merge $BRANCH
97+
- name: Download paddle.tar.gz and merge target branch
9898
run: |
9999
docker exec -t ${{ env.container_name }} /bin/bash -c '
100100
rm -rf * .[^.]*

.github/workflows/check-bypass.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
permissions:
2020
contents: read
2121
env:
22-
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1"]'
22+
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1", "XieYunshen"]'
2323
outputs:
2424
can-skip: ${{ steps.check-bypass.outputs.can-skip }}
2525
steps:

.github/workflows/re-run.yml

+20
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,26 @@ jobs:
119119
REPO: ${{ github.event.repository.name }}
120120
JOB_NAME: 'PR-CI-Inference / Test'
121121

122+
- name: Rerun coverage
123+
if: ${{ contains(env.comment_body, 'coverage') && !contains(env.comment_body, 'test') }}
124+
uses: ./.github/actions/rerun-workflow
125+
with:
126+
PR_ID: ${{ github.event.issue.number }}
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
OWNER: ${{ github.repository_owner }}
129+
REPO: ${{ github.event.repository.name }}
130+
JOB_NAME: 'Coverage / Coverage build'
131+
132+
- name: Rerun coverage test
133+
if: ${{ contains(env.comment_body, 'coverage') && contains(env.comment_body, 'test') }}
134+
uses: ./.github/actions/rerun-workflow
135+
with:
136+
PR_ID: ${{ github.event.issue.number }}
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
OWNER: ${{ github.repository_owner }}
139+
REPO: ${{ github.event.repository.name }}
140+
JOB_NAME: 'Coverage / Coverage test'
141+
122142
- name: Rerun XPU
123143
if: ${{ contains(env.comment_body, 'xpu') && !contains(env.comment_body, 'build') && !contains(env.comment_body, 'test') }}
124144
uses: ./.github/actions/rerun-workflow

ci/coverage_info.sh

-26
Original file line numberDiff line numberDiff line change
@@ -218,29 +218,3 @@ python ${PADDLE_ROOT}/ci/coverage_diff.py python-coverage-diff.info python-git-d
218218
mv -f python-coverage-diff.tmp python-coverage-diff.info
219219

220220
cp python-coverage-diff.info coverage_files
221-
222-
# assert coverage lines
223-
224-
echo "Assert Diff Coverage"
225-
226-
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py coverage-diff.info 0.9 || COVERAGE_LINES_ASSERT=1
227-
228-
echo "Assert Python Diff Coverage"
229-
230-
if [ ${WITH_XPU:-OFF} == "ON" ]; then
231-
echo "XPU has no python coverage!"
232-
else
233-
if [[ "${NO_PYTHON_COVERAGE_DATA}" != "1" ]];then
234-
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1
235-
fi
236-
fi
237-
238-
if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then
239-
echo "exit 9" > /tmp/paddle_coverage.result
240-
python ${PADDLE_ROOT}/tools/get_pr_title.py skip_coverage_check && NOT_CHECK_COVERAGE_PR=1
241-
if [[ "${NOT_CHECK_COVERAGE_PR}" = "1" ]];then
242-
echo "Skip coverage check in the PR-CI-Coverage pipeline."
243-
exit 0
244-
fi
245-
exit 9
246-
fi

0 commit comments

Comments
 (0)