name: Linux-build on: workflow_call: inputs: docker_build_image: type: string required: true is_pr: type: string required: false default: "true" clone-can-skip: default: "false" required: false type: string outputs: can-skip: description: "Whether to skip the job" value: ${{ jobs.check-bypass.outputs.can-skip }} env: PR_ID: ${{ github.event.pull_request.number || '0' }} COMMIT_ID: ${{ github.event.pull_request.head.sha || github.sha }} work_dir: /paddle PADDLE_ROOT: /paddle TASK: paddle-CI-${{ github.event.pull_request.number }}-build ci_scripts: /paddle/ci BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }} CI_name: build CFS_DIR: /home/data/cfs is_pr: ${{ inputs.is_pr }} 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 uses: ./.github/workflows/check-bypass.yml with: workflow-name: build secrets: github-token: ${{ secrets.GITHUB_TOKEN }} build: name: Build 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: PADDLE_CUDA_INSTALL_REQUIREMENTS: "ON" FLAGS_fraction_of_gpu_memory_to_use: 0.15 CTEST_OUTPUT_ON_FAILURE: 1 CTEST_PARALLEL_LEVEL: 2 WITH_GPU: "ON" CUDA_ARCH_NAME: Volta WITH_COVERAGE: "OFF" PADDLE_FRACTION_GPU_MEMORY_TO_USE: 0.15 CUDA_VISIBLE_DEVICES: 0,1 PRECISION_TEST: "ON" WITH_CINN: "ON" INFERENCE_DEMO_INSTALL_DIR: /home/data/cfs/.cache/build WITH_INCREMENTAL_COVERAGE: "OFF" WITH_AVX: "ON" WITH_TESTING: "OFF" COVERALLS_UPLOAD: "OFF" GIT_PR_ID: ${{ github.event.pull_request.number }} PADDLE_VERSION: 0.0.0 WITH_DISTRIBUTE: "ON" WITH_UNITY_BUILD: "ON" PY_VERSION: "3.10" WITH_SHARED_PHI: "ON" CCACHE_MAXSIZE: 50G CCACHE_LIMIT_MULTIPLE: 0.8 CCACHE_STATSLOG: /paddle/build/.stats.log CCACHE_SLOPPINESS: clang_index_store,time_macros,include_file_mtime CACHE_DIR: /home/data/cfs/.cache/build 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 run: | container_name=${TASK}-$(date +%Y%m%d-%H%M%S) echo "container_name=${container_name}" >> ${{ github.env }} docker_image=${{ inputs.docker_build_image }} docker run -d -t --name ${container_name} \ -v "/home/data/cfs:/home/data/cfs" \ -v "/home/data/cfs/.cache:/root/.cache" \ -v "/home/data/shared:/home/data/shared" \ -v "/dev/shm:/dev/shm" \ -v ${{ github.workspace }}/../../..:${{ github.workspace }}/../../.. \ -v ${{ github.workspace }}:/paddle \ -e BRANCH \ -e is_pr \ -e PR_ID \ -e COMMIT_ID \ -e work_dir \ -e PADDLE_ROOT \ -e ci_scripts \ -e PADDLE_CUDA_INSTALL_REQUIREMENTS \ -e FLAGS_fraction_of_gpu_memory_to_use \ -e CTEST_OUTPUT_ON_FAILURE \ -e CTEST_PARALLEL_LEVEL \ -e WITH_GPU \ -e CUDA_ARCH_NAME \ -e WITH_COVERAGE \ -e PADDLE_FRACTION_GPU_MEMORY_TO_USE \ -e CUDA_VISIBLE_DEVICES \ -e PRECISION_TEST \ -e WITH_CINN \ -e INFERENCE_DEMO_INSTALL_DIR \ -e WITH_INCREMENTAL_COVERAGE \ -e WITH_SHARED_PHI \ -e WITH_TESTING \ -e COVERALLS_UPLOAD \ -e GIT_PR_ID \ -e PADDLE_VERSION \ -e WITH_DISTRIBUTE \ -e WITH_UNITY_BUILD \ -e PY_VERSION \ -e CCACHE_MAXSIZE \ -e CCACHE_LIMIT_MULTIPLE \ -e WITH_AVX \ -e CACHE_DIR \ -e CCACHE_DIR \ -e CCACHE_SECONDARY_STORAGE \ -e CCACHE_SLOPPINESS \ -e CCACHE_STATSLOG \ -e CFS_DIR \ -e no_proxy \ -e CI_name \ -w /paddle --network host ${docker_image} - name: Download paddle.tar.gz 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-build/${PR_ID}/${COMMIT_ID}/Paddle.tar.gz --no-check-certificate echo "Extracting Paddle.tar.gz" git config --global --add safe.directory ${work_dir} tar -xf Paddle.tar.gz --strip-components=1 git submodule foreach "git config --global --add safe.directory \$toplevel/\$sm_path" 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 ' - name: Merge target branch if: ${{ inputs.is_pr == 'true' }} env: work_dir: ${{ github.workspace }} run: | docker exec -t ${{ env.container_name }} /bin/bash -c ' 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 if: needs.check-bypass.outputs.can-skip != 'true' run: | docker exec -t ${{ env.container_name }} /bin/bash -c ' mkdir -p /root/.cache/build mkdir -p /root/.ccache/build source ${{ github.workspace }}/../../../proxy bash ${ci_scripts}/cmake-predownload.sh bash ${ci_scripts}/run_setup.sh bdist_wheel ' - name: Check sequence op if: needs.check-bypass.outputs.can-skip != 'true' run: | docker exec -t ${{ env.container_name }} /bin/bash -c ' source ${ci_scripts}/utils.sh; init bash ${work_dir}/tools/check_sequence_op.sh clean_build_files ' - name: Upload paddle_whl if: needs.check-bypass.outputs.can-skip != 'true' env: home_path: ${{ github.workspace }}/.. bos_file: ${{ github.workspace }}/../bos/BosClient.py paddle_whl: paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl run: | docker exec -t ${{ env.container_name }} /bin/bash -c ' bash ${ci_scripts}/compress_build.sh 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 /paddle/build/paddle ls | grep -v cinn | xargs rm -rf rm -rf /paddle/build/third_party rm -rf /paddle/build/dist cd / tar --use-compress-program="pzstd -1" -cf build.tar.gz paddle echo "Uploading build.tar.gz to bos" python ${{ env.bos_file }} build.tar.gz paddle-github-action/PR/build/${{ env.PR_ID }}/${{ env.COMMIT_ID }} echo "Uploading build.tar.gz to cfs" mkdir -p ${CFS_DIR}/build_bos/${PR_ID}/${COMMIT_ID} mv build.tar.gz ${CFS_DIR}/build_bos/${PR_ID}/${COMMIT_ID} && echo success mv /paddle/${{ env.paddle_whl }} . echo "Uploading paddle_whl to bos" python ${{ env.bos_file }} ${{ env.paddle_whl }} paddle-github-action/PR/build/${{ env.PR_ID }}/${{ env.COMMIT_ID }} ' - name: Terminate and delete the container if: ${{ needs.check-bypass.outputs.can-skip != 'true' && 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 }}