From 1dd2409e023fa5d0a48566c0e27cddc1a5f4093a Mon Sep 17 00:00:00 2001 From: Michka Popoff Date: Mon, 31 Jul 2023 22:22:20 +0400 Subject: [PATCH] Run pycodestyle from github actions This makes the outputs more readable Tests will fail on pycodestyle failure, to have a quicker feedback loop when debugging failed builds --- .github/workflows/tests.yml | 4 ++ unittests/pep8_tester.py | 95 ------------------------------------- unittests/test_all.py | 2 - 3 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 unittests/pep8_tester.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0d1f118f..07405612 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -64,6 +64,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" + - name: Install pycodestyle + run: pip install pycodestyle + - name: Run pycodestyle + run: pycodestyle . --exclude=docs - name: Setup castxml for Linux if: matrix.os == 'ubuntu-20.04' && matrix.castxml == 'castxml' run: | diff --git a/unittests/pep8_tester.py b/unittests/pep8_tester.py deleted file mode 100644 index 3405de42..00000000 --- a/unittests/pep8_tester.py +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright 2014-2017 Insight Software Consortium. -# Copyright 2004-2009 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt - -import os -import unittest -import fnmatch - -import pycodestyle - - -class Test(unittest.TestCase): - - def test_pep8_conformance_unitests(self): - """ - Pep8 conformance test (unitests) - - Runs on the unittest directory. - """ - - # Get the path to current directory - path = os.path.dirname(os.path.realpath(__file__)) - - self.run_check(path) - - def test_pep8_conformance_pygccxml(self): - """ - Pep8 conformance test (pygccxml) - - Runs on the pygccxml directory. - """ - - # Get the path to current directory - path = os.path.dirname(os.path.realpath(__file__)) - path += "/../pygccxml/" - - self.run_check(path) - - def test_pep8_conformance_example(self): - """ - Pep8 conformance test (examples) - - Runs on the example file in the docs. - """ - - # Get the path to current directory - path = os.path.dirname(os.path.realpath(__file__)) - path += "/../docs/examples/" - - # Find all the examples files - file_paths = [] - for root, dirnames, filenames in os.walk(path): - for file_path in fnmatch.filter(filenames, '*.py'): - file_paths.append(os.path.join(root, file_path)) - - for path in file_paths: - self.run_check(path) - - def test_pep8_conformance_setup(self): - """ - Pep8 conformance test (setup) - - Runs on the setup.py file - """ - - # Get the path to current directory - path = os.path.dirname(os.path.realpath(__file__)) - path += "/../setup.py" - - self.run_check(path) - - def run_check(self, path): - """Common method to run the pep8 test.""" - - result = pycodestyle.StyleGuide().check_files(paths=[path]) - - if result.total_errors != 0: - self.assertEqual( - result.total_errors, 0, - "Found code style errors (and warnings).") - - -def create_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(Test)) - return suite - - -def run_suite(): - unittest.TextTestRunner(verbosity=2).run(create_suite()) - - -if __name__ == "__main__": - run_suite() diff --git a/unittests/test_all.py b/unittests/test_all.py index 28c3a2dd..cd3408ac 100644 --- a/unittests/test_all.py +++ b/unittests/test_all.py @@ -60,7 +60,6 @@ from . import gccxml10185_tester from . import inline_specifier_tester from . import test_create_decl_string -from . import pep8_tester from . import example_tester from . import test_utils from . import test_va_list_tag_removal @@ -90,7 +89,6 @@ from . import test_ccflags testers = [ - pep8_tester, decl_string_tester, declaration_files_tester, declarations_comparison_tester,