Skip to content

Commit 1858821

Browse files
Add Action
1 parent 826ea06 commit 1858821

3 files changed

Lines changed: 225 additions & 0 deletions

File tree

.github/workflows/CI.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
branches: [develop, release/**, fleety_*]
7+
8+
permissions: read-all
9+
10+
concurrency:
11+
group: ${{ github.event.pull_request.number }}-${{ github.workflow }}
12+
cancel-in-progress: true
13+
14+
env:
15+
PR_ID: ${{ github.event.pull_request.number }}
16+
COMMIT_ID: ${{ github.event.pull_request.head.sha }}
17+
18+
jobs:
19+
clone:
20+
name: Clone-linux
21+
uses: ./.github/workflows/_Clone-linux.yml
22+
with:
23+
workflow-name: 'CI'
24+
25+
Codestyle-Check:
26+
name: Codestyle-Check
27+
uses: ./.github/workflows/_Codestyle-Check.yml
28+
needs: [clone]
29+
30+
GCU:
31+
name: PR-CI-GCU
32+
uses: ./.github/workflows/_GCU.yml
33+
needs: [clone, Codestyle-Check]

.github/workflows/_Clone-linux.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Clone-linux
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
workflow-name:
7+
type: string
8+
required: false
9+
clone_dir:
10+
type: string
11+
required: false
12+
default: 'PaddlecustomDevice'
13+
is_pr:
14+
type: string
15+
required: false
16+
default: 'true'
17+
outputs:
18+
can-skip:
19+
value: ${{ jobs.clone.outputs.can-skip }}
20+
slice-check:
21+
value: ${{ jobs.clone.outputs.slice-check }}
22+
23+
permissions: read-all
24+
25+
defaults:
26+
run:
27+
shell: bash
28+
29+
env:
30+
PR_ID: ${{ github.event.pull_request.number || '0' }}
31+
COMMIT_ID: ${{ github.event.pull_request.head.sha || github.sha }}
32+
ci_scripts: ${{ github.workspace }}/ci
33+
BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }}
34+
35+
jobs:
36+
clone:
37+
name: Clone PaddlecustomDevice
38+
if: ${{ github.repository_owner == 'PaddlePaddle' }}
39+
outputs:
40+
can-skip: ${{ steps.check-bypass.outputs.can-skip }}
41+
slice-check: ${{ steps.check-execution.outputs.slice-check }}
42+
runs-on:
43+
group: HK-Clone
44+
45+
steps:
46+
- name: Clone paddle
47+
uses: actions/checkout@v4
48+
with:
49+
ref: ${{ github.event.pull_request.base.ref }}
50+
submodules: 'recursive'
51+
fetch-depth: 1000
52+
53+
- name: Merge PR to test branch
54+
id: check-execution
55+
if: ${{ inputs.is_pr == 'true' }}
56+
run: |
57+
git config --unset http.https://github.com/.extraheader
58+
git submodule foreach --recursive sh -c "git config --local --unset-all 'http.https://github.com/.extraheader'"
59+
git submodule foreach --recursive sh -c "git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'"
60+
git switch ${{ github.event.pull_request.base.ref }}
61+
set +e
62+
git branch -D test
63+
set -e
64+
git gc
65+
git switch -c test
66+
git config user.name "PaddleCI"
67+
git config user.email "paddle_ci@example.com"
68+
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr
69+
git merge --no-ff pr
70+
git submodule update --init
71+
git branch -d pr
72+
source ${ci_scripts}/check_execution.sh
73+
bash ${ci_scripts}/third_party_tag.sh
74+
75+
- name: Check bypass
76+
id: check-bypass
77+
uses: ./.github/actions/check-bypass
78+
with:
79+
github-token: ${{ secrets.GITHUB_TOKEN }}
80+
workflow-name: ${{ inputs.workflow-name }}
81+
82+
- name: Download bos client
83+
env:
84+
home_path: "/home/paddle/actions-runner/"
85+
bos_file: "/home/paddle/actions-runner/bos/BosClient.py"
86+
run: |
87+
if [ ! -f "${bos_file}" ]; then
88+
wget -q --no-proxy -O ${home_path}/bos_new.tar.gz https://xly-devops.bj.bcebos.com/home/bos_new.tar.gz --no-check-certificate
89+
mkdir ${home_path}/bos
90+
tar xf ${home_path}/bos_new.tar.gz -C ${home_path}/bos
91+
fi
92+
93+
- name: Push paddle-action.tar.gz to bos
94+
env:
95+
AK: paddle
96+
SK: paddle
97+
bos_file: "/home/paddle/actions-runner/bos/BosClient.py"
98+
run: |
99+
cd ..
100+
tar -I 'zstd -T0' -cf PaddlecustomDevice.tar.gz PaddlecustomDevice
101+
echo "::group::Install bce-python-sdk"
102+
python -m pip install bce-python-sdk==0.8.74
103+
echo "::endgroup::"
104+
python ${bos_file} PaddlecustomDevice.tar.gz paddle-github-action/PaddleCustomDevice/PR/${{ inputs.clone_dir }}/${PR_ID}/${COMMIT_ID}
105+
rm PaddlecustomDevice.tar.gz
106+
cd -
107+
git switch ${BRANCH}
108+
set +e
109+
git branch -D test
110+
git gc
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Codestyle-Check
2+
3+
on:
4+
pull_request:
5+
branches: ["develop"]
6+
7+
jobs:
8+
pre-commit:
9+
name: Pre Commit
10+
if: ${{ github.repository_owner == 'PaddlePaddle' }}
11+
runs-on:
12+
group: APPROVAL
13+
env:
14+
PR_ID: ${{ github.event.pull_request.number }}
15+
BRANCH: develop
16+
17+
steps:
18+
- name: Cleanup
19+
run: |
20+
rm -rf * .[^.]*
21+
22+
- name: Check docker image and run container
23+
env:
24+
python: "python3.10"
25+
GIT_PR_ID: ${{ github.event.pull_request.number || '0' }}
26+
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
RUN_ID: ${{ github.run_id }}
28+
docker_image: iregistry.baidu-int.com/tiangexiao/paddle-npu:cann800-910B-ubuntu18-x86_64
29+
run: |
30+
container_name=${TASK}-${core_index}-$(date +%Y%m%d-%H%M%S)
31+
echo "container_name=${container_name}" >> ${{ github.env }}
32+
docker container ls -a --filter "name=paddle-CI-*-api-benchmark-${core_index}*" --format "{{.ID}}" | xargs -r docker rm -f
33+
docker container ls -a --filter "name=api_benchmark_ci_baseline_" --format "{{.ID}} {{.CreatedAt}}" | awk '$2 <= "'$(date -d '1 day ago' +'%Y-%m-%d')'" {print $1}' | xargs -r docker rm -f
34+
docker run -d -t --name ${container_name} --shm-size=128g \
35+
-v ${{ github.workspace }}/../../..:${{ github.workspace }}/../../.. \
36+
-v ${{ github.workspace }}:/paddle \
37+
-e python \
38+
-e core_index \
39+
-e BRANCH \
40+
-e PR_ID \
41+
-e COMMIT_ID \
42+
-e RUN_ID \
43+
-e wheel_link \
44+
-e work_dir \
45+
-e PADDLE_ROOT \
46+
-e ci_scripts \
47+
-e GIT_PR_ID \
48+
-e PADDLE_VERSION \
49+
-e no_proxy \
50+
-e CI_name \
51+
-e GITHUB_API_TOKEN \
52+
-w /paddle --network host ${docker_image}
53+
54+
- name: Download PaddleCustomDevice.tar.gz
55+
run: |
56+
wget -q --tries=5 --no-proxy https://paddle-github-action.bj.bcebos.com/PaddleCustomDevice/PR/${PR_ID}/${COMMIT_ID}/PaddleCustomDevice.tar.gz --no-check-certificate
57+
echo "Extracting PaddleTest.tar.gz"
58+
# git config --global --add safe.directory ${work_dir}
59+
tar -xf PaddleCustomDevice.tar.gz --strip-components=1
60+
git fetch origin pull/${PR_ID}/merge
61+
git checkout -b test FETCH_HEAD
62+
63+
- name: Setup python3.12
64+
if: steps.check-bypass.outputs.can-skip != 'true'
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: '3.12'
68+
cache: 'pip'
69+
70+
- name: Install dependencies
71+
if: steps.check-bypass.outputs.can-skip != 'true'
72+
run: |
73+
pip install pre-commit==2.17.0 cpplint==1.6.0 clang-format==13.0.0
74+
75+
- name: Check pre-commit
76+
if: steps.check-bypass.outputs.can-skip != 'true'
77+
env:
78+
SKIP_CLANG_TIDY_CHECK: "ON"
79+
run: |
80+
set +e
81+
bash -x tools/codestyle/pre_commit.sh;EXCODE=$?
82+
exit $EXCODE

0 commit comments

Comments
 (0)