From 0d51033ffcb4c0e4ef36bf954e42d7e64776de09 Mon Sep 17 00:00:00 2001 From: EmmonsCurse <1577972691@qq.com> Date: Tue, 18 Nov 2025 17:40:20 +0800 Subject: [PATCH] [CI] [DEBUG] Coverage merge xpu and gpu --- .github/workflows/_ci_xpu.yml | 130 +++++++++++++++++ .github/workflows/_coverage_combine.yml | 108 ++++++++++++++ .github/workflows/_unit_test_coverage.yml | 167 +++------------------- .github/workflows/ci_xpu.yml | 85 ----------- .github/workflows/pr_build_and_test.yml | 22 ++- scripts/.coveragerc | 2 + scripts/codecov.yml | 5 + scripts/run_ci_xpu.sh | 26 ++-- 8 files changed, 301 insertions(+), 244 deletions(-) create mode 100644 .github/workflows/_ci_xpu.yml create mode 100644 .github/workflows/_coverage_combine.yml delete mode 100644 .github/workflows/ci_xpu.yml create mode 100644 scripts/codecov.yml diff --git a/.github/workflows/_ci_xpu.yml b/.github/workflows/_ci_xpu.yml new file mode 100644 index 00000000000..11f451a40bd --- /dev/null +++ b/.github/workflows/_ci_xpu.yml @@ -0,0 +1,130 @@ +name: CI_XPU + +on: + workflow_call: + inputs: + DOCKER_IMAGE: + description: "Build Images" + required: true + type: string + default: "ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/fastdeploy-xpu:2.1.0" + FASTDEPLOY_ARCHIVE_URL: + description: "URL of the compressed FastDeploy code archive." + required: true + type: string + outputs: + xpu_cov_file_url: + description: "Output path of the GPU tests" + value: ${{ jobs.CI_XPU.outputs.xpu_cov_file_url }} + +concurrency: + group: ${{ github.event.pull_request.number }}-xpu-ci + cancel-in-progress: true + +jobs: + CI_XPU: + runs-on: [self-hosted, XPU-P800-8Card] + outputs: + xpu_cov_file_url: ${{ steps.set_output.outputs.xpu_cov_file_url }} + steps: + - name: Print current runner name + run: | + echo "Current runner name: ${{ runner.name }}" + - name: Code Checkout + env: + docker_image: ${{ inputs.DOCKER_IMAGE }} + fd_archive_url: ${{ inputs.FASTDEPLOY_ARCHIVE_URL }} + run: | + REPO="https://github.com/${{ github.repository }}.git" + FULL_REPO="${{ github.repository }}" + REPO_NAME="${FULL_REPO##*/}" + BASE_BRANCH="${{ github.base_ref }}" + # Clean the repository directory before starting + docker run --rm --net=host -v $(pwd):/workspace -w /workspace \ + -e "REPO_NAME=${REPO_NAME}" \ + -e "BASE_BRANCH=${BASE_BRANCH}" \ + -e "fd_archive_url=${fd_archive_url}" \ + ${docker_image} /bin/bash -c ' + if [ -d ${REPO_NAME} ]; then + echo "Directory ${REPO_NAME} exists, removing it..." + rm -rf ${REPO_NAME} + fi + wget -q ${fd_archive_url} + tar -xf FastDeploy.tar.gz + rm -rf FastDeploy.tar.gz + set -x + cd FastDeploy + git config --global --add safe.directory "$(pwd)" + git config --global user.name "FastDeployCI" + git config --global user.email "fastdeploy_ci@example.com" + git log -n 3 --oneline + ' + - name: Run CI unittest + id: set_output + env: + docker_image: ${{ inputs.DOCKER_IMAGE }} + IS_PR: ${{ github.event_name == 'pull_request' }} + run: | + runner_name="${{ runner.name }}" + last_char="${runner_name: -1}" + if [[ "$last_char" == "1" ]]; then + xpu_id="4" + else + xpu_id="0" + fi + FD_API_PORT=$((8180 + xpu_id * 100)) + FD_ENGINE_QUEUE_PORT=$((8150 + xpu_id * 100)) + FD_METRICS_PORT=$((8170 + xpu_id * 100)) + commit_id=${{ github.event.pull_request.head.sha }} + pr_num=${{ github.event.pull_request.number }} + PARENT_DIR=$(dirname "$WORKSPACE") + echo "PARENT_DIR:$PARENT_DIR" + docker run --rm --net=host --cap-add=SYS_PTRACE --privileged --shm-size=64G \ + -v $(pwd):/workspace -w /workspace \ + -v "/ssd3:/ssd3" \ + -e "MODEL_PATH=/ssd3/model" \ + -e "http_proxy=$(git config --global --get http.proxy)" \ + -e "https_proxy=$(git config --global --get https.proxy)" \ + -e "no_proxy=bcebos.com,mirrors.tuna.tsinghua.edu.cn,127.0.0.1,localhost" \ + -e "FD_API_PORT=${FD_API_PORT}" \ + -e "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}" \ + -e "FD_METRICS_PORT=${FD_METRICS_PORT}" \ + -e "XPU_ID=${xpu_id}" \ + -e "IS_PR=${IS_PR}" \ + -e "commit_id=${commit_id}" \ + -e "pr_num=${pr_num}" \ + ${docker_image} /bin/bash -c ' + git config --global --add safe.directory /workspace/FastDeploy + chown -R $(whoami) /workspace/FastDeploy + cd FastDeploy + python -m pip install coverage + export COVERAGE_FILE=/workspace/FastDeploy/coveragedata/.coverage.xpu + export COVERAGE_RCFILE=/workspace/FastDeploy/scripts/.coveragerc + TEST_EXIT_CODE=0 + bash scripts/run_ci_xpu.sh || TEST_EXIT_CODE=8 + echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> exit_code.env + cat exit_code.env + tar -cvf xpu_coverage.tar -C coveragedata . + coverage combine coveragedata/ || echo "No data to combine" + coverage report + # coverage data upload + target_path=paddle-github-action/PR/FastDeploy/${pr_num}/${commit_id}/XPU + wget -q --no-proxy --no-check-certificate https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddlePaddle/PaddleTest/tools/bos_tools.py -O bos_tools.py + push_file=$(realpath bos_tools.py) + python -m pip install bce-python-sdk==0.9.29 + cov_file="xpu_coverage.tar" + if [ -f ${cov_file} ];then + python ${push_file} ${cov_file} ${target_path}/CoverageData + target_path_stripped="${target_path#paddle-github-action/}" + XPU_COV_FILE_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${cov_file} + echo "xpu_cov_file_url=${XPU_COV_FILE_URL}" >> github.output + fi + ' + if [ -f FastDeploy/github.output ];then + cat FastDeploy/github.output >> $GITHUB_OUTPUT + fi + if [ -f FastDeploy/exit_code.env ]; then + cat FastDeploy/exit_code.env >> $GITHUB_ENV + source FastDeploy/exit_code.env + fi + exit "$TEST_EXIT_CODE" diff --git a/.github/workflows/_coverage_combine.yml b/.github/workflows/_coverage_combine.yml new file mode 100644 index 00000000000..66e03ee0477 --- /dev/null +++ b/.github/workflows/_coverage_combine.yml @@ -0,0 +1,108 @@ +name: Coverage Combine +description: "Coverage Combine And Check" + +on: + workflow_call: + inputs: + GPU_COV_FILE_URL: + description: "URL of the compressed GPU Coverage Data archive." + required: true + type: string + XPU_COV_FILE_URL: + description: "URL of the compressed GPU Coverage Data archive." + required: true + type: string + CACHE_DIR: + description: "Cache Dir Use" + required: false + type: string + default: "" + secrets: + github-token: + required: true + + +jobs: + coverage_combine: + name: Coverage Combine And Check + env: + gpu_cov_file_url: ${{ inputs.GPU_COV_FILE_URL }} + xpu_cov_file_url: ${{ inputs.XPU_COV_FILE_URL }} + IS_PR: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + steps: + - name: Clone FastDeploy + uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + submodules: recursive + fetch-depth: 0 + - name: Fetch base branch + if: ${{ github.event_name == 'pull_request' }} + run: | + git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1000 + # 找到最后共同节点 + MERGE_BASE=$(git merge-base origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.sha }}) + # 生成 diff 文件 + git diff ${MERGE_BASE} ${{ github.event.pull_request.head.sha }} --unified=0 > diff.txt + cat diff.txt + - name: Python Setup + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: coverage file download and combine + shell: bash + env: + BASE_REF: ${{ github.event.pull_request.base.ref }} + run: | + git log -n 3 + python -m pip install coverage diff-cover + mkdir coveragedata + if [ -z "${gpu_cov_file_url}" ]; then + echo "No diff coverage file URL provided." + else + wget -q ${gpu_cov_file_url} + gpu_cov_file=$(basename "$gpu_cov_file_url") + tar -xf ${gpu_cov_file} -C coveragedata + fi + if [ -z "${xpu_cov_file_url}" ]; then + echo "No diff coverage file URL provided." + else + wget -q ${xpu_cov_file_url} + xpu_cov_file=$(basename "$xpu_cov_file_url") + tar -xf ${xpu_cov_file} -C coveragedata + fi + export COVERAGE_FILE=coveragedata/.coverage + export COVERAGE_RCFILE=./scripts/.coveragerc + export COVERAGE_IGNORE_ERRORS=True + coverage combine coveragedata/ + coverage report --ignore-errors + coverage xml -o python_coverage_all.xml --ignore-errors + COVERAGE_EXIT_CODE=0 + set -x + if [[ "$IS_PR" == "true" ]]; then + diff-cover python_coverage_all.xml --diff-file=diff.txt --fail-under=80 --json-report diff_coverage.json || COVERAGE_EXIT_CODE=9 + python scripts/generate_diff_coverage_xml.py diff.txt python_coverage_all.xml + filename=diff_coverage.json + else + echo "Not a PR, skipping diff-cover" + fi + if [[ -f diff_coverage.json ]]; then + echo "====== Diff Coverage JSON ======" + if command -v jq >/dev/null 2>&1; then + jq . diff_coverage.json + else + cat diff_coverage.json + fi + echo "================================" + fi + exit "$COVERAGE_EXIT_CODE" + - name: Upload diff coverage report + if: always() && hashFiles('diff_coverage.xml') != '' + uses: codecov/codecov-action@v5 + with: + files: ./diff_coverage.xml + codecov_yml_path: ./scripts/codecov.yml + name: python diff coverage + verbose: true + flags: diff diff --git a/.github/workflows/_unit_test_coverage.yml b/.github/workflows/_unit_test_coverage.yml index d46bee316b5..77669895df9 100644 --- a/.github/workflows/_unit_test_coverage.yml +++ b/.github/workflows/_unit_test_coverage.yml @@ -27,6 +27,10 @@ on: required: false type: string default: "" + outputs: + gpu_cov_file_url: + description: "Output path of the GPU tests" + value: ${{ jobs.run_tests_with_coverage.outputs.gpu_cov_file_url }} secrets: github-token: required: true @@ -44,9 +48,8 @@ jobs: timeout-minutes: 90 needs: check_cov_skip outputs: - diff_cov_file_url: ${{ steps.cov_upload.outputs.diff_cov_file_url }} + gpu_cov_file_url: ${{ steps.cov_upload.outputs.gpu_cov_file_url }} unittest_failed_url: ${{ steps.cov_upload.outputs.unittest_failed_url }} - diff_cov_result_json_url: ${{ steps.cov_upload.outputs.diff_cov_result_json_url }} steps: - name: Code Prepare shell: bash @@ -189,114 +192,47 @@ jobs: else echo "Warning: tests/plugins directory not found, skipping setup.py install" fi - export COVERAGE_FILE=/workspace/FastDeploy/coveragedata/.coverage + export COVERAGE_FILE=/workspace/FastDeploy/coveragedata/.coverage.gpu export COVERAGE_RCFILE=/workspace/FastDeploy/scripts/.coveragerc TEST_EXIT_CODE=0 bash scripts/coverage_run.sh || TEST_EXIT_CODE=8 echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> exit_code.env + tar -cvf gpu_coverage.tar -C coveragedata . coverage combine coveragedata/ || echo "No data to combine" coverage report - coverage xml -o python_coverage_all.xml - COVERAGE_EXIT_CODE=0 - if [[ "$IS_PR" == "true" ]]; then - echo "Running diff coverage for PR..." - diff-cover python_coverage_all.xml --diff-file=diff.txt --fail-under=80 --json-report diff_coverage.json || COVERAGE_EXIT_CODE=9 - python scripts/generate_diff_coverage_xml.py diff.txt python_coverage_all.xml - else - echo "Running full coverage" - coverage report -m > full_coverage_report.txt - python scripts/generate_full_coverage_csv.py full_coverage_report.txt full_coverage_report.csv - fi - echo "COVERAGE_EXIT_CODE=${COVERAGE_EXIT_CODE}" >> exit_code.env ' if [ -f FastDeploy/exit_code.env ]; then cat FastDeploy/exit_code.env >> $GITHUB_ENV fi - - name: Upload coverage and unit test results to BOS + + - name: Upload unit resule and diff coverage to bos id: cov_upload shell: bash - env: - IS_PR: ${{ github.event_name == 'pull_request' }} - GITHUB_SHA: ${{ github.sha }} - BRANCH: ${{ github.ref_name }} - PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} - PR_NUMBER: ${{ github.event.pull_request.number }} run: | cd FastDeploy - python -m pip install -q bce-python-sdk==0.9.29 - wget -q --no-proxy --no-check-certificate \ - https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddlePaddle/PaddleTest/tools/bos_tools.py \ - -O bos_tools.py + commit_id=${{ github.event.pull_request.head.sha }} + pr_num=${{ github.event.pull_request.number }} + target_path=paddle-github-action/PR/FastDeploy/${pr_num}/${commit_id}/GPU + wget -q --no-proxy --no-check-certificate https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddlePaddle/PaddleTest/tools/bos_tools.py -O bos_tools.py push_file=$(realpath bos_tools.py) - - if [[ "$IS_PR" == "true" ]]; then - commit_id=${PR_COMMIT_SHA} - pr_num=${PR_NUMBER} - target_path=paddle-github-action/PR/FastDeploy/${pr_num}/${commit_id}/SM${compile_arch//,/_} - elif [[ "${{ github.ref_type }}" == "tag" ]]; then - commit_id=${{ github.sha }} - tag_name=${{ github.ref_name }} - target_path=paddle-github-action/TAG/FastDeploy/${tag_name}/${commit_id}/SM${compile_arch//,/_} - target_path_latest=paddle-github-action/TAG/FastDeploy/${tag_name}/latest/SM${compile_arch//,/_} - target_path_stripped_latest="${target_path_latest#paddle-github-action/}" - else - commit_id=${{ github.sha }} - branch_name=${{ github.ref_name }} - target_path=paddle-github-action/BRANCH/FastDeploy/${branch_name}/${commit_id}/SM${compile_arch//,/_} - target_path_latest=paddle-github-action/BRANCH/FastDeploy/${branch_name}/latest/SM${compile_arch//,/_} - target_path_stripped_latest="${target_path_latest#paddle-github-action/}" + python -m pip install bce-python-sdk==0.9.29 + cov_file="gpu_coverage.tar" + if [ -f ${cov_file} ];then + python ${push_file} ${cov_file} ${target_path}/CoverageData + target_path_stripped="${target_path#paddle-github-action/}" + GPU_COV_FILE_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${cov_file} + echo "gpu_cov_file_url=${GPU_COV_FILE_URL}" >> $GITHUB_OUTPUT fi - target_path_stripped="${target_path#paddle-github-action/}" - - if [[ "$IS_PR" == "true" ]]; then - diff_cov_file="diff_coverage.xml" - if [ -f ${diff_cov_file} ]; then - python ${push_file} ${diff_cov_file} ${target_path}/CoverageData - DIFF_COV_FILE_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${diff_cov_file} - echo "diff_cov_file_url=${DIFF_COV_FILE_URL}" >> $GITHUB_OUTPUT - echo "diff_cov_file_url=${DIFF_COV_FILE_URL}" >> $GITHUB_ENV - fi - - diff_cov_result_json="diff_coverage.json" - if [ -f ${diff_cov_result_json} ]; then - python ${push_file} ${diff_cov_result_json} ${target_path}/CoverageData - DIFF_COV_JSON_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${diff_cov_result_json} - echo "diff_cov_result_json_url=${DIFF_COV_JSON_URL}" >> $GITHUB_OUTPUT - echo "diff_cov_result_json_url=${DIFF_COV_JSON_URL}" >> $GITHUB_ENV - fi - fi - - HAS_FAILED_TESTS=false unittest_result="failed_tests.log" - if [ -s ${unittest_result} ]; then - HAS_FAILED_TESTS=true + if [ -s ${unittest_result} ];then python ${push_file} ${unittest_result} ${target_path}/UnitTestResult + target_path_stripped="${target_path#paddle-github-action/}" UNIT_TEST_RESULT_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/UnitTestResult/${unittest_result} echo "unittest_failed_url=${UNIT_TEST_RESULT_URL}" >> $GITHUB_OUTPUT echo "unittest_failed_url=${UNIT_TEST_RESULT_URL}" >> $GITHUB_ENV fi - if [[ "$IS_PR" != "true" ]]; then - full_cov_file="full_coverage_report.txt" - full_cov_csv="full_coverage_report.csv" - - if [ -f ${full_cov_file} ]; then - python ${push_file} ${full_cov_file} ${target_path}/CoverageData - python ${push_file} ${full_cov_file} ${target_path_latest}/CoverageData - FULL_COV_FILE_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${full_cov_file} - echo "full_coverage_report_url=${FULL_COV_FILE_URL}" >> $GITHUB_OUTPUT - echo "full_coverage_report_url=${FULL_COV_FILE_URL}" >> $GITHUB_ENV - fi - - if [ "$HAS_FAILED_TESTS" = false ] && [ -f ${full_cov_csv} ]; then - python ${push_file} ${full_cov_csv} ${target_path}/CoverageData - python ${push_file} ${full_cov_csv} ${target_path_latest}/CoverageData - FULL_COV_CSV_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${full_cov_csv} - echo "full_coverage_csv_url=${FULL_COV_CSV_URL}" >> $GITHUB_OUTPUT - echo "full_coverage_csv_url=${FULL_COV_CSV_URL}" >> $GITHUB_ENV - fi - fi - name: Check Unit Test Success shell: bash run: | @@ -317,62 +253,3 @@ jobs: exit "$TEST_EXIT_CODE" fi echo "All tests passed" - - - name: Verify Code Coverage Threshold (80%) - if: ${{ github.event_name == 'pull_request' && (needs.check_cov_skip.outputs['can-skip'] != 'true') }} - shell: bash - run: | - cd FastDeploy - if [ "$COVERAGE_EXIT_CODE" -eq 9 ]; then - echo "Coverage generation failed (exit code 9)" - filename=$(basename "$diff_cov_result_json_url") - if [ -z "${diff_cov_result_json_url}" ]; then - echo "No diff cov result file URL provided." - else - rm -rf "${filename}" - wget -O ${filename} ${diff_cov_result_json_url} || echo "Download cov json file failed, but continuing..." - fi - if [ -f "${filename}" ];then - echo "Failed test cases:" - if command -v jq >/dev/null 2>&1; then - jq . "${filename}" - else - cat "${filename}" - fi - fi - exit "$COVERAGE_EXIT_CODE" - fi - echo "coverage passed" - exit 0 - - diff_coverage_report: - needs: run_tests_with_coverage - if: always() - runs-on: ubuntu-latest - timeout-minutes: 15 - env: - fd_archive_url: ${{ inputs.FASTDEPLOY_ARCHIVE_URL }} - steps: - - name: coverage diff file download - shell: bash - env: - diff_cov_file_url: ${{ needs.run_tests_with_coverage.outputs.diff_cov_file_url }} - run: | - wget -q --no-proxy ${fd_archive_url} - tar -xf FastDeploy.tar.gz - cd FastDeploy - if [ -z "${diff_cov_file_url}" ]; then - echo "No diff coverage file URL provided." - exit 0 - fi - wget "${diff_cov_file_url}" -O ./diff_coverage.xml || echo "Download cov file failed, but continuing..." - - name: Upload diff coverage report - 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 - with: - files: ./FastDeploy/diff_coverage.xml - name: python diff coverage - verbose: true - disable_search: true - commit_parent: false - flags: diff diff --git a/.github/workflows/ci_xpu.yml b/.github/workflows/ci_xpu.yml deleted file mode 100644 index 752a38e62c3..00000000000 --- a/.github/workflows/ci_xpu.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI_XPU - -on: - pull_request: - branches: - - develop - - 'release/*' - paths-ignore: - - '**.md' - - '**.txt' - workflow_dispatch: - -concurrency: - group: ${{ github.event.pull_request.number }}-xpu-ci - cancel-in-progress: true - -jobs: - CI_XPU: - runs-on: [self-hosted, XPU-P800-8Card] - steps: - - name: Print current runner name - run: | - echo "Current runner name: ${{ runner.name }}" - # Because the system version is lower than 2.23, the checkout cannot be used. - # - name: Checkout code - # uses: actions/checkout@v4 - - - name: Code Checkout - env: - docker_image: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/fastdeploy-xpu:2.2.0 - run: | - REPO="https://github.com/${{ github.repository }}.git" - FULL_REPO="${{ github.repository }}" - REPO_NAME="${FULL_REPO##*/}" - BASE_BRANCH="${{ github.base_ref }}" - # Clean the repository directory before starting - docker run --rm --net=host -v $(pwd):/workspace -w /workspace \ - -e "REPO_NAME=${REPO_NAME}" \ - -e "BASE_BRANCH=${BASE_BRANCH}" \ - ${docker_image} /bin/bash -c ' - if [ -d ${REPO_NAME} ]; then - echo "Directory ${REPO_NAME} exists, removing it..." - rm -rf ${REPO_NAME} - fi - ' - git config --global user.name "FastDeployCI" - git config --global user.email "fastdeploy_ci@example.com" - git clone ${REPO} ${REPO_NAME} -b ${BASE_BRANCH} - cd FastDeploy - if [ "${{ github.event_name }}" = "pull_request" ]; then - git fetch origin pull/${{ github.event.pull_request.number }}/head:pr/${{ github.event.pull_request.number }} - git merge pr/${{ github.event.pull_request.number }} - git log -n 3 --oneline - else - git checkout ${{ github.sha }} - git log -n 3 --oneline - fi - - - name: Run CI unittest - env: - docker_image: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/fastdeploy-xpu:2.2.0 - run: | - runner_name="${{ runner.name }}" - last_char="${runner_name: -1}" - - if [[ "$last_char" == "1" ]]; then - xpu_id="4" - else - xpu_id="0" - fi - PARENT_DIR=$(dirname "$WORKSPACE") - echo "PARENT_DIR:$PARENT_DIR" - docker run --rm --net=host --cap-add=SYS_PTRACE --privileged --shm-size=64G \ - -v $(pwd):/workspace -w /workspace \ - -v "/ssd3:/ssd3" \ - -e "MODEL_PATH=/ssd3/model" \ - -e "http_proxy=$(git config --global --get http.proxy)" \ - -e "https_proxy=$(git config --global --get https.proxy)" \ - -e "no_proxy=bcebos.com,mirrors.tuna.tsinghua.edu.cn,127.0.0.1,localhost" \ - -e "XPU_ID=${xpu_id}" \ - ${docker_image} /bin/bash -c " - git config --global --add safe.directory /workspace/FastDeploy - cd FastDeploy - bash scripts/run_ci_xpu.sh - " diff --git a/.github/workflows/pr_build_and_test.yml b/.github/workflows/pr_build_and_test.yml index 620bf9fc40d..bdeca4bb8dd 100644 --- a/.github/workflows/pr_build_and_test.yml +++ b/.github/workflows/pr_build_and_test.yml @@ -34,8 +34,8 @@ jobs: run: | echo "The built wheel is located at: ${{ needs.build.outputs.wheel_path }}" - unittest_coverage: - name: Run FastDeploy Unit Tests and Coverage + gpu_unittest: + name: Run FastDeploy Unit Tests with Coverage needs: [clone,build] uses: ./.github/workflows/_unit_test_coverage.yml with: @@ -75,3 +75,21 @@ jobs: FASTDEPLOY_ARCHIVE_URL: ${{ needs.clone.outputs.repo_archive_url }} FASTDEPLOY_WHEEL_URL: ${{ needs.build.outputs.wheel_path }} MODEL_CACHE_DIR: "/ssd2/actions-runner/ModelData" + + xpu_unittest: + name: Run XPU Test with Coverage + needs: [ clone ] + uses: ./.github/workflows/_ci_xpu.yml + with: + DOCKER_IMAGE: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/fastdeploy-xpu-ci:latest + FASTDEPLOY_ARCHIVE_URL: ${{ needs.clone.outputs.repo_archive_url }} + + coverage_combine: + name: Coverage Combine And Check + uses: ./.github/workflows/_coverage_combine.yml + needs: [ clone, gpu_unittest, xpu_unittest ] + with: + GPU_COV_FILE_URL: ${{ needs.gpu_unittest.outputs.gpu_cov_file_url }} + XPU_COV_FILE_URL: ${{ needs.xpu_unittest.outputs.xpu_cov_file_url }} + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/.coveragerc b/scripts/.coveragerc index a56d4520561..7a3f313b2a4 100644 --- a/scripts/.coveragerc +++ b/scripts/.coveragerc @@ -22,3 +22,5 @@ omit = */fastdeploy/model_executor/graph_optimization/utils.py */fastdeploy/model_executor/ops/gpu/fastdeploy_ops.py */fastdeploy/model_executor/ops/gpu/deep_gemm/utils.py + +ignore_errors = True \ No newline at end of file diff --git a/scripts/codecov.yml b/scripts/codecov.yml new file mode 100644 index 00000000000..29ffcf6b61e --- /dev/null +++ b/scripts/codecov.yml @@ -0,0 +1,5 @@ +codecov: + require_ci_to_pass: false + +fixes: + - "/workspace/FastDeploy::/home/runner/work/FastDeploy/FastDeploy/FastDeploy" diff --git a/scripts/run_ci_xpu.sh b/scripts/run_ci_xpu.sh index 5807fa6c4e9..4a5fe6a1b8d 100644 --- a/scripts/run_ci_xpu.sh +++ b/scripts/run_ci_xpu.sh @@ -2,6 +2,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" echo "$DIR" +export COVERAGE_RCFILE=${COVERAGE_RCFILE:-$DIR/../scripts/.coveragerc} #安装lsof工具 apt install -y lsof @@ -50,6 +51,7 @@ export CLANG_PATH=$(pwd)/custom_ops/xpu_ops/third_party/xtdk export XVLLM_PATH=$(pwd)/custom_ops/xpu_ops/third_party/xvllm bash build.sh || exit 1 +export PYTHONPATH=./:${PYTHONPATH} echo "pip others" python -m pip install openai -U python -m pip uninstall -y triton @@ -75,7 +77,7 @@ else export XPU_VISIBLE_DEVICES="4,5,6,7" fi export port_num=$((8188 + XPU_ID * 100)) -python -m fastdeploy.entrypoints.openai.api_server \ +python -m coverage run -m fastdeploy.entrypoints.openai.api_server \ --model ${MODEL_PATH}/ERNIE-4.5-300B-A47B-Paddle \ --port $port_num \ --engine-worker-queue-port $((port_num + 1)) \ @@ -122,7 +124,7 @@ done # 执行服务化推理 -python -m pytest -s tests/ci_use/XPU_45T/run_45T.py +python -m coverage run -m pytest -s tests/ci_use/XPU_45T/run_45T.py kv_block_test_exit_code=$? echo kv_block_test_exit_code is ${kv_block_test_exit_code} @@ -151,7 +153,7 @@ else export XPU_VISIBLE_DEVICES="4,5,6,7" fi export port_num=$((8188 + XPU_ID * 100)) -python -m fastdeploy.entrypoints.openai.api_server \ +python -m coverage run -m fastdeploy.entrypoints.openai.api_server \ --model ${MODEL_PATH}/ERNIE-4.5-300B-A47B-W4A8C8-TP4-Paddle \ --port $port_num \ --engine-worker-queue-port $((port_num + 1)) \ @@ -198,7 +200,7 @@ done # 执行服务化推理 -python -m pytest -s tests/ci_use/XPU_45T/run_w4a8.py +python -m coverage run -m pytest -s tests/ci_use/XPU_45T/run_w4a8.py w4a8_test_exit_code=$? echo w4a8_test_exit_code is ${w4a8_test_exit_code} @@ -227,7 +229,7 @@ else export XPU_VISIBLE_DEVICES="4,5,6,7" fi export port_num=$((8188 + XPU_ID * 100)) -python -m fastdeploy.entrypoints.openai.api_server \ +python -m coverage run -m fastdeploy.entrypoints.openai.api_server \ --model ${MODEL_PATH}/ERNIE-4.5-VL-28B-A3B-Paddle \ --port $port_num \ --engine-worker-queue-port $((port_num + 1)) \ @@ -277,7 +279,7 @@ done # 执行服务化推理 -python -m pytest -s tests/ci_use/XPU_45T/run_45vl.py +python -m coverage run -m pytest -s tests/ci_use/XPU_45T/run_45vl.py vl_test_exit_code=$? echo vl_test_exit_code is ${vl_test_exit_code} @@ -322,7 +324,7 @@ cd - export port_num=$((8188 + XPU_ID * 100)) # 启动服务 -python -m fastdeploy.entrypoints.openai.api_server \ +python -m coverage run -m fastdeploy.entrypoints.openai.api_server \ --model ${MODEL_PATH}/ERNIE-4.5-300B-A47B-Paddle \ --port $port_num \ --tensor-parallel-size 4 \ @@ -368,7 +370,7 @@ done # 执行在线推理验证脚本 -python -m pytest -s tests/ci_use/XPU_45T/run_ep_online.py +python -m coverage run -m pytest -s tests/ci_use/XPU_45T/run_ep_online.py ep_online_exit_code=$? echo ep_online_exit_code is ${ep_online_exit_code} @@ -411,7 +413,7 @@ export BKCL_RDMA_VERBS=1 export port_num=$((8188 + XPU_ID * 100)) # 启动服务 -python -m fastdeploy.entrypoints.openai.api_server \ +python -m coverage run -m fastdeploy.entrypoints.openai.api_server \ --model ${MODEL_PATH}/ERNIE-4.5-300B-A47B-Paddle \ --port $port_num \ --tensor-parallel-size 1 \ @@ -454,7 +456,7 @@ done # 执行在线推理验证脚本 -python -m pytest -s tests/ci_use/XPU_45T/run_ep_online.py +python -m coverage run -m pytest -s tests/ci_use/XPU_45T/run_ep_online.py ep_online_exit_code=$? echo ep_online_exit_code is ${ep_online_exit_code} @@ -498,7 +500,7 @@ export BKCL_RDMA_VERBS=1 export port_num=$((8188 + XPU_ID * 100)) # 启动服务 -python -m fastdeploy.entrypoints.openai.api_server \ +python -m coverage run -m fastdeploy.entrypoints.openai.api_server \ --model ${MODEL_PATH}/ERNIE-4.5-300B-A47B-Paddle \ --port $port_num \ --tensor-parallel-size 4 \ @@ -543,7 +545,7 @@ done # 执行在线推理验证脚本 -python -m pytest -s tests/ci_use/XPU_45T/run_ep_online.py +python -m coverage run -m pytest -s tests/ci_use/XPU_45T/run_ep_online.py ep_online_exit_code=$? echo ep_online_exit_code is ${ep_online_exit_code}