-
Notifications
You must be signed in to change notification settings - Fork 96
175 lines (154 loc) · 6.95 KB
/
Copy pathUnittest_check.yml
File metadata and controls
175 lines (154 loc) · 6.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: CI Unittest
on:
# Nightly: re-validate master against the freshly built nightly paddle
# Cron is UTC: '0 21 * * *' => 05:00 UTC+8
# schedule:
# - cron: '0 21 * * *'
pull_request:
branches: [master, develop, "release/**"]
paths-ignore:
- '**/*.md'
- 'docs/**'
- 'LICENSE'
- '.gitignore'
- '.pre-commit-config.yaml'
push:
branches: [master, develop]
paths-ignore:
- '**/*.md'
- 'docs/**'
- 'LICENSE'
- '.gitignore'
- '.pre-commit-config.yaml'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
ci-unittest:
name: CI Unittest
runs-on:
group: PaConvert
labels: [cpu]
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ensure CI image Exists
run: |
docker image inspect paconvert-ci:cu118 >/dev/null 2>&1 || \
docker build --pull --network=host \
--build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
--build-arg no_proxy="localhost,127.0.0.1" \
-t paconvert-ci:cu118 -f tools/docker/Dockerfile tools/docker
- name: Start Container
run: |
container_name="paconvert-cpu-unittest-${{ github.run_id }}-${{ github.run_attempt }}"
echo "container_name=${container_name}" >> "$GITHUB_ENV"
docker run -d --name "${container_name}" \
-e NVIDIA_VISIBLE_DEVICES=void \
-e http_proxy=$http_proxy \
-e https_proxy=$https_proxy \
-e no_proxy="localhost,127.0.0.1" \
--network host \
-v /dev/shm:/dev/shm \
-v "${{ github.workspace }}:/ws" \
-w /ws \
paconvert-ci:cu118 sleep infinity
- name: Run CI Unittest
shell: bash
run: docker exec "$container_name" bash scripts/ci/run_cpu_unittest.sh
- name: Upload logs on failing
if: failure()
uses: actions/upload-artifact@v4
with:
name: ci-unittest-log-${{ github.run_id }}
path: |
pytest.log
tests/**/pytest.log
if-no-files-found: ignore
retention-days: 14
- name: Cleanup Container
if: always()
run: |
if [ -n "${container_name:-}" ]; then
docker exec "${container_name}" chown -R "$(id -u):$(id -g)" /ws 2>/dev/null || true
docker rm -f "${container_name}" || true
fi
# - name: Setup Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.10'
# cache: pip
# cache-dependency-path: |
# requirements.txt
# tests/requirements.txt
# - name: Check Env
# run: |
# python --version
# pwd
# - name: Install Latest Release CPU Version Torch
# run: |
# python -m pip install --upgrade pip
# python -m pip install -U torch torchvision --index-url https://download.pytorch.org/whl/cpu
# python -c "import torch; print('torch version information:', torch.__version__)"
# - name: Install Latest develop CPU Version Paddle
# run: |
# python -m pip uninstall -y paddlepaddle
# python -m pip uninstall -y paddlepaddle-gpu
# python -m pip install --force-reinstall --no-cache-dir -U --pre paddlepaddle \
# -i https://www.paddlepaddle.org.cn/packages/nightly/cpu/ \
# --extra-index-url https://pypi.org/simple \
# --timeout 120 --retries 3
# python -c "import paddle; print('paddle version information:', paddle.__version__); print('paddle commit information:', paddle.__git_commit__)"
# - name: Install paconvert requirements
# run: |
# python -m pip install -r requirements.txt
# if [ -f tests/requirements.txt ]; then
# python -m pip install -r tests/requirements.txt
# fi
# - name: Run CI Unittest
# shell: bash
# run: |
# python -m pip install pytest-timeout pytest-xdist pytest-rerunfailures
# # Disable errexit so a failing run is captured instead of aborting immediately
# # A passing retry can clear the error.
# set +e
# echo "Checking code cpu unit test by pytest ..."
# # tee output to pytest.log so it can be uploaded as an artifact on failure;
# # PIPESTATUS[0] preserves pytest's exit code instead of tee's.
# python -m pytest -v -s -p no:warnings --reruns=3 ./tests 2>&1 | tee pytest.log
# check_error=${PIPESTATUS[0]}
# if [ ${check_error} -ne 0 ]; then
# echo "Rerun cpu unit test check."
# python -m pytest -v -s -p no:warnings --lf ./tests 2>&1 | tee -a pytest.log
# check_error=${PIPESTATUS[0]}
# fi
# echo '************************************************************************************************************'
# if [ ${check_error} -ne 0 ]; then
# echo "Your PR code cpu unit test check failed."
# echo "Please run the following command:"
# echo ""
# echo " python -m pytest tests"
# echo ""
# echo "For more information, please refer to our check guide:"
# echo "https://github.com/PaddlePaddle/PaConvert#readme."
# else
# echo "Your PR code cpu unit test check passed."
# fi
# echo '************************************************************************************************************'
# exit ${check_error}
# - name: Upload logs on failure
# if: failure()
# uses: actions/upload-artifact@v4
# with:
# name: ci-unittest-log-${{ github.run_id }}
# path: |
# pytest.log
# tests/**/pytest.log
# if-no-files-found: ignore
# retention-days: 14