1
+ name : Model Unittest GPU CI
2
+
3
+ on :
4
+ pull_request :
5
+ push :
6
+ schedule :
7
+ - cron : " 0 18 * * *"
8
+ workflow_call :
9
+ inputs :
10
+ runner :
11
+ required : false
12
+ type : string
13
+ image_name :
14
+ required : false
15
+ type : string
16
+
17
+ concurrency :
18
+ group : model-unittest-${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
19
+ cancel-in-progress : true
20
+
21
+ env :
22
+ PR_ID : ${{ github.event.pull_request.number }}
23
+ COMMIT_ID : ${{ github.event.pull_request.head.sha }}
24
+ TASK : PaddleFormers-CI-${{ github.event.pull_request.number }}-model-unittest-gpu
25
+ ci_scripts : /workspace/PaddleFormers/scripts/unit_test
26
+ BRANCH : ${{ github.event.pull_request.base.ref }}
27
+ AGILE_COMPILE_BRANCH : ${{ github.event.pull_request.base.ref }}
28
+ CI_name : model-unittest-gpu-ci
29
+ 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"
30
+
31
+ defaults :
32
+ run :
33
+ shell : bash
34
+
35
+ jobs :
36
+ model-unittest-gpu-ci :
37
+ name : model-unittest-gpu-ci
38
+ runs-on : ${{ inputs.runner || 'ernie-8gpu' }}
39
+ steps :
40
+ - name : Determine Image Name
41
+ env :
42
+ IMAGE_NAME : ${{ inputs.image_name }}
43
+ run : |
44
+ if [[ -n "${IMAGE_NAME}" ]]; then
45
+ echo "IMAGE_NAME=${IMAGE_NAME}" >> "$GITHUB_ENV"
46
+ else
47
+ echo "IMAGE_NAME=ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddle:cuda126-dev-latest" >> "$GITHUB_ENV"
48
+ fi
49
+
50
+ - name : Run Container
51
+ env :
52
+ work_dir : ${{ github.workspace }}
53
+ FLAGS_dynamic_static_unified_comm : " True"
54
+ python_version : " 3.10"
55
+ paddle_whl : https://paddle-qa.bj.bcebos.com/paddle-pipeline/Develop-GpuAll-LinuxCentos-Gcc11-Cuda126-Cudnn95-Trt105-Py310-Compile/latest/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
56
+ run : |
57
+ container_name=${TASK}-$(date +%Y%m%d-%H%M%S)
58
+ echo "container_name=${container_name}" >> "$GITHUB_ENV"
59
+ docker run -d -t --name ${container_name} --net=host -v /dev/shm:/dev/shm --shm-size=32G \
60
+ -v $work_dir/../../..:$work_dir/../../.. \
61
+ -v $work_dir:/workspace \
62
+ -v /home/.cache/pip:/home/.cache/pip \
63
+ -e BRANCH \
64
+ -e AGILE_COMPILE_BRANCH \
65
+ -e PR_ID \
66
+ -e COMMIT_ID \
67
+ -e work_dir \
68
+ -e ci_scripts \
69
+ -e no_proxy \
70
+ -e CI_name \
71
+ -e paddle_whl \
72
+ -e FLAGS_dynamic_static_unified_comm \
73
+ -e python_version \
74
+ -e HF_PROXY_PATH=$work_dir/../../../proxy_huggingface \
75
+ -e AISTUDIO_PROXY_PATH=$work_dir/../../../proxy_aistudio \
76
+ -w /workspace --runtime=nvidia --privileged $IMAGE_NAME
77
+
78
+ - name : Download Code
79
+ run : |
80
+ docker exec -t $container_name /bin/bash -c '
81
+ rm -rf * .[^.]*
82
+ echo "Downloading PaddleFormers.tar"
83
+ wget -q --no-proxy https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddleFormers.tar --no-check-certificate
84
+ echo "Extracting PaddleFormers.tar"
85
+ tar xf PaddleFormers.tar && rm -rf PaddleFormers.tar
86
+ source $work_dir/../../../proxy
87
+ cd PaddleFormers
88
+ git config --global user.name "PaddleCI"
89
+ git config --global user.email "[email protected] "
90
+ git pull
91
+ git submodule update --init --recursive --force
92
+ if [ -n "${PR_ID}" ]; then
93
+ git fetch origin pull/${PR_ID}/head
94
+ git checkout -b PR_${PR_ID} FETCH_HEAD
95
+ git remote add upstream https://github.com/PaddlePaddle/PaddleFormers.git
96
+ git fetch upstream ${BRANCH}:${BRANCH}
97
+ git merge ${BRANCH} --no-edit
98
+ git diff --numstat ${BRANCH} -- | awk "{print \$NF}"
99
+ else
100
+ echo "Not in a pull_request event. Skipping PR-specific operations."
101
+ fi
102
+ git log --pretty=oneline -10
103
+ '
104
+
105
+ - name : Test
106
+ run : |
107
+ docker exec -t $container_name /bin/bash -c '
108
+ ldconfig
109
+ pip config set global.cache-dir "/home/.cache/pip"
110
+ set -e
111
+ rm -rf /root/.cache/aistudio/
112
+ cd /workspace/PaddleFormers && git config --global --add safe.directory $PWD
113
+ source $work_dir/../../../proxy
114
+ source $work_dir/../../../AISTUDIO_ACCESS_TOKEN
115
+ timeout 30m bash scripts/unit_test/ci_model_unit.sh ${paddle_whl}
116
+ '
117
+
118
+ - name : Upload Products
119
+ if : always()
120
+ env :
121
+ home_path : ${{ github.workspace }}/../../..
122
+ bos_file : ${{ github.workspace }}/../../../bos/BosClient.py
123
+ allure_file : ${{ github.workspace }}/../../../allure-2.19.0/bin/allure
124
+ run : |
125
+ docker exec -t $container_name /bin/bash -c '
126
+ if [ ! -f "${{ env.bos_file }}" ]; then
127
+ 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
128
+ mkdir ${{ env.home_path }}/bos
129
+ tar xf ${{ env.home_path }}/bos_new.tar.gz -C ${{ env.home_path }}/bos
130
+ fi
131
+ if [ ! -f "${{ env.allure_file }}" ]; then
132
+ 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
133
+ unzip -q ${{ env.home_path }}/allure-2.19.0.zip
134
+ fi
135
+ if [ -n "${PR_ID}" ]; then
136
+ bos_prefix="${PR_ID}/${COMMIT_ID}"
137
+ else
138
+ bos_prefix="schedule/$(date +%Y%m%d)"
139
+ fi
140
+ # coverage.xml
141
+ # cd /workspace/PaddleFormers
142
+ # python ${{ env.bos_file }} coverage.xml paddle-github-action/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs
143
+ # echo "cov-report: https://paddle-github-action.bj.bcebos.com/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs/coverage.xml"
144
+ # logs
145
+ cd /workspace/PaddleFormers/model-unittest_logs
146
+ for FILE in /workspace/PaddleFormers/model-unittest_logs/*; do
147
+ file=$(basename "$FILE")
148
+ python ${{ env.bos_file }} $file paddle-github-action/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs
149
+ echo "$file: https://paddle-github-action.bj.bcebos.com/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs/$file"
150
+ done
151
+ # allure
152
+ # cd /workspace/PaddleFormers/
153
+ # ${{ env.allure_file }} generate result -o report
154
+ # tar -czf report.tar.gz report
155
+ # python ${{ env.bos_file }} report.tar.gz paddle-github-action/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs
156
+ # echo "report: https://paddle-github-action.bj.bcebos.com/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs/report.tar.gz"
157
+ '
158
+
159
+ - name : Terminate And Delete the Container
160
+ if : always()
161
+ run : |
162
+ docker rm -f $container_name 2>/dev/null || true
163
+
164
+ # upload-coverage:
165
+ # name: upload-coverage
166
+ # needs: [model-unittest-gpu-ci]
167
+ # if: always()
168
+ # runs-on: ubuntu-latest
169
+ # steps:
170
+ # - name: Checkout Code
171
+ # uses: actions/checkout@v4
172
+ # with:
173
+ # fetch-depth: 0
174
+
175
+ # - name: Download coverage.xml
176
+ # run: |
177
+ # if [ -n "${PR_ID}" ]; then
178
+ # bos_prefix="${PR_ID}/${COMMIT_ID}"
179
+ # else
180
+ # bos_prefix="schedule/$(date +%Y%m%d)"
181
+ # fi
182
+ # wget -q --no-proxy \
183
+ # https://paddle-github-action.bj.bcebos.com/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs/coverage.xml \
184
+ # --no-check-certificate -O coverage.xml
185
+
186
+ # - name: Fix coverage.xml paths
187
+ # run: |
188
+ # echo "Before fix:"
189
+ # head -n 10 coverage.xml || true
190
+
191
+ # old_source=$(grep -oPm1 '(?<=<source>).*?(?=</source>)' coverage.xml || true)
192
+ # if [ -n "$old_source" ]; then
193
+ # echo "Replacing source '$old_source' with 'paddleformers'"
194
+ # sed -i "s|<source>$old_source</source>|<source>paddleformers</source>|g" coverage.xml
195
+ # else
196
+ # echo "No <source> found, injecting <source>paddleformers</source>"
197
+ # sed -i 's|<sources>|<sources>\n <source>paddleformers</source>|' coverage.xml
198
+ # fi
199
+
200
+ # echo "After fix:"
201
+ # head -n 10 coverage.xml || true
202
+
203
+ # - name: Upload coverage to Codecov
204
+ # uses: codecov/codecov-action@v4
205
+ # with:
206
+ # files: coverage.xml
207
+ # env:
208
+ # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
209
+
210
+ # upload-allure:
211
+ # name: upload-allure
212
+ # needs: [model-unittest-gpu-ci]
213
+ # if: success() || failure()
214
+ # runs-on: ubuntu-latest
215
+ # steps:
216
+ # - name: Checkout Code
217
+ # uses: actions/checkout@v4
218
+ # with:
219
+ # fetch-depth: 0
220
+
221
+ # - name: Download report.tar.gz
222
+ # run: |
223
+ # if [ -n "${PR_ID}" ]; then
224
+ # bos_prefix="${PR_ID}/${COMMIT_ID}"
225
+ # else
226
+ # bos_prefix="schedule/$(date +%Y%m%d)"
227
+ # fi
228
+ # wget -q --no-proxy \
229
+ # https://paddle-github-action.bj.bcebos.com/PR/PaddleFormers/model-unittest-gpu/${bos_prefix}/logs/report.tar.gz \
230
+ # --no-check-certificate -O report.tar.gz
231
+ # tar -xzf report.tar.gz
232
+
233
+ # - name: Upload Allure Report
234
+ # uses: actions/upload-artifact@v4
235
+ # with:
236
+ # name: allure-report
237
+ # path: report
238
+ # if-no-files-found: ignore
239
+
240
+ # - name: Deploy allure report to GitHub Pages
241
+ # uses: peaceiris/actions-gh-pages@v4
242
+ # with:
243
+ # github_token: ${{ secrets.GITHUB_TOKEN }}
244
+ # publish_dir: ./report
0 commit comments