bisect-kit: Add isort tool for format check
BUG=b:247338352
TEST=./run_tests.sh
Change-Id: Ia8d5b2a9e79504e55ba55ae753a8826b52988263
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/bisect-kit/+/3990448
Commit-Queue: Ace Wu <acewu@chromium.org>
Reviewed-by: Zheng-Jie Chang <zjchang@chromium.org>
Tested-by: Ace Wu <acewu@chromium.org>
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
index 3b6b71f..bdaeb8b 100644
--- a/PRESUBMIT.cfg
+++ b/PRESUBMIT.cfg
@@ -1,2 +1,2 @@
-[Hooks Scripts]
-hook0 = ../../../chromite/bin/cros lint ${PRESUBMIT_FILES}
+[Hook Scripts]
+isort_check: isort --check .
diff --git a/pyproject.toml b/pyproject.toml
index a43925a..093bec6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,6 +2,23 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+[tool.isort]
+profile = "black"
+line_length = 80
+lines_after_imports = 2
+skip_glob = [
+ "third_party",
+ "internal",
+ "venv",
+]
+extend_skip_glob = "*_pb2.py"
+length_sort = false
+force_single_line = true
+from_first = false
+case_sensitive = false
+force_sort_within_sections = true
+order_by_type = false
+
[tool.pytest.ini_options]
minversion = "6.0"
addopts = [
@@ -13,5 +30,6 @@
]
norecursedirs = [
"third_party",
+ "internal",
"venv",
]
diff --git a/requirements_dev.txt b/requirements_dev.txt
index 9cda381..8e6081b 100644
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@ -1,2 +1,3 @@
+#isort # provided by depot_tool
pytest
pytest-xdist
diff --git a/run_formatters.sh b/run_formatters.sh
new file mode 100755
index 0000000..f90247b
--- /dev/null
+++ b/run_formatters.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Print all commands being executed
+set -x
+
+# Exit immediately if any command exits with a non-zero status
+set -e
+
+# Change pwd to the directory containing this script.
+cd "$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")"
+
+# Update depot_tools
+update_depot_tools
+
+# Format python files with isort.
+isort .
diff --git a/run_tests.sh b/run_tests.sh
index ef15a15..717dd0c 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -3,10 +3,20 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# Print all commands being executed
set -x
+
+# Exit immediately if any command exits with a non-zero status
set -e
-# change pwd to the directory containing this script
+# Change pwd to the directory containing this script
cd "$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")"
+# Update depot_tools
+update_depot_tools
+
+# Check python format with isort.
+isort --check .
+
+# Run test cases with pytest.
pytest -v