Skip to content

Commit d54dcbc

Browse files
authored
Test ci fix (#95)
1 parent cc57da4 commit d54dcbc

File tree

1 file changed

+71
-267
lines changed

1 file changed

+71
-267
lines changed

.github/workflows/presubmit.yml

Lines changed: 71 additions & 267 deletions
Original file line numberDiff line numberDiff line change
@@ -2,298 +2,102 @@ name: Presubmit Checks
22
on:
33
pull_request:
44
types: [opened, synchronize, reopened]
5+
workflow_dispatch:
56

67
jobs:
7-
title_format:
8-
name: Check PR Title
9-
if: ${{ github.event.pull_request }}
8+
matrix_prep:
109
runs-on: ubuntu-latest
10+
outputs:
11+
matrix: ${{ steps.set-matrix.outputs.matrix }}
12+
matrix_osx: ${{ steps.set-matrix.outputs.matrix_osx }}
1113
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v2
14-
with:
15-
python-version: 3.8
16-
17-
- name: Run PR Title Checker
18-
run: |
19-
pip install semver GitPython
20-
python misc/ci_check_pr_title.py "$PR_TITLE"
21-
env:
22-
PR_TITLE: ${{ github.event.pull_request.title }}
23-
24-
check_code_format:
25-
name: Check Code Format
26-
runs-on: ubuntu-latest
27-
# This job will be required to pass before merging to master branch.
28-
steps:
29-
- uses: actions/checkout@v2
30-
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v2
32-
with:
33-
python-version: 3.8
34-
35-
- name: Setup git & clang-format
36-
run: |
37-
git config user.email "[email protected]"
38-
git config user.name "Taichi Gardener"
39-
git checkout -b _fake_squash
40-
git remote add upstream https://github.com/taichi-dev/taichi.git
41-
git fetch upstream master
42-
sudo apt install clang-format-10
43-
44-
- name: Cache PIP
45-
uses: actions/cache@v2
46-
with:
47-
path: ~/.cache/pip
48-
key: ${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_dev.txt') }}
49-
50-
- name: Install requirements
51-
run: |
52-
python3 -m pip install --user -r requirements_dev.txt
53-
54-
- name: Check code format
55-
run: |
56-
python3 misc/code_format.py
57-
git checkout -b _enforced_format
58-
git commit -am "enforce code format" || true
59-
# exit with 1 if there were differences:
60-
git diff _fake_squash _enforced_format --exit-code
61-
62-
- name: Pylint
63-
run: |
64-
# Make sure pylint doesn't regress
65-
pylint python/taichi/ --disable=all --enable=C0415
66-
if [ $? -eq 0 ]
67-
then
68-
echo "PASSED: pylint is happy"
69-
exit 0
70-
else
71-
echo "FAILED: please run the pylint command above and make sure it passes"
72-
exit 1
73-
fi
74-
75-
build_and_test_cpu_required:
76-
# This job will be required to pass before merging to master branch.
77-
name: Required Build and Test (CPU)
78-
needs: check_code_format
79-
timeout-minutes: 60
80-
strategy:
81-
matrix:
82-
include:
83-
- os: ubuntu-latest
84-
python: 3.6
85-
runs-on: ${{ matrix.os }}
86-
steps:
87-
- uses: actions/checkout@v2
88-
with:
89-
submodules: 'recursive'
90-
91-
- uses: actions/setup-python@v2
92-
with:
93-
python-version: ${{ matrix.python }}
94-
95-
- name: Download Pre-Built LLVM 10.0.0
14+
- id: set-matrix
9615
run: |
97-
python misc/ci_download.py
98-
mkdir taichi-llvm
99-
cd taichi-llvm
100-
unzip ../taichi-llvm.zip
101-
env:
102-
CI_PLATFORM: ${{ matrix.os }}
16+
# For nightly release, we only run on python 3.8
17+
[ -z "${{ github.event.action }}" ] && matrix="[{\"name\":\"taichi-nightly\",\"python\":\"3.8\"}]"
18+
# For production release, we run on four python versions.
19+
[ -z "${{ github.event.action }}" ] || matrix="[{\"name\":\"taichi\",\"python\":\"3.6\"},{\"name\":\"taichi\",\"python\":\"3.7\"},{\"name\":\"taichi\",\"python\":\"3.8\"},{\"name\":\"taichi\",\"python\":\"3.9\"}]"
20+
echo ::set-output name=matrix::{\"include\":$(echo $matrix)}\"
21+
# M1 only supports py38 and py39(conda), so change matrix.
22+
[ -z "${{ github.event.action }}" ] && matrix_osx="[{\"name\":\"taichi-nightly\",\"python\":\"3.8\"}]"
23+
[ -z "${{ github.event.action }}" ] || matrix_osx="[{\"name\":\"taichi\",\"python\":\"3.8\"},{\"name\":\"taichi\",\"python\":\"3.9\"}]"
24+
echo ::set-output name=matrix_osx::{\"include\":$(echo $matrix_osx)}\"
25+
build_and_upload_linux:
26+
name: Build and Upload (linux only)
27+
needs: matrix_prep
10328

104-
- name: Build & Install
105-
run: .github/workflows/scripts/unix_build.sh
106-
env:
107-
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=ON -DTI_WITH_VULKAN:BOOL=OFF -DTI_BUILD_TESTS:BOOL=ON
108-
CXX: clang++
109-
PROJECT_NAME: taichi
110-
111-
- name: Test
112-
run: .github/workflows/scripts/unix_test.sh
113-
114-
build_and_test_cpu:
115-
name: Build and Test (CPU)
116-
needs: build_and_test_cpu_required
117-
timeout-minutes: 60
11829
strategy:
119-
matrix:
120-
include:
121-
- os: macos-latest
122-
python: 3.7
123-
with_cc: OFF
124-
with_cpp_tests: ON
125-
- os: ubuntu-latest
126-
python: 3.9
127-
with_cc: OFF
128-
with_cpp_tests: OFF
129-
- os: ubuntu-latest
130-
python: 3.8
131-
with_cc: ON
132-
with_cpp_tests: OFF
133-
runs-on: ${{ matrix.os }}
30+
fail-fast: false
31+
matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }}
32+
runs-on: [self-hosted, cuda, vulkan, cn, release]
13433
steps:
13534
- uses: actions/checkout@v2
13635
with:
13736
submodules: 'recursive'
13837

139-
- uses: actions/setup-python@v2
140-
with:
141-
python-version: ${{ matrix.python }}
142-
143-
- name: Download Pre-Built LLVM 10.0.0
38+
- name: Create Python Wheel
14439
run: |
145-
python misc/ci_download.py
146-
mkdir taichi-llvm
147-
cd taichi-llvm
148-
unzip ../taichi-llvm.zip
149-
env:
150-
CI_PLATFORM: ${{ matrix.os }}
151-
152-
- name: Build & Install
153-
run: .github/workflows/scripts/unix_build.sh
154-
env:
155-
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=${{ matrix.with_cc }} -DTI_WITH_VULKAN:BOOL=OFF -DTI_BUILD_TESTS:BOOL=${{ matrix.with_cpp_tests }}
156-
CXX: clang++
157-
PROJECT_NAME: taichi
158-
# [DEBUG] Copy this step around to enable debugging inside Github Action instances.
159-
#- name: Setup tmate session
160-
# uses: mxschmitt/action-tmate@v3
161-
# with:
162-
# limit-access-to-actor: true
163-
164-
- name: Test
165-
run: .github/workflows/scripts/unix_test.sh
166-
env:
167-
RUN_CPP_TESTS: ${{ matrix.with_cpp_tests }}
168-
169-
build_and_test_gpu_linux:
170-
name: Build and Test (GPU)
171-
needs: check_code_format
172-
runs-on: [self-hosted, cuda, vulkan, cn]
173-
timeout-minutes: 60
174-
steps:
175-
- uses: actions/checkout@v2
176-
with:
177-
submodules: 'recursive'
40+
# We hacked here because conda activate in CI won't update python PATH
41+
# automatically. So we don't activate and use desired python version
42+
# directly.
43+
export PATH=/home/buildbot/miniconda3/envs/$PYTHON/bin:$PATH
44+
TAICHI_REPO_DIR=`pwd`
45+
export PATH=$LLVM_LIB_ROOT_DIR/bin:/usr/local/cuda/bin:$PATH
46+
export LLVM_DIR=$LLVM_LIB_ROOT_DIR/lib/cmake/llvm
47+
export CXX=clang++-8
48+
python3 -m pip uninstall taichi taichi-nightly -y
49+
python3 -m pip install -r requirements_dev.txt
50+
python3 -m pip install twine
51+
cd python
52+
git fetch origin master
53+
export TAICHI_CMAKE_ARGS=$CI_SETUP_CMAKE_ARGS
54+
python3 build.py build --project_name $PROJECT_NAME
55+
cd ..
56+
NUM_WHL=`ls dist/*.whl | wc -l`
57+
if [ $NUM_WHL -ne 1 ]; then echo 'ERROR: created more than 1 whl.' && exit 1; fi
58+
python3 -m pip install dist/*.whl
17859
179-
- name: Build
180-
run: |
181-
export PATH=$PATH:/usr/local/cuda/bin
182-
.github/workflows/scripts/unix_build.sh
18360
env:
18461
LLVM_LIB_ROOT_DIR: /opt/taichi-llvm-10.0.0
185-
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=ON -DTI_WITH_CC:BOOL=OFF -DTI_WITH_VULKAN:BOOL=ON
18662
BUILD_NUM_THREADS: 8
187-
LLVM_PATH: /opt/taichi-llvm-10.0.0/bin
188-
LLVM_DIR: /opt/taichi-llvm-10.0.0/lib/cmake/llvm
189-
CXX: clang++-8
190-
PROJECT_NAME: taichi
63+
CI_SETUP_CMAKE_ARGS: -DTI_WITH_VULKAN:BOOL=ON -DTI_WITH_OPENGL:BOOL=ON -DTI_WITH_CC:BOOL=OFF -DTI_BUILD_TESTS:BOOL=${{ matrix.with_cpp_tests }}
64+
PROJECT_NAME: ${{ matrix.name }}
65+
PYTHON: ${{ matrix.python }}
19166

192-
- name: Test
193-
run: .github/workflows/scripts/unix_test.sh
194-
env:
195-
DISPLAY: :1
196-
GPU_TEST: ON
197-
198-
build_and_test_windows:
199-
name: Build and Test (Windows)
200-
needs: check_code_format
201-
runs-on: windows-latest
202-
timeout-minutes: 90
203-
steps:
204-
205-
- name: Install 7Zip PowerShell
206-
shell: powershell
207-
run: Install-Module 7Zip4PowerShell -Force -Verbose
20867

209-
- uses: actions/checkout@v2
68+
- name: Archive Wheel Artifacts
69+
uses: actions/upload-artifact@v2
21070
with:
211-
submodules: 'recursive'
212-
213-
- uses: actions/setup-python@v2
214-
with:
215-
python-version: 3.7
216-
217-
- name: Add msbuild to PATH
218-
uses: microsoft/[email protected]
219-
220-
- name: Download And Install Vulkan
221-
shell: powershell
222-
run: |
223-
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe" -OutFile VulkanSDK.exe
224-
$installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList @("/S");
225-
$installer.WaitForExit();
226-
227-
- name: Build
228-
shell: powershell
229-
run: |
230-
$env:Path += ";C:/VulkanSDK/1.2.189.0/Bin"
231-
cd C:\
232-
Remove-item alias:curl
233-
curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/taichi-llvm-10.0.0-msvc2019.zip -LO
234-
7z x taichi-llvm-10.0.0-msvc2019.zip -otaichi_llvm
235-
curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/clang-10.0.0-win.zip -LO
236-
7z x clang-10.0.0-win.zip -otaichi_clang
237-
$env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH
238-
clang --version
239-
cd D:\a\taichi\taichi
240-
python -m pip install -r requirements_dev.txt
241-
cd python
242-
git fetch origin master
243-
$env:TAICHI_CMAKE_ARGS = $env:CI_SETUP_CMAKE_ARGS
244-
python build.py build
245-
cd ..\dist
246-
$env:WHL = $(dir *.whl)
247-
python -m pip install $env:WHL
248-
env:
249-
PYTHON: C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe
250-
CI_SETUP_CMAKE_ARGS: -G "Visual Studio 16 2019" -A x64 -DLLVM_DIR=C:\taichi_llvm\lib\cmake\llvm -DTI_WITH_VULKAN:BOOL=ON
251-
VULKAN_SDK: C:/VulkanSDK/1.2.189.0
71+
name: ${{ matrix.name }}-py${{ matrix.python }}-linux.whl
72+
path: dist/*.whl
25273

25374
- name: Test
254-
shell: powershell
25575
run: |
256-
$env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH
257-
python -c "import taichi"
258-
python examples/algorithm/laplace.py
259-
python bin/taichi diagnose
260-
python bin/taichi changelog
261-
python bin/taichi test -vr2 -t2
76+
export PATH=/home/buildbot/miniconda3/envs/$PYTHON/bin:$PATH
77+
python3 examples/algorithm/laplace.py
78+
export DISPLAY=:1
79+
hash -r
80+
glewinfo
81+
ti diagnose
82+
ti changelog
83+
ti test -vr2 -t2 -k "not ndarray and not torch"
84+
# ndarray test might OOM if run with -t2.
85+
# FIXME: unify this with presubmit.yml to avoid further divergence
86+
ti test -vr2 -t1 -k "ndarray or torch"
26287
env:
263-
PYTHON: C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe
88+
PYTHON: ${{ matrix.python }}
26489

265-
build_and_test_m1:
266-
name: Build and Test (Apple M1)
267-
needs: check_code_format
268-
timeout-minutes: 60
269-
strategy:
270-
matrix:
271-
include:
272-
- os: macos-latest
273-
python: 3.8
274-
defaults:
275-
run:
276-
# https://github.com/actions/runner/issues/805#issuecomment-844426478
277-
shell: "/usr/bin/arch -arch arm64e /bin/bash --noprofile --norc -eo pipefail {0}"
278-
runs-on: [self-hosted, m1]
279-
steps:
280-
- uses: actions/checkout@v2
281-
with:
282-
submodules: 'recursive'
283-
284-
- name: Build
285-
run: |
286-
rm -rf $HOME/Library/Python/3.8/lib/python/site-packages/taichi
287-
.github/workflows/scripts/unix_build.sh
90+
- name: Upload PyPI
28891
env:
289-
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CUDA:BOOL=OFF -DTI_WITH_CC:BOOL=OFF -DTI_WITH_VULKAN:BOOL=OFF -DTI_BUILD_TESTS:BOOL=ON
290-
CXX: clang++
291-
PROJECT_NAME: taichi
92+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#using-encrypted-secrets-in-a-workflow
93+
PROD_PWD: ${{ secrets.PYPI_PWD_PROD }}
94+
NIGHT_PWD: ${{ secrets.PYPI_PWD_NIGHTLY }}
95+
PROJECT_NAME: ${{ matrix.name }}
96+
PYTHON: ${{ matrix.python }}
29297

293-
- name: Test
29498
run: |
295-
export PATH=$PATH:$HOME/Library/Python/3.8/bin
296-
python3 examples/algorithm/laplace.py
297-
TI_LIB_DIR=`python3 -c "import taichi;print(taichi.__path__[0])" | tail -1`
298-
TI_LIB_DIR="$TI_LIB_DIR/lib" ./build/taichi_cpp_tests
299-
ti test -vr2 -t4 -x
99+
export PATH=/home/buildbot/miniconda3/envs/$PYTHON/bin:$PATH
100+
cd python
101+
if [ $PROJECT_NAME == "taichi-nightly" ]; then export PYPI_PWD="$NIGHT_PWD" && python3 build.py upload --skip_build --testpypi --project_name $PROJECT_NAME
102+
elif [ $PROJECT_NAME == "taichi" ]; then export PYPI_PWD="$PROD_PWD" && python3 build.py upload --skip_build; fi
103+

0 commit comments

Comments
 (0)