-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Workflow] Use pre-commit hooks to check codes (#4633)
* Use pre-commit hooks * Add pylint to pre-commit hooks * Update the docs * add pre-commit to requirements-dev * make both yapf and isort happy * change the update schedule * remove code_format.py * turn off yapf for one line
- Loading branch information
Showing
21 changed files
with
104 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ jobs: | |
issue-type: pull-request | ||
permission: triage | ||
commands: | | ||
format | ||
benchmark | ||
rebase | ||
rerun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,75 +57,14 @@ jobs: | |
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 | ||
submodules: 'recursive' | ||
|
||
- name: clang-tidy | ||
run: | | ||
|
@@ -145,27 +84,27 @@ jobs: | |
|
||
build_and_test_cpu_linux: | ||
name: Build and Test linux (CPU) | ||
needs: [check_code_format, check_files] | ||
needs: check_files | ||
timeout-minutes: 60 | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
python: py39 | ||
with_cc: ON | ||
wanted_archs: "cpu,cc" | ||
wanted_archs: 'cpu,cc' | ||
- os: ubuntu-latest | ||
python: py310 | ||
with_cc: ON | ||
wanted_archs: "cpu,cc" | ||
wanted_archs: 'cpu,cc' | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
packages: read | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: "recursive" | ||
submodules: 'recursive' | ||
|
||
- name: Get sccache cache | ||
uses: actions/cache@v2 | ||
|
@@ -234,7 +173,7 @@ jobs: | |
build_and_test_cpu_mac: | ||
name: Build and Test macos (CPU) | ||
needs: [check_code_format, check_files] | ||
needs: check_files | ||
timeout-minutes: 60 | ||
strategy: | ||
matrix: | ||
|
@@ -243,12 +182,12 @@ jobs: | |
python: 3.7 | ||
with_cc: OFF | ||
with_cpp_tests: ON | ||
wanted_archs: "cpu" | ||
wanted_archs: 'cpu' | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: "recursive" | ||
submodules: 'recursive' | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
|
@@ -302,13 +241,13 @@ jobs: | |
|
||
build_and_test_gpu_linux: | ||
name: Build and Test (GPU) | ||
needs: [check_code_format, check_files] | ||
needs: check_files | ||
runs-on: [self-hosted, cuda, vulkan, cn] | ||
timeout-minutes: 60 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: "recursive" | ||
submodules: 'recursive' | ||
|
||
- name: Get sccache cache | ||
uses: actions/cache@v2 | ||
|
@@ -364,7 +303,7 @@ jobs: | |
PY: py38 | ||
GPU_TEST: ON | ||
DISPLAY: :1 | ||
TI_WANTED_ARCHS: "cpu,cuda,vulkan,opengl" | ||
TI_WANTED_ARCHS: 'cpu,cuda,vulkan,opengl' | ||
TI_DEVICE_MEMORY_GB: '0.7' | ||
|
||
- name: clean docker container | ||
|
@@ -374,7 +313,7 @@ jobs: | |
build_and_test_windows: | ||
name: Build and Test Windows | ||
needs: [check_code_format, check_files] | ||
needs: check_files | ||
runs-on: [self-hosted, windows, gpu] | ||
timeout-minutes: 90 | ||
steps: | ||
|
@@ -386,7 +325,7 @@ jobs: | |
- uses: actions/checkout@v2 | ||
with: | ||
submodules: "recursive" | ||
submodules: 'recursive' | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
|
@@ -421,12 +360,12 @@ jobs: | |
TAICHI_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=ON -DTI_WITH_CC:BOOL=OFF | ||
TI_SKIP_VERSION_CHECK: ON | ||
TI_CI: 1 | ||
PYTHON: "3.7" | ||
PYTHON: '3.7' | ||
TI_DEVICE_MEMORY_GB: '0.7' | ||
|
||
build_and_test_m1: | ||
name: Build and Test (Apple M1) | ||
needs: [check_code_format, check_files] | ||
needs: check_files | ||
timeout-minutes: 60 | ||
strategy: | ||
matrix: | ||
|
@@ -436,12 +375,12 @@ jobs: | |
defaults: | ||
run: | ||
# https://github.com/actions/runner/issues/805#issuecomment-844426478 | ||
shell: "/usr/bin/arch -arch arm64e /bin/bash --noprofile --norc -eo pipefail {0}" | ||
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" | ||
submodules: 'recursive' | ||
|
||
- name: Get sccache cache | ||
uses: actions/cache@v2 | ||
|
@@ -472,7 +411,7 @@ jobs: | |
export PATH=/Users/github/miniforge3/envs/$PY/bin:$PATH | ||
.github/workflows/scripts/unix_test.sh | ||
env: | ||
TI_WANTED_ARCHS: "metal,vulkan,cpu" | ||
TI_WANTED_ARCHS: 'metal,vulkan,cpu' | ||
PY: ${{ matrix.python }} | ||
PLATFORM: "m1" | ||
PLATFORM: 'm1' | ||
TI_CI: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
ci: | ||
autoupdate_schedule: quarterly | ||
|
||
exclude: ^((tests/python/test_exception|.*/examples/.*)\.py$|external/) | ||
repos: | ||
- repo: https://github.com/google/yapf | ||
rev: v0.31.0 | ||
hooks: | ||
- id: yapf | ||
additional_dependencies: [toml] | ||
|
||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v10.0.1 | ||
hooks: | ||
- id: clang-format | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
|
||
- repo: https://github.com/PyCQA/pylint | ||
rev: v2.13.1 | ||
hooks: | ||
- id: pylint | ||
args: ['-rn', '-sn'] | ||
files: ^python/taichi/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
[MESSAGES CONTROL] | ||
disable=invalid-name, missing-function-docstring, missing-class-docstring, missing-module-docstring, unused-wildcard-import, cyclic-import, blacklisted-name, import-outside-toplevel | ||
disable=all | ||
enable= | ||
C0121,C0200,C0209,C0321,C0325,C0415, | ||
W0101,W0108,W0202,W0235,W0401,W0404,W0611,W0621,W0622,W612,W1309, | ||
E1101, | ||
R0201,R0205,R0402,R1703,R1705,R1710,R1732 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.