124 lines
4.5 KiB
YAML
124 lines
4.5 KiB
YAML
name: Doc-Preview
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
docker_doc_image:
|
|
type: string
|
|
required: true
|
|
can-skip:
|
|
type: string
|
|
required: false
|
|
default: "false"
|
|
build-can-skip:
|
|
type: string
|
|
required: false
|
|
default: 'false'
|
|
|
|
env:
|
|
PR_ID: ${{ github.event.pull_request.number }}
|
|
COMMIT_ID: ${{ github.event.pull_request.head.sha }}
|
|
ci_scripts: /workspace/paddle/ci
|
|
BRANCH: ${{ github.event.pull_request.base.ref }}
|
|
TASK: paddle-CI-${{ github.event.pull_request.number }}-Doc-Preview
|
|
CI_name: Doc-Preview
|
|
CFS_DIR: /home/data/cfs
|
|
work_dir: /paddle
|
|
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' && inputs.build-can-skip != 'true' }}
|
|
uses: ./.github/workflows/check-bypass.yml
|
|
with:
|
|
workflow-name: "Doc-Preview"
|
|
secrets:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
build-doc:
|
|
name: Build doc
|
|
needs: [check-bypass]
|
|
if: ${{ needs.check-bypass.outputs.can-skip != 'true' && inputs.can-skip != 'true' }}
|
|
runs-on:
|
|
group: BD_BJ-V100
|
|
timeout-minutes: 120
|
|
steps:
|
|
- name: Check docker image and run container
|
|
env:
|
|
CACHE_DIR: /home/data/cfs/.cache
|
|
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
AGILE_PULL_ID: ${{ github.event.pull_request.number }}
|
|
AGILE_REVISION: ${{ github.event.pull_request.head.sha }}
|
|
BUILD_DOC: "true"
|
|
UPLOAD_DOC: "true"
|
|
BOSBUCKET: "paddle-site-web-dev"
|
|
PREVIEW_SITE: "paddle-docs-preview.paddlepaddle.org.cn"
|
|
AGILE_COMPILE_BRANCH: ${{ startsWith(github.event.pull_request.base.ref, 'fleety_') && 'develop' || github.event.pull_request.base.ref }}
|
|
BOS_CREDENTIAL_AK: "paddle"
|
|
BOS_CREDENTIAL_SK: "paddle"
|
|
PADDLE_WHL: https://paddle-github-action.bj.bcebos.com/PR/build/${{ github.event.pull_request.number }}/${{ github.event.pull_request.head.sha }}/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
|
|
run: |
|
|
container_name=${TASK}-$(date +%Y%m%d-%H%M%S)
|
|
echo "container_name=${container_name}" >> ${{ github.env }}
|
|
docker_image=${{ inputs.docker_doc_image }}
|
|
docker run -d -t --gpus all --name ${container_name} \
|
|
-v "/home/data/cfs:/home/data/cfs" \
|
|
-v "/home/data/cfs/.cache/python35-cpu:/root/.cache" \
|
|
-v "/home/data/cfs/.ccache:/root/.ccache" \
|
|
-v "/dev/shm:/dev/shm" \
|
|
-v ${{ github.workspace }}/../../..:${{ github.workspace }}/../../.. \
|
|
-v ${{ github.workspace }}:/paddle \
|
|
-e CACHE_DIR \
|
|
-e GITHUB_API_TOKEN \
|
|
-e AGILE_PULL_ID \
|
|
-e AGILE_REVISION \
|
|
-e BUILD_DOC \
|
|
-e UPLOAD_DOC \
|
|
-e BOSBUCKET \
|
|
-e PREVIEW_SITE \
|
|
-e BRANCH \
|
|
-e AGILE_COMPILE_BRANCH \
|
|
-e BOS_CREDENTIAL_AK \
|
|
-e BOS_CREDENTIAL_SK \
|
|
-e PADDLE_WHL \
|
|
-e CFS_DIR \
|
|
-e work_dir \
|
|
-e no_proxy \
|
|
-w /paddle --network host ${docker_image}
|
|
|
|
- name: Doc build
|
|
run: |
|
|
docker exec -t ${{ env.container_name }} /bin/bash -c '
|
|
rm -rf * .[^.]*
|
|
echo "Downloading build.tar.gz from cfs"
|
|
cp ${CFS_DIR}/build_bos/${AGILE_PULL_ID}/${AGILE_REVISION}/build.tar.gz .
|
|
echo "Extracting build.tar.gz"
|
|
git config --global --add safe.directory ${work_dir}
|
|
tar --use-compress-program="pzstd -1" -xpf build.tar.gz --strip-components=1
|
|
if ! api_doc_spec_diff=$(python tools/diff_api.py paddle/fluid/API_DEV.spec.doc paddle/fluid/API_PR.spec.doc); then
|
|
echo "diff_api.py failed for API doc specs."
|
|
exit 1
|
|
fi
|
|
if [ -z "$api_doc_spec_diff" ]; then
|
|
echo "API documents no change."
|
|
exit 0
|
|
fi
|
|
|
|
cd /
|
|
source ${{ github.workspace }}/../../../proxy
|
|
pip3 install --progress-bar off -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple --force-reinstall ${work_dir}/build/pr_whl/*.whl
|
|
bash ${work_dir}/ci/run_docs_preview.sh
|
|
'
|
|
|
|
- name: Terminate and delete the container
|
|
if: always()
|
|
run: |
|
|
set +e
|
|
docker exec -t ${{ env.container_name }} /bin/bash -c 'rm -rf * .[^.]*'
|
|
docker rm -f ${{ env.container_name }}
|