Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
//

// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
ci_lint = "tlcpack/ci-lint:v0.61"
ci_lint = "tlcpack/ci-lint:v0.62"
ci_gpu = "tlcpack/ci-gpu:v0.64"
ci_cpu = "tlcpack/ci-cpu:v0.65"
ci_wasm = "tlcpack/ci-wasm:v0.60"
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ exclude = '''
| src\/
| vta\/
| web\/
)/|tests/lint/add_asf_header.py|tests/lint/check_file_type.py|python/tvm/topi/testing/pool3d_python.py|python/topi/python/test_topi_pooling.py
)/|python/topi/python/test_topi_pooling.py
|python/tvm/topi/testing/pool3d_python.py
|tests/lint/add_asf_header.py
|tests/lint/check_file_type.py
)
'''
61 changes: 61 additions & 0 deletions tests/lint/git-black.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -e
set -u
set -o pipefail

if [[ "$1" == "-i" ]]; then
INPLACE_FORMAT=1
shift 1
else
INPLACE_FORMAT=0
fi

if [[ "$#" -lt 1 ]]; then
echo "Usage: tests/lint/git-black.sh [-i] <commit>"
echo ""
echo "Run black on Python files that changed since <commit>"
echo "Examples:"
echo "- Compare last one commit: tests/lint/git-black.sh HEAD~1"
echo "- Compare against upstream/master: tests/lint/git-black.sh upstream/master"
echo "The -i will use black to format files in-place instead of checking them."
exit 1
fi

if [ ! -x "$(command -v black)" ]; then
echo "Cannot find black"
exit 1
fi

# Print out specific version
echo "Version Information: $(black --version)"

# Compute Python files which changed to compare.
IFS=$'\n' read -a FILES -d'\n' < <(git diff --name-only HEAD $1 -- "*.py" "*.pyi") || true
echo "read returned $?"
echo "Files: $FILES"

if [[ ${INPLACE_FORMAT} -eq 1 ]]; then
echo "Running black on Python files against revision" $1):
CMD=( "black" "${FILES[@]}" )
echo "${CMD[@]}"
"${CMD[@]}"
else
echo "Running black in checking mode"
black --diff --check
fi
21 changes: 21 additions & 0 deletions tests/lint/python_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -e
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.


./tests/lint/git-black.sh HEAD~1
./tests/lint/git-black.sh origin/master
17 changes: 11 additions & 6 deletions tests/scripts/task_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,27 @@ cleanup()
trap cleanup 0


echo "Check file types..."
echo "Checking file types..."
python3 tests/lint/check_file_type.py

echo "Check ASF license header..."
echo "Checking ASF license headers..."
tests/lint/check_asf_header.sh

echo "Check codestyle of c++ code..."
echo "Linting the C++ code..."
tests/lint/cpplint.sh

echo "clang-format check..."
tests/lint/clang_format.sh

echo "Check codestyle of python code..."
# TODO(@jroesch): enable black check
# echo "black check..."
# tests/lint/python_format.sh

echo "Linting the Python code..."
tests/lint/pylint.sh
echo "Check codestyle of jni code..."

echo "Lintinf the JNI code..."
tests/lint/jnilint.sh

echo "Check documentations of c++ code..."
echo "Checking C++ documentation..."
tests/lint/cppdocs.sh