Skip to content

Commit

Permalink
python: Integrate linting tools
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax committed Apr 12, 2021
1 parent 4ecf3f7 commit 257c507
Show file tree
Hide file tree
Showing 15 changed files with 1,785 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ cmake-build-debug
/linux
bazel.output.txt
*~
.coverage
7 changes: 7 additions & 0 deletions .yapfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*generated*
*venv*
*protos*
*~
*_pb2.py
*tests*
*#*
7 changes: 0 additions & 7 deletions bazel/repositories_extra.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_fetch_
def _python_deps():
py_repositories()

# REMOVE!!!
pip_install(
name = "sometools_pip3",
requirements = "@envoy//tools/sometools:requirements.txt",
extra_pip_args = ["--require-hashes"],
)

pip_install(
name = "config_validation_pip3",
requirements = "@envoy//tools/config_validation:requirements.txt",
Expand Down
8 changes: 5 additions & 3 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ set -e

build_setup_args=""
if [[ "$1" == "format_pre" || "$1" == "fix_format" || "$1" == "check_format" || "$1" == "check_repositories" || \
"$1" == "check_spelling" || "$1" == "fix_spelling" || "$1" == "bazel.clang_tidy" || \
"$1" == "check_spelling_pedantic" || "$1" == "fix_spelling_pedantic" ]]; then
build_setup_args="-nofetch"
"$1" == "check_spelling" || "$1" == "fix_spelling" || "$1" == "bazel.clang_tidy" || "$1" == "tooling" || \
"$1" == "check_spelling_pedantic" || "$1" == "fix_spelling_pedantic" ]]; then
build_setup_args="-nofetch"
fi

# TODO(phlax): Clarify and/or integrate SRCDIR and ENVOY_SRCDIR
Expand Down Expand Up @@ -470,8 +470,10 @@ elif [[ "$CI_TARGET" == "tooling" ]]; then
echo "Run pytest tooling tests..."
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/testing:pytest_python_pytest -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/testing:pytest_python_coverage -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/base:pytest_checker -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/base:pytest_runner -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/base:pytest_utils -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/code_format:pytest_python_check -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/testing:python_coverage -- --fail-under=95 /tmp/.coverage-envoy /source/generated/tooling
exit 0
elif [[ "$CI_TARGET" == "verify_examples" ]]; then
Expand Down
12 changes: 1 addition & 11 deletions ci/format_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,8 @@ CURRENT=shellcheck
CURRENT=configs
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //configs:example_configs_validation

# TODO(phlax): update to use bazel and python_flake8/python_check
# this will simplify this code to a single line
CURRENT=python
"${ENVOY_SRCDIR}"/tools/code_format/format_python_tools.sh check || {
"${ENVOY_SRCDIR}"/tools/code_format/format_python_tools.sh fix
git diff HEAD | tee "${DIFF_OUTPUT}"
raise () {
# this throws an error without exiting
return 1
}
raise
}
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/code_format:python_check -- --diff-file="$DIFF_OUTPUT" --fix "$(pwd)"

if [[ "${#FAILED[@]}" -ne "0" ]]; then
echo "TESTS FAILED:" >&2
Expand Down
2 changes: 2 additions & 0 deletions tools/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ licenses(["notice"]) # Apache 2

envoy_package()

envoy_py_library("tools.base.checker")

envoy_py_library("tools.base.runner")

envoy_py_library("tools.base.utils")
Loading

0 comments on commit 257c507

Please sign in to comment.