|
| 1 | +name: CI_XPU |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + DOCKER_IMAGE: |
| 7 | + description: "Build Images" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + default: "ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/fastdeploy-xpu:2.1.0" |
| 11 | + FASTDEPLOY_ARCHIVE_URL: |
| 12 | + description: "URL of the compressed FastDeploy code archive." |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + outputs: |
| 16 | + xpu_cov_file_url: |
| 17 | + description: "Output path of the GPU tests" |
| 18 | + value: ${{ jobs.CI_XPU.outputs.xpu_cov_file_url }} |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.event.pull_request.number }}-xpu-ci |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + CI_XPU: |
| 26 | + runs-on: [self-hosted, XPU-P800-8Card] |
| 27 | + outputs: |
| 28 | + xpu_cov_file_url: ${{ steps.set_output.outputs.xpu_cov_file_url }} |
| 29 | + steps: |
| 30 | + - name: Print current runner name |
| 31 | + run: | |
| 32 | + echo "Current runner name: ${{ runner.name }}" |
| 33 | + - name: Code Checkout |
| 34 | + env: |
| 35 | + docker_image: ${{ inputs.DOCKER_IMAGE }} |
| 36 | + fd_archive_url: ${{ inputs.FASTDEPLOY_ARCHIVE_URL }} |
| 37 | + run: | |
| 38 | + REPO="https://github.com/${{ github.repository }}.git" |
| 39 | + FULL_REPO="${{ github.repository }}" |
| 40 | + REPO_NAME="${FULL_REPO##*/}" |
| 41 | + BASE_BRANCH="${{ github.base_ref }}" |
| 42 | + # Clean the repository directory before starting |
| 43 | + docker run --rm --net=host -v $(pwd):/workspace -w /workspace \ |
| 44 | + -e "REPO_NAME=${REPO_NAME}" \ |
| 45 | + -e "BASE_BRANCH=${BASE_BRANCH}" \ |
| 46 | + -e "fd_archive_url=${fd_archive_url}" \ |
| 47 | + ${docker_image} /bin/bash -c ' |
| 48 | + if [ -d ${REPO_NAME} ]; then |
| 49 | + echo "Directory ${REPO_NAME} exists, removing it..." |
| 50 | + rm -rf ${REPO_NAME} |
| 51 | + fi |
| 52 | + wget -q ${fd_archive_url} |
| 53 | + tar -xf FastDeploy.tar.gz |
| 54 | + rm -rf FastDeploy.tar.gz |
| 55 | + set -x |
| 56 | + cd FastDeploy |
| 57 | + git config --global --add safe.directory "$(pwd)" |
| 58 | + git config --global user.name "FastDeployCI" |
| 59 | + git config --global user.email "fastdeploy_ci@example.com" |
| 60 | + git log -n 3 --oneline |
| 61 | + ' |
| 62 | + - name: Run CI unittest |
| 63 | + id: set_output |
| 64 | + env: |
| 65 | + docker_image: ${{ inputs.DOCKER_IMAGE }} |
| 66 | + IS_PR: ${{ github.event_name == 'pull_request' }} |
| 67 | + run: | |
| 68 | + runner_name="${{ runner.name }}" |
| 69 | + last_char="${runner_name: -1}" |
| 70 | + if [[ "$last_char" == "1" ]]; then |
| 71 | + xpu_id="4" |
| 72 | + else |
| 73 | + xpu_id="0" |
| 74 | + fi |
| 75 | + FD_API_PORT=$((8180 + xpu_id * 100)) |
| 76 | + FD_ENGINE_QUEUE_PORT=$((8150 + xpu_id * 100)) |
| 77 | + FD_METRICS_PORT=$((8170 + xpu_id * 100)) |
| 78 | + commit_id=${{ github.event.pull_request.head.sha }} |
| 79 | + pr_num=${{ github.event.pull_request.number }} |
| 80 | + PARENT_DIR=$(dirname "$WORKSPACE") |
| 81 | + echo "PARENT_DIR:$PARENT_DIR" |
| 82 | + docker run --rm --net=host --cap-add=SYS_PTRACE --privileged --shm-size=64G \ |
| 83 | + -v $(pwd):/workspace -w /workspace \ |
| 84 | + -v "/ssd3:/ssd3" \ |
| 85 | + -e "MODEL_PATH=/ssd3/model" \ |
| 86 | + -e "http_proxy=$(git config --global --get http.proxy)" \ |
| 87 | + -e "https_proxy=$(git config --global --get https.proxy)" \ |
| 88 | + -e "no_proxy=bcebos.com,mirrors.tuna.tsinghua.edu.cn,127.0.0.1,localhost" \ |
| 89 | + -e "FD_API_PORT=${FD_API_PORT}" \ |
| 90 | + -e "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}" \ |
| 91 | + -e "FD_METRICS_PORT=${FD_METRICS_PORT}" \ |
| 92 | + -e "XPU_ID=${xpu_id}" \ |
| 93 | + -e "IS_PR=${IS_PR}" \ |
| 94 | + -e "commit_id=${commit_id}" \ |
| 95 | + -e "pr_num=${pr_num}" \ |
| 96 | + ${docker_image} /bin/bash -c ' |
| 97 | + git config --global --add safe.directory /workspace/FastDeploy |
| 98 | + chown -R $(whoami) /workspace/FastDeploy |
| 99 | + cd FastDeploy |
| 100 | + python -m pip install coverage |
| 101 | + export COVERAGE_FILE=/workspace/FastDeploy/coveragedata/.coverage.xpu |
| 102 | + export COVERAGE_RCFILE=/workspace/FastDeploy/scripts/.coveragerc |
| 103 | + TEST_EXIT_CODE=0 |
| 104 | + bash scripts/run_ci_xpu.sh || TEST_EXIT_CODE=8 |
| 105 | + echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> exit_code.env |
| 106 | + cat exit_code.env |
| 107 | + tar -cvf xpu_coverage.tar -C coveragedata . |
| 108 | + coverage combine coveragedata/ || echo "No data to combine" |
| 109 | + coverage report |
| 110 | + # coverage data upload |
| 111 | + target_path=paddle-github-action/PR/FastDeploy/${pr_num}/${commit_id}/XPU |
| 112 | + 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 |
| 113 | + push_file=$(realpath bos_tools.py) |
| 114 | + python -m pip install bce-python-sdk==0.9.29 |
| 115 | + cov_file="xpu_coverage.tar" |
| 116 | + if [ -f ${cov_file} ];then |
| 117 | + python ${push_file} ${cov_file} ${target_path}/CoverageData |
| 118 | + target_path_stripped="${target_path#paddle-github-action/}" |
| 119 | + XPU_COV_FILE_URL=https://paddle-github-action.bj.bcebos.com/${target_path_stripped}/CoverageData/${cov_file} |
| 120 | + echo "xpu_cov_file_url=${XPU_COV_FILE_URL}" >> github.output |
| 121 | + fi |
| 122 | + ' |
| 123 | + if [ -f FastDeploy/github.output ];then |
| 124 | + cat FastDeploy/github.output >> $GITHUB_OUTPUT |
| 125 | + fi |
| 126 | + if [ -f FastDeploy/exit_code.env ]; then |
| 127 | + cat FastDeploy/exit_code.env >> $GITHUB_ENV |
| 128 | + source FastDeploy/exit_code.env |
| 129 | + fi |
| 130 | + exit "$TEST_EXIT_CODE" |
0 commit comments