|
| 1 | +name: Base Test |
| 2 | +description: "Run Base Tests" |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + DOCKER_IMAGE: |
| 8 | + description: "Build Images" |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + default: "ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddleqa:cuda126-py310" |
| 12 | + FASTDEPLOY_ARCHIVE_URL: |
| 13 | + description: "URL of the compressed FastDeploy code archive." |
| 14 | + required: true |
| 15 | + type: string |
| 16 | + FASTDEPLOY_WHEEL_URL: |
| 17 | + description: "URL of the FastDeploy Wheel." |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + CACHE_DIR: |
| 21 | + description: "Cache Dir Use" |
| 22 | + required: false |
| 23 | + type: string |
| 24 | + default: "" |
| 25 | + MODEL_CACHE_DIR: |
| 26 | + description: "Cache Dir Use" |
| 27 | + required: false |
| 28 | + type: string |
| 29 | + default: "" |
| 30 | + |
| 31 | +jobs: |
| 32 | + base_tests: |
| 33 | + runs-on: [self-hosted, GPU-h20-1Cards] |
| 34 | + steps: |
| 35 | + - name: Code Prepare |
| 36 | + shell: bash |
| 37 | + env: |
| 38 | + docker_image: ${{ inputs.DOCKER_IMAGE }} |
| 39 | + fd_archive_url: ${{ inputs.FASTDEPLOY_ARCHIVE_URL }} |
| 40 | + run: | |
| 41 | + set -x |
| 42 | + REPO="https://github.com/${{ github.repository }}.git" |
| 43 | + FULL_REPO="${{ github.repository }}" |
| 44 | + REPO_NAME="${FULL_REPO##*/}" |
| 45 | + BASE_BRANCH="${{ github.base_ref }}" |
| 46 | +
|
| 47 | + # Clean the repository directory before starting |
| 48 | + docker run --rm --net=host -v $(pwd):/workspace -w /workspace \ |
| 49 | + -e "REPO_NAME=${REPO_NAME}" \ |
| 50 | + ${docker_image} /bin/bash -c ' |
| 51 | + if [ -d ${REPO_NAME} ]; then |
| 52 | + echo "Directory ${REPO_NAME} exists, removing it..." |
| 53 | + rm -rf ${REPO_NAME}* |
| 54 | + fi |
| 55 | + ' |
| 56 | +
|
| 57 | + wget -q ${fd_archive_url} |
| 58 | + tar -xf FastDeploy.tar.gz |
| 59 | + rm -rf FastDeploy.tar.gz |
| 60 | + cd FastDeploy |
| 61 | + git config --global user.name "FastDeployCI" |
| 62 | + git config --global user.email "[email protected]" |
| 63 | + git log -n 3 --oneline |
| 64 | +
|
| 65 | + - name: Run FastDeploy Base Tests |
| 66 | + shell: bash |
| 67 | + env: |
| 68 | + docker_image: ${{ inputs.DOCKER_IMAGE }} |
| 69 | + fastdeploy_wheel_url: ${{ inputs.FASTDEPLOY_WHEEL_URL }} |
| 70 | + CACHE_DIR: ${{ inputs.CACHE_DIR }} |
| 71 | + MODEL_CACHE_DIR: ${{ inputs.MODEL_CACHE_DIR }} |
| 72 | + run: | |
| 73 | + runner_name="${{ runner.name }}" |
| 74 | + last_char="${runner_name: -1}" |
| 75 | +
|
| 76 | + if [[ "$last_char" =~ [0-7] ]]; then |
| 77 | + DEVICES="$last_char" |
| 78 | + else |
| 79 | + DEVICES="0" |
| 80 | + fi |
| 81 | +
|
| 82 | + FLASK_PORT=$((42068 + DEVICES * 100)) |
| 83 | + FD_API_PORT=$((42088 + DEVICES * 100)) |
| 84 | + FD_ENGINE_QUEUE_PORT=$((42058 + DEVICES * 100)) |
| 85 | + FD_METRICS_PORT=$((42078 + DEVICES * 100)) |
| 86 | + echo "Test ENV Parameter:" |
| 87 | + echo "=========================================================" |
| 88 | + echo "FLASK_PORT=${FLASK_PORT}" |
| 89 | + echo "FD_API_PORT=${FD_API_PORT}" |
| 90 | + echo "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}" |
| 91 | + echo "FD_METRICS_PORT=${FD_METRICS_PORT}" |
| 92 | + echo "DEVICES=${DEVICES}" |
| 93 | + echo "=========================================================" |
| 94 | +
|
| 95 | + CACHE_DIR="${CACHE_DIR:-$(dirname "$(dirname "${{ github.workspace }}")")}" |
| 96 | + echo "CACHE_DIR is set to ${CACHE_DIR}" |
| 97 | + if [ ! -f "${CACHE_DIR}/gitconfig" ]; then |
| 98 | + touch "${CACHE_DIR}/gitconfig" |
| 99 | + fi |
| 100 | + if [ ! -d "${MODEL_CACHE_DIR}" ]; then |
| 101 | + echo "Error: MODEL_CACHE_DIR '${MODEL_CACHE_DIR}' does not exist." |
| 102 | + exit 1 |
| 103 | + fi |
| 104 | +
|
| 105 | + PARENT_DIR=$(dirname "$WORKSPACE") |
| 106 | +
|
| 107 | + docker run --rm --ipc=host --pid=host --net=host \ |
| 108 | + -v $(pwd):/workspace \ |
| 109 | + -w /workspace \ |
| 110 | + -e fastdeploy_wheel_url=${fastdeploy_wheel_url} \ |
| 111 | + -e "FD_API_PORT=${FD_API_PORT}" \ |
| 112 | + -e "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}" \ |
| 113 | + -e "FD_METRICS_PORT=${FD_METRICS_PORT}" \ |
| 114 | + -e "FLASK_PORT=${FLASK_PORT}" \ |
| 115 | + -v "${MODEL_CACHE_DIR}:/MODELDATA" \ |
| 116 | + -v "${CACHE_DIR}/gitconfig:/etc/gitconfig:ro" \ |
| 117 | + -v "${CACHE_DIR}/.cache:/root/.cache" \ |
| 118 | + -v "${CACHE_DIR}/ConfigDir:/root/.config" \ |
| 119 | + -e TZ="Asia/Shanghai" \ |
| 120 | + --gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -xc ' |
| 121 | + # python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/ |
| 122 | + python -m pip install paddlepaddle-gpu==3.0.0.dev20250729 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/ |
| 123 | +
|
| 124 | + pip config set global.index-url http://pip.baidu.com/root/baidu/+simple/ |
| 125 | + pip config set install.trusted-host pip.baidu.com |
| 126 | + pip config set global.extra-index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple |
| 127 | + python -m pip install ${fastdeploy_wheel_url} |
| 128 | + python -m pip install pytest |
| 129 | +
|
| 130 | + wget https://paddle-qa.bj.bcebos.com/zhengtianyu/tools/llm-deploy-linux-amd64 |
| 131 | + chmod +x ./llm-deploy-linux-amd64 |
| 132 | + ./llm-deploy-linux-amd64 -python python3.10 \ |
| 133 | + -model_name ERNIE-4.5-0.3B-Paddle \ |
| 134 | + -model_path /MODELDATA \ |
| 135 | + --skip install |
| 136 | +
|
| 137 | + git config --global --add safe.directory /workspace/FastDeploy |
| 138 | + cd FastDeploy |
| 139 | + pushd test/ce/deploy |
| 140 | + python3.10 deploy.py > dd.log 2>&1 & |
| 141 | + sleep 3 |
| 142 | + curl -X POST http://0.0.0.0:${FLASK_PORT}/start \ |
| 143 | + -H "Content-Type: application/json" \ |
| 144 | + -d "{\"--model\": \"/MODELDATA/ERNIE-4.5-0.3B-Paddle\"}" |
| 145 | +
|
| 146 | + curl -X POST http://localhost:${FLASK_PORT}/wait_for_infer?timeout=90 |
| 147 | + popd |
| 148 | +
|
| 149 | + pushd test/ce/server |
| 150 | + export URL=http://localhost:${FD_API_PORT}/v1/chat/completions |
| 151 | + export TEMPLATE=TOKEN_LOGPROB |
| 152 | + TEST_EXIT_CODE=0 |
| 153 | + python -m pytest -sv . || TEST_EXIT_CODE=$? |
| 154 | + popd |
| 155 | + echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> /workspace/FastDeploy/exit_code.env |
| 156 | + ' |
| 157 | + if [ -f ./FastDeploy/exit_code.env ]; then |
| 158 | + source ./FastDeploy/exit_code.env |
| 159 | + cat ./FastDeploy/exit_code.env >> $GITHUB_ENV |
| 160 | + fi |
| 161 | + echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" |
| 162 | + exit ${TEST_EXIT_CODE} |
0 commit comments