Files
2026-07-13 12:40:42 +08:00

202 lines
6.9 KiB
YAML

name: Linux-CPU
on:
workflow_call:
inputs:
docker_cpu_image:
type: string
required: true
clone-can-skip:
type: string
required: false
default: "false"
outputs:
can-skip:
description: "Whether to skip the job"
value: ${{ jobs.check-bypass.outputs.can-skip }}
env:
PR_ID: ${{ github.event.pull_request.number }}
COMMIT_ID: ${{ github.event.pull_request.head.sha }}
work_dir: /paddle
PADDLE_ROOT: /paddle
TASK: paddle-CI-${{ github.event.pull_request.number }}-cpu
ci_scripts: ${{ github.workspace }}/ci
BRANCH: ${{ github.event.pull_request.base.ref }}
CI_name: cpu
no_proxy: "bcebos.com,apiin.im.baidu.com,gitee.com,aliyun.com,.baidu.com,.tuna.tsinghua.edu.cn"
defaults:
run:
shell: bash
jobs:
check-bypass:
name: Check bypass
if: ${{ github.repository_owner == 'PaddlePaddle' }}
uses: ./.github/workflows/check-bypass.yml
with:
workflow-name: cpu
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
build-and-test:
name: Build and test
outputs:
can-skip: ${{ needs.check-bypass.outputs.can-skip || inputs.clone-can-skip || 'false' }}
needs: [check-bypass]
if: ${{ needs.check-bypass.outputs.can-skip != 'true' && inputs.clone-can-skip != 'true' }}
runs-on:
group: GZ_BD-CPU
timeout-minutes: 120
steps:
- name: Check docker image and run container
env:
WITH_GPU: "OFF"
WITH_SHARED_PHI: "ON"
WITH_MKL: "OFF"
WITH_TESTING: "ON"
COVERALLS_UPLOAD: "OFF"
GIT_PR_ID: ${{ github.event.pull_request.number }}
PADDLE_VERSION: 0.0.0
WITH_DISTRIBUTE: "ON"
PREC_SUFFIX: .py3
WITH_UNITY_BUILD: "ON"
PY_VERSION: "3.10"
PROC_RUN: 12
FLAGS_enable_eager_mode: 1
WITH_TENSORRT: "OFF"
GENERATOR: "Ninja"
CCACHE_MAXSIZE: 50G
CCACHE_LIMIT_MULTIPLE: 0.8
WITH_AVX: "OFF"
CACHE_DIR: "/root/.cache/cpu"
CCACHE_DIR: "/home/data/shared/.ccache/l1" # L1 cache on machine shared dir
CCACHE_SECONDARY_STORAGE: "file:///home/data/cfs/.ccache/l2" # L2 cache on cfs
WITH_OPENVINO: "ON"
run: |
container_name=${TASK}-$(date +%Y%m%d-%H%M%S)
echo "container_name=${container_name}" >> ${{ github.env }}
docker_image=${{ inputs.docker_cpu_image }}
docker run -d -t --name ${container_name} \
-v "/home/data/cfs:/home/data/cfs" \
-v "/home/data/cfs/.cache/python35-cpu:/root/.cache" \
-v "/home/data/shared:/home/data/shared" \
-v "/dev/shm:/dev/shm" \
-v ${{ github.workspace }}/../../..:${{ github.workspace }}/../../.. \
-v ${{ github.workspace }}:/paddle \
-e WITH_GPU \
-e BRANCH \
-e PR_ID \
-e COMMIT_ID \
-e work_dir \
-e PADDLE_ROOT \
-e WITH_SHARED_PHI \
-e WITH_MKL \
-e WITH_TESTING \
-e COVERALLS_UPLOAD \
-e GIT_PR_ID \
-e PADDLE_VERSION \
-e WITH_DISTRIBUTE \
-e PREC_SUFFIX \
-e WITH_UNITY_BUILD \
-e PY_VERSION \
-e PROC_RUN \
-e FLAGS_enable_eager_mode \
-e WITH_TENSORRT \
-e GENERATOR \
-e CCACHE_MAXSIZE \
-e CCACHE_LIMIT_MULTIPLE \
-e GITHUB_ENV \
-e ci_scripts \
-e WITH_AVX \
-e CACHE_DIR \
-e CCACHE_DIR \
-e CCACHE_SECONDARY_STORAGE \
-e CI_name \
-e no_proxy \
-e WITH_OPENVINO \
-w /paddle --network host ${docker_image}
- name: Download paddle.tar.gz and merge target branch
env:
work_dir: ${{ github.workspace }}
timeout-minutes: 30
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
rm -rf * .[^.]*
set -e
echo "Downloading Paddle.tar.gz"
wget -q --tries=5 --no-proxy https://paddle-github-action.bj.bcebos.com/PR/Paddle/${PR_ID}/${COMMIT_ID}/Paddle.tar.gz --no-check-certificate
echo "Extracting Paddle.tar.gz"
tar -xf Paddle.tar.gz --strip-components=1
rm Paddle.tar.gz
git config --global user.name "PaddleCI"
git config --global user.email "paddle_ci@example.com"
git remote -v
set +e
git remote add upstream https://github.com/PaddlePaddle/Paddle.git
set -e
source ${{ github.workspace }}/../../../proxy
cp ci/git_pull.sh ci/git_pull_copy.sh
git checkout $BRANCH
bash ci/git_pull_copy.sh $BRANCH
git fetch upstream $BRANCH
git checkout test
git merge --no-edit $BRANCH
git submodule update
'
- name: Build
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
source ${{ github.workspace }}/../../../proxy
bash ${ci_scripts}/cmake-predownload.sh
bash ${ci_scripts}/run_setup.sh bdist_wheel
EXCODE=$?
exit $EXCODE
'
- name: Test
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
source ${{ github.workspace }}/../../../proxy
bash ${ci_scripts}/run_linux_cpu_test.sh
EXCODE=$?
source ${ci_scripts}/utils.sh; clean_build_files
exit $EXCODE
'
- name: Upload paddle_whl
env:
home_path: ${{ github.workspace }}/..
bos_file: ${{ github.workspace }}/../bos/BosClient.py
paddle_whl: paddlepaddle-0.0.0-cp310-cp310-linux_x86_64.whl
run: |
docker exec -t ${{ env.container_name }} /bin/bash -c '
echo "::group::Install bce-python-sdk"
source ${{ github.workspace }}/../../../proxy
python -m pip install bce-python-sdk==0.8.74
echo "::endgroup::"
export AK=paddle
export SK=paddle
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
cd dist
echo "Uploading paddle_whl to bos"
source ${{ github.workspace }}/../../../unproxy
python3.10 ${{ env.bos_file }} ${{ env.paddle_whl }} paddle-github-action/PR/cpu_whl/${{ env.PR_ID }}/${{ env.COMMIT_ID }}
'
- name: Terminate and delete the container
if: always()
run: |
set +e
docker exec -t ${{ env.container_name }} /bin/bash -c 'rm -rf * .[^.]*'
docker stop ${{ env.container_name }}
docker rm ${{ env.container_name }}