[Execute Infrastructure] Rename test_ai_* test files to test_coverage_* #8824
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unittest GPU CI | |
| on: | |
| pull_request: | |
| schedule: | |
| - cron: "0 18 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| pull-requests: read | |
| contents: read | |
| actions: read | |
| checks: read | |
| concurrency: | |
| group: unittest-${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| PR_ID: ${{ github.event.pull_request.number || '0' }} | |
| COMMIT_ID: ${{ github.event.pull_request.head.sha || github.sha }} | |
| BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }} | |
| AGILE_COMPILE_BRANCH: ${{ github.event.pull_request.base.ref }} | |
| work_dir: ${{ github.workspace }} | |
| CI_name: unittest-gpu-ci | |
| TASK: PaddleFormers_CI_unittest_gpu_${{ github.event.pull_request.number }} | |
| ci_scripts: /workspace/PaddleFormers/scripts/unit_test | |
| IMAGE_NAME: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddle:cuda129-dev | |
| python_version: 3.12 | |
| paddle_whl: https://paddle-qa.bj.bcebos.com/paddle-pipeline/Develop-TagBuild-Training-Linux-Gpu-Cuda12.9-Cudnn9.9-Trt10.5-Mkl-Avx-Gcc11-SelfBuiltPypiUse/latest/paddlepaddle_gpu-0.0.0-cp312-cp312-linux_x86_64.whl | |
| no_proxy: "localhost,bj.bcebos.com,su.bcebos.com,bcebos.com,apiin.im.baidu.com,gitee.com,aliyun.com,.baidu.com,.tuna.tsinghua.edu.cn" | |
| PYTEST_EXECUTE_FLAG_FILE: ${{ github.workspace }}/../../../PYTEST_EXECUTE_FLAG_FILE/${{ github.event.pull_request.number || '0' }}/${{ github.event.pull_request.head.sha || github.sha }}/pytest_execute.flag | |
| PYTEST_EXECUTE_FLAG: false | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| check-bypass: | |
| name: Check bypass | |
| if: ${{ inputs.can-skip != 'true' }} | |
| uses: ./.github/workflows/check-bypass.yml | |
| with: | |
| workflow-name: 'formers-unittest' | |
| secrets: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| check_skip: | |
| name: Check skip-unittest-ci label | |
| needs: check-bypass | |
| if: ${{ needs.check-bypass.outputs.can-skip == 'false' }} | |
| runs-on: 'ernie-cpu' | |
| outputs: | |
| skip: ${{ steps.check_skip.outputs.skip }} | |
| steps: | |
| - name: Check skip-unittest-ci label | |
| id: check_skip | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| labels='${{ toJson(github.event.pull_request.labels.*.name) }}' | |
| echo "PR labels: $labels" | |
| if echo "$labels" | grep -q "skip-unittest-ci"; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Skip CI but mark success | |
| if: steps.check_skip.outputs.skip == 'true' | |
| run: | | |
| echo "skip-unittest-ci label found" | |
| echo "Downstream GPU jobs will be skipped" | |
| unittest-gpu-ci: | |
| needs: check_skip | |
| if: needs.check_skip.outputs.skip == 'false' | |
| name: unittest-gpu-ci | |
| runs-on: 'ernie-unittest' | |
| outputs: | |
| pytest_execute_flag: ${{ steps.set_pytest_flag.outputs.pytest_execute_flag }} | |
| steps: | |
| - name: Determine the runner | |
| run: | | |
| gpu_id=$(( $(echo $PWD | awk -F'/' '{print $4}' | awk -F'_' '{print $2}') )) | |
| echo $PWD | |
| echo GPU_DEVICES="$gpu_id" >> $GITHUB_ENV | |
| - name: Run Container | |
| env: | |
| FLAGS_dynamic_static_unified_comm: "True" | |
| PIP_CACHE_DIR: /root/.cache/pip | |
| GPU_DEVICES: ${{ env.GPU_DEVICES }} | |
| run: | | |
| container_name=${TASK}-$(date +%Y%m%d-%H%M%S) | |
| echo "GPU_DEVICES=$GPU_DEVICES" | |
| echo "container_name=${container_name}" >> "$GITHUB_ENV" | |
| echo "Workspace path: ${{ github.workspace }}" | |
| docker run -d -t --name ${container_name} --gpus device=${GPU_DEVICES} --runtime=nvidia --net=host -v /dev/shm:/dev/shm --shm-size=32G \ | |
| -v $work_dir/../../..:$work_dir/../../.. \ | |
| -v $work_dir:/workspace \ | |
| -v /home/.cache/:/root/.cache/ \ | |
| -v /home/paddle-1/models/:/home/models/ \ | |
| -e PF_HOME=/home/models/ \ | |
| -e "work_dir=$work_dir" \ | |
| -e "PR_ID=$PR_ID" \ | |
| -e "BRANCH=$BRANCH" \ | |
| -e "COMMIT_ID=$COMMIT_ID" \ | |
| -e "AGILE_COMPILE_BRANCH=$AGILE_COMPILE_BRANCH" \ | |
| -e CUDA_VISIBLE_DEVICES=${GPU_DEVICES} \ | |
| -e NVIDIA_VISIBLE_DEVICES=${GPU_DEVICES} \ | |
| -e "ci_scripts=$ci_scripts" \ | |
| -e "PYTEST_EXECUTE_FLAG_FILE=$PYTEST_EXECUTE_FLAG_FILE" \ | |
| -e "no_proxy=$no_proxy" \ | |
| -e "paddle_whl=$paddle_whl" \ | |
| -e "FLAGS_dynamic_static_unified_comm=$FLAGS_dynamic_static_unified_comm" \ | |
| -e "python_version=$python_version" \ | |
| -e "HF_PROXY_PATH=$work_dir/../../../proxy_huggingface" \ | |
| -e "AISTUDIO_PROXY_PATH=$work_dir/../../../proxy_aistudio" \ | |
| -e "HF_DATASETS_CACHE=$work_dir/../../../paddlenlp/huggingface/datasets" \ | |
| -e "TRANSFORMERS_CACHE=$work_dir/../../../paddlenlp/huggingface" \ | |
| -e PIP_CACHE_DIR \ | |
| -w /workspace --privileged $IMAGE_NAME | |
| - name: Check GPU | |
| run: | | |
| docker exec $container_name nvidia-smi | |
| - name: Download Code | |
| run: | | |
| docker exec -t $container_name /bin/bash -c ' | |
| rm -rf * .[^.]* | |
| echo "Downloading PaddleFormers.tar" | |
| wget -q --no-proxy https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddleFormers.tar --no-check-certificate | |
| echo "Extracting PaddleFormers.tar" | |
| rm -rf PaddleFormers | |
| tar xf PaddleFormers.tar && rm -rf PaddleFormers.tar | |
| source $work_dir/../../../proxy | |
| cd PaddleFormers | |
| git config --global user.name "PaddleCI" | |
| git config --global user.email "paddle_ci@example.com" | |
| git pull | |
| git submodule update --init --recursive --force | |
| if [ -n "$PR_ID" ] && [ "$PR_ID" != "0" ]; then | |
| git fetch origin pull/${PR_ID}/head | |
| git checkout -b PR_${PR_ID} FETCH_HEAD | |
| git remote add upstream https://github.com/PaddlePaddle/PaddleFormers.git | |
| git fetch upstream ${BRANCH}:${BRANCH} | |
| git merge ${BRANCH} --no-edit | |
| git diff --numstat ${BRANCH} -- | awk "{print \$NF}" | |
| else | |
| echo "Not in a pull_request event. Skipping PR-specific operations." | |
| fi | |
| git log --pretty=oneline -10 | |
| ' | |
| - name: Change python version | |
| run: | | |
| docker exec -i -e "work_dir=$work_dir" -e "python_version=$python_version" $container_name /bin/bash <<-DOCKER_EOF | |
| echo "Change python version to $python_version" | |
| set -e | |
| cp /home/models/Miniforge3-Linux-x86_64.sh /tmp/miniforge.sh | |
| bash /tmp/miniforge.sh -b -p /opt/conda | |
| /opt/conda/bin/conda create -n py_\$python_version python=\$python_version -y \ | |
| --override-channels \ | |
| -c conda-forge | |
| . /opt/conda/etc/profile.d/conda.sh | |
| conda activate py_\$python_version | |
| python --version | |
| DOCKER_EOF | |
| - name: Test | |
| id: test | |
| run: | | |
| docker exec -t $container_name /bin/bash -c ' | |
| . /opt/conda/etc/profile.d/conda.sh | |
| conda activate py_$python_version | |
| python --version | |
| ldconfig | |
| mkdir -p /root/.cache/pip | |
| pip cache dir | |
| set -e | |
| rm -rf /root/.cache/aistudio/ | |
| cd /workspace/PaddleFormers && git config --global --add safe.directory $PWD | |
| source $work_dir/../../../proxy | |
| source $work_dir/../../../AISTUDIO_ACCESS_TOKEN | |
| bash -x scripts/unit_test/ci_unittest.sh ${paddle_whl} false ${PYTEST_EXECUTE_FLAG_FILE} ${AGILE_COMPILE_BRANCH} | |
| ' | |
| - name: Display Test Summary | |
| if: always() | |
| run: | | |
| file_success=${{ github.workspace }}/PaddleFormers/unittest_logs/unittest.log | |
| file_failed=${{ github.workspace }}/PaddleFormers/unittest_logs/unittest_FAIL.log | |
| if [[ "${{ steps.test.outcome }}" == "success" ]]; then | |
| echo "✅ Test passed successfully" | |
| tail -n 1 ${file_success} || true | |
| else | |
| echo "❌ Test failed with status: ${{ steps.test.outcome }}" | |
| grep "^FAILED tests" ${file_failed} | awk '{print $2}' | sort -u || true | |
| fi | |
| - name: Upload Products | |
| if: always() | |
| env: | |
| home_path: ${{ github.workspace }}/../../.. | |
| bos_file: ${{ github.workspace }}/../../../bos/BosClient.py | |
| java_file: ${{ github.workspace }}/../../../jdk1.8.0_351 | |
| allure_file: ${{ github.workspace }}/../../../allure-2.19.0/bin/allure | |
| run: | | |
| docker exec -t $container_name /bin/bash -c ' | |
| source ${work_dir}/../../../proxy_huggingface | |
| python -m pip install bce-python-sdk==0.8.74 -i https://pypi.org/simple | |
| if [ ! -f "${{ env.bos_file }}" ]; then | |
| wget -q --no-proxy -O ${{ env.home_path }}/bos_new.tar.gz https://xly-devops.bj.bcebos.com/home/bos_new.tar.gz --no-check-certificate | |
| mkdir ${{ env.home_path }}/bos | |
| tar xf ${{ env.home_path }}/bos_new.tar.gz -C ${{ env.home_path }}/bos | |
| fi | |
| if [ ! -f "${{ env.java_file }}" ]; then | |
| wget -q --no-proxy -O ${{ env.home_path }}/java_linux.tar.gz https://paddle-qa.bj.bcebos.com/java/java_linux.tar.gz --no-check-certificate | |
| tar xf ${{ env.home_path }}/java_linux.tar.gz | |
| fi | |
| if [ ! -f "${{ env.allure_file }}" ]; then | |
| wget -q --no-proxy -O ${{ env.home_path }}/allure-2.19.0.zip https://xly-devops.bj.bcebos.com/tools/allure-2.19.0.zip --no-check-certificate | |
| unzip -q ${{ env.home_path }}/allure-2.19.0.zip | |
| fi | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| bos_prefix="manual/${{ github.run_id }}" | |
| elif [[ "${{ github.event_name }}" == "schedule" ]]; then | |
| bos_prefix="schedule/${{ github.run_id }}" | |
| elif [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| bos_prefix="${PR_ID}/${COMMIT_ID}" | |
| fi | |
| # coverage.xml | |
| if [ -f "${PYTEST_EXECUTE_FLAG_FILE}" ]; then | |
| echo "PYTEST_EXECUTE_FLAG_FILE found, uploading coverage.xml." | |
| cd /workspace/PaddleFormers | |
| python ${{ env.bos_file }} coverage.xml paddle-github-action/PR/PaddleFormers/ci-unittest-gpu/${bos_prefix}/logs | |
| exit_code=$? | |
| if [ $exit_code -eq 0 ]; then | |
| echo "cov-report: https://paddle-github-action.bj.bcebos.com/PR/PaddleFormers/ci-unittest-gpu/${bos_prefix}/logs/coverage.xml" | |
| else | |
| echo "ERROR: Failed to upload $file (exit code: $exit_code)" | |
| fi | |
| else | |
| echo "PYTEST_EXECUTE_FLAG_FILE not found, skipping coverage.xml upload." | |
| fi | |
| # logs | |
| cd /workspace/PaddleFormers/unittest_logs | |
| for FILE in /workspace/PaddleFormers/unittest_logs/*; do | |
| file=$(basename "$FILE") | |
| python ${{ env.bos_file }} $file paddle-github-action/PR/PaddleFormers/ci-unittest-gpu/${bos_prefix}/logs | |
| exit_code=$? | |
| if [ $exit_code -eq 0 ]; then | |
| echo "$file: https://paddle-github-action.bj.bcebos.com/PR/PaddleFormers/ci-unittest-gpu/${bos_prefix}/logs/$file" | |
| else | |
| echo "ERROR: Failed to upload $file (exit code: $exit_code)" | |
| fi | |
| done | |
| ' | |
| - name: Set pytest execute flag output | |
| if: always() | |
| id: set_pytest_flag # 专门设置输出的步骤 | |
| run: | | |
| # 检查标志文件是否存在,并设置作业输出 | |
| if [ -f "${{ env.PYTEST_EXECUTE_FLAG_FILE }}" ]; then | |
| echo "pytest_execute_flag=true" >> $GITHUB_OUTPUT | |
| echo "PYTEST_EXECUTE_FLAG_FILE exists, setting flag to true" | |
| else | |
| echo "pytest_execute_flag=false" >> $GITHUB_OUTPUT | |
| echo "PYTEST_EXECUTE_FLAG_FILE does not exist, setting flag to false" | |
| fi | |
| - name: Terminate And Delete the Container | |
| if: always() | |
| run: | | |
| docker rm -f $container_name 2>/dev/null || true |