From 3c665729fc2b0e4c78719cf004c880ce0d085ac0 Mon Sep 17 00:00:00 2001 From: Melih Yalcin Date: Wed, 29 Jun 2022 11:58:58 +0100 Subject: [PATCH] integrate autopep8 to presubmit --- kokoro/presubmit/build.sh | 4 ++++ kokoro/presubmit/presubmit.sh | 8 ++++++++ .../vulkan_parser/spirv_capabilities_parser.py | 8 ++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/kokoro/presubmit/build.sh b/kokoro/presubmit/build.sh index 004a3df3a2..485e35b13f 100755 --- a/kokoro/presubmit/build.sh +++ b/kokoro/presubmit/build.sh @@ -45,12 +45,16 @@ sudo apt-get install -y clang-format-6.0 # Get recent Android build tools. echo y | $ANDROID_HOME/tools/bin/sdkmanager --install 'build-tools;30.0.3' +# Python Format tool +python3 -m pip install autopep8==1.6.0 --user + # Setup environment. export ANDROID_NDK_HOME=/opt/android-ndk-r16b export BAZEL=$BUILD_ROOT/bazel/bin/bazel export BUILDIFIER=$BUILD_ROOT/tools/bin/buildifier export BUILDOZER=$BUILD_ROOT/tools/bin/buildozer export CLANG_FORMAT=clang-format-6.0 +export AUTOPEP8=autopep8 cd $SRC diff --git a/kokoro/presubmit/presubmit.sh b/kokoro/presubmit/presubmit.sh index e47aa37e38..742ac6b9cc 100755 --- a/kokoro/presubmit/presubmit.sh +++ b/kokoro/presubmit/presubmit.sh @@ -18,6 +18,7 @@ BAZEL=${BAZEL:-bazel} BUILDIFIER=${BUILDIFIER:-buildifier} BUILDOZER=${BUILDOZER:-buildozer} CLANG_FORMAT=${CLANG_FORMAT:-clang-format} +AUTOPEP8=${AUTOPEP8:-autopep8} if test -t 1; then ncolors=$(tput colors) @@ -102,6 +103,10 @@ function run_gofmt() { find . -name "*.go" | xargs $GOFMT -w } +function run_autopep8() { + $AUTOPEP8 --global-config=tools/build/python/pep8 -r --in-place vulkan_generator +} + # Ensure we are clean to start out with. check "git workspace must be clean" true @@ -127,5 +132,8 @@ check "gazelle" run_gazelle # installed its Go SDK (as a dependency to run Gazelle). check gofmt run_gofmt +# Check python Formatter(autopep8) +check autopep8 run_autopep8 + echo echo "${green}All check completed successfully.$normal" diff --git a/vulkan_generator/vulkan_parser/spirv_capabilities_parser.py b/vulkan_generator/vulkan_parser/spirv_capabilities_parser.py index 7ed0178f95..74d2da69a9 100644 --- a/vulkan_generator/vulkan_parser/spirv_capabilities_parser.py +++ b/vulkan_generator/vulkan_parser/spirv_capabilities_parser.py @@ -52,9 +52,5 @@ def parse(spirv_element: ET.Element) -> types.SpirvCapability: else: raise SyntaxError(f"Unknown Spirv capability type: {ET.tostring(spirv_element, 'utf-8')}") - return types.SpirvCapability( - name=name, - version=version, - feature=feature, - property=vulkan_property, - extension=extension) + # Break this lines format intentionally to test presubmit(autopep8) + return types.SpirvCapability(name=name, version=version, feature=feature, property=vulkan_property, extension=extension)