forked from taichi-dev/taichi
-
Notifications
You must be signed in to change notification settings - Fork 0
462 lines (417 loc) · 16.3 KB
/
testing.yml
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
name: Build and Test
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [master]
concurrency:
group: ${{ github.event.number || github.run_id }}
cancel-in-progress: true
jobs:
check_files:
name: Check files
outputs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: check modified files
id: check_files
run: |
echo "Concurrency group: ${{ github.event.number || github.run_id }}"
echo "=============== list modified files ==============="
git diff --name-only @^
chore_files=( LICENSE CONTRIBUTING.md README.md netlify.toml )
chore_dirs=( docs )
run_job=false
for file in $(git diff --name-only @^); do
is_chore=false
for chore_file in ${chore_files[*]}; do
[[ ${file} == ${chore_file} ]] && is_chore=true && break
done
for chore_dir in ${chore_dirs[*]}; do
[[ ${file} == ${chore_dir}/* ]] && is_chore=true && break
done
if ! ${is_chore}; then
run_job=true
break
fi
done
if ${run_job}; then
echo "::set-output name=run_job::true"
else
echo "::set-output name=run_job::false"
fi
check_code_format:
name: Check Code Format
runs-on: ubuntu-latest
needs: check_files
# This job will be required to pass before merging to master branch.
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Setup git & clang-format
run: |
git config user.email "[email protected]"
git config user.name "Taichi Gardener"
git checkout -b _fake_squash
git remote add upstream https://github.com/taichi-dev/taichi.git
git fetch upstream master
sudo apt install clang-format-10
- name: Cache PIP
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_dev.txt') }}
- name: Install requirements
run: |
python3 -m pip install --user -r requirements_dev.txt
- name: Check code format
run: |
python3 misc/code_format.py
git checkout -b _enforced_format
git commit -am "enforce code format" || true
# exit with 1 if there were differences:
git diff _fake_squash _enforced_format --exit-code
check_static_analyzer:
name: Check Static Analyzer
runs-on: ubuntu-latest
needs: check_files
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Pylint
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
python3 -m pip install --user pylint
# Make sure pylint doesn't regress
pylint python/taichi/ --disable=all --enable=$(python scripts/generate_pylint_tags.py)
if [ $? -eq 0 ]
then
echo "PASSED: pylint is happy"
exit 0
else
echo "FAILED: please run the pylint command above and make sure it passes"
exit 1
fi
- name: clang-tidy
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
echo $CR_PAT | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker pull ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0
docker run -id --user dev --name check_clang_tidy ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0 /bin/bash
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx --owner 1000 --group 1000 | docker cp - check_clang_tidy:/home/dev/
docker exec --user root check_clang_tidy apt install -y clang-tidy-10
docker exec --user dev check_clang_tidy /home/dev/taichi/.github/workflows/scripts/check_clang_tidy.sh "$CI_SETUP_CMAKE_ARGS"
env:
CR_PAT: ${{ secrets.GITHUB_TOKEN }}
CI_SETUP_CMAKE_ARGS: -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=ON -DTI_WITH_VULKAN:BOOL=OFF -DTI_BUILD_TESTS:BOOL=OFF
build_and_test_cpu_linux:
name: Build and Test linux (CPU)
needs: [check_code_format, check_files]
timeout-minutes: 60
strategy:
matrix:
include:
- os: ubuntu-latest
python: py36
with_cc: OFF
wanted_archs: "cpu"
- os: ubuntu-latest
python: py39
with_cc: ON
wanted_archs: "cpu,cc"
runs-on: ${{ matrix.os }}
permissions:
packages: read
contents: read
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Get sccache cache
uses: actions/cache@v2
with:
path: sccache_cache
key: sccache-linux-${{matrix.with_cc}}-${{ github.sha }}
restore-keys: |
sccache-linux-${{matrix.with_cc}}-
- name: Get docker images
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
echo $CR_PAT | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker pull ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0
env:
CR_PAT: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
mkdir -m777 shared
docker create --user dev --name taichi_build \
-e PY -e PROJECT_NAME -e TAICHI_CMAKE_ARGS \
ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0 \
/home/dev/taichi/.github/workflows/scripts/unix_build.sh
# A tarball is needed because sccache needs some permissions that only the file owner has.
# 1000 is the uid and gid of user "dev" in the container.
# If the uid or gid of the user inside the docker changes, please change the uid and gid in the following line.
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx --owner 1000 --group 1000 | docker cp - taichi_build:/home/dev/
docker start -a taichi_build
rm -rf sccache_cache
docker cp taichi_build:/home/dev/taichi/sccache_cache sccache_cache
docker cp taichi_build:/home/dev/taichi/dist shared/dist
docker cp taichi_build:/home/dev/taichi/build shared/build
env:
PY: ${{ matrix.python }}
PROJECT_NAME: taichi
TAICHI_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=${{ matrix.with_cc }} -DTI_WITH_VULKAN:BOOL=OFF -DTI_BUILD_TESTS:BOOL=ON -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
docker create --user dev --name taichi_test -e PY -e TI_WANTED_ARCHS ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0 /home/dev/unix_test.sh
docker cp .github/workflows/scripts/unix_test.sh taichi_test:/home/dev/unix_test.sh
docker cp shared/dist/ taichi_test:/home/dev/
docker cp shared/build/ taichi_test:/home/dev/
docker cp ./requirements_test.txt taichi_test:/home/dev/requirements_test.txt
docker cp tests/ taichi_test:/home/dev/
docker start -a taichi_test
env:
PY: ${{ matrix.python }}
TI_WANTED_ARCHS: ${{ matrix.wanted_archs }}
- name: clean docker container
if: always()
run: |
docker rm taichi_build taichi_test -f
build_and_test_cpu_mac:
name: Build and Test macos (CPU)
needs: [check_code_format, check_files]
timeout-minutes: 60
strategy:
matrix:
include:
- os: macos-10.15
python: 3.7
with_cc: OFF
with_cpp_tests: ON
wanted_archs: "cpu"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Get sccache cache
uses: actions/cache@v2
with:
path: sccache_cache
key: sccache-mac-${{ github.sha }}
restore-keys: |
sccache-mac-
- name: Download Pre-Built LLVM 10.0.0
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
python misc/ci_download.py
env:
CI_PLATFORM: ${{ matrix.os }}
- name: Build & Install
run: |
brew install molten-vk
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
mkdir -p sccache_cache
export PATH=`pwd`/taichi-llvm/bin/:$PATH
.github/workflows/scripts/unix_build.sh
brew uninstall molten-vk
env:
TAICHI_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=${{ matrix.with_cc }} -DTI_WITH_VULKAN:BOOL=ON -DTI_BUILD_TESTS:BOOL=${{ matrix.with_cpp_tests }} -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
CXX: clang++
# [DEBUG] Copy this step around to enable debugging inside Github Action instances.
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
.github/workflows/scripts/unix_test.sh
env:
TI_WANTED_ARCHS: ${{ matrix.wanted_archs }}
build_and_test_gpu_linux:
name: Build and Test (GPU)
needs: [check_code_format, check_files]
runs-on: [self-hosted, cuda, vulkan, cn]
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Get sccache cache
uses: actions/cache@v2
with:
path: sccache_cache
key: sccache-linux-gpu-${{ github.sha }}
restore-keys: |
sccache-linux-gpu-
- name: Build & Install
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
mkdir -m777 shared
docker create --user dev --name taichi_build --gpus all -v /tmp/.X11-unix:/tmp/.X11-unix \
-e PY -e GPU_BUILD -e PROJECT_NAME -e TAICHI_CMAKE_ARGS -e DISPLAY \
registry.taichigraphics.com/taichidev-ubuntu18.04:v0.1.1 \
/home/dev/taichi/.github/workflows/scripts/unix_build.sh
# A tarball is needed because sccache needs some permissions that only the file owner has.
# 1000 is the uid and gid of user "dev" in the container.
# If the uid or gid of the user inside the docker changes, please change the uid and gid in the following line.
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx --owner 1000 --group 1000 | docker cp - taichi_build:/home/dev/
docker start -a taichi_build
rm -rf sccache_cache
docker cp taichi_build:/home/dev/taichi/sccache_cache sccache_cache
docker cp taichi_build:/home/dev/taichi/dist shared/dist
docker cp taichi_build:/home/dev/taichi/build shared/build
env:
PY: py38
GPU_BUILD: ON
PROJECT_NAME: taichi
TAICHI_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=ON -DTI_WITH_CC:BOOL=OFF -DTI_WITH_VULKAN:BOOL=ON -DTI_BUILD_TESTS:BOOL=ON -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
DISPLAY: :1
- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
docker create --user dev --name taichi_test --gpus all -v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY -e PY -e GPU_TEST -e TI_WANTED_ARCHS \
registry.taichigraphics.com/taichidev-ubuntu18.04:v0.1.1 \
/home/dev/unix_test.sh
docker cp .github/workflows/scripts/unix_test.sh taichi_test:/home/dev/unix_test.sh
docker cp shared/dist/ taichi_test:/home/dev/
docker cp shared/build/ taichi_test:/home/dev/
docker cp tests/ taichi_test:/home/dev/
docker start -a taichi_test
env:
PY: py38
GPU_TEST: ON
DISPLAY: :1
TI_WANTED_ARCHS: "cpu,cuda,vulkan,opengl"
- name: clean docker container
if: always()
run: |
docker rm taichi_build taichi_test -f
build_and_test_windows:
name: Build and Test Windows
needs: [check_code_format, check_files]
runs-on: [self-hosted, windows, gpu]
timeout-minutes: 90
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Add Visual Studio Shell to ENV
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Get sccache cache
uses: actions/cache@v2
with:
path: ccache_cache
key: ccache-win64-${{ github.sha }}
restore-keys: |
ccache-win64-
- name: Build
shell: powershell
run: |
if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) {
exit 0
}
.\.github\workflows\scripts\win_build.ps1 -installVulkan -install -libsDir C:\
- name: Test
shell: powershell
run: |
if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) {
exit 0
}
.\.github\workflows\scripts\win_test.ps1
env:
TI_WANTED_ARCHS: cpu,cuda,opengl
TAICHI_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=ON -DTI_WITH_CC:BOOL=OFF
TI_SKIP_VERSION_CHECK: ON
build_and_test_m1:
name: Build and Test (Apple M1)
needs: [check_code_format, check_files]
timeout-minutes: 60
strategy:
matrix:
include:
- os: macos-latest
python: 3.8
defaults:
run:
# https://github.com/actions/runner/issues/805#issuecomment-844426478
shell: "/usr/bin/arch -arch arm64e /bin/bash --noprofile --norc -eo pipefail {0}"
runs-on: [self-hosted, m1]
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Get sccache cache
uses: actions/cache@v2
with:
path: sccache_cache
key: sccache-m1-${{ github.sha }}
restore-keys: |
sccache-m1-
- name: Build
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
rm -rf $HOME/Library/Python/3.8/lib/python/site-packages/taichi
brew install molten-vk
.github/workflows/scripts/unix_build.sh
env:
TAICHI_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CUDA:BOOL=OFF -DTI_WITH_CC:BOOL=OFF -DTI_WITH_VULKAN:BOOL=ON -DTI_BUILD_TESTS:BOOL=ON -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
CXX: clang++
- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
export PATH=$PATH:$HOME/Library/Python/3.8/bin
.github/workflows/scripts/unix_test.sh
env:
TI_WANTED_ARCHS: "metal,vulkan,cpu"