From 9de011e3885dc2a7d4f39f4a5d289857395b3eb8 Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Tue, 22 Mar 2022 17:57:51 +0300 Subject: [PATCH 1/3] Added pylint test --- .github/workflows/build_wheels_macos.yml | 5 +++ .github/workflows/build_wheels_macos_m1.yml | 5 +++ .github/workflows/build_wheels_windows.yml | 6 ++++ tests/pylint.py | 3 ++ travis_config.sh | 37 ++++++++++----------- 5 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 tests/pylint.py diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml index c70f2b2d..2e434a5f 100644 --- a/.github/workflows/build_wheels_macos.yml +++ b/.github/workflows/build_wheels_macos.yml @@ -171,6 +171,11 @@ jobs: cd ${{ github.workspace }}/opencv python modules/python/test/test.py -v --repo . + - name: Pylint test + run: | + python -m pip install pylint + python -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring + test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build, test] diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml index 3711e1b3..46ecb631 100644 --- a/.github/workflows/build_wheels_macos_m1.yml +++ b/.github/workflows/build_wheels_macos_m1.yml @@ -106,6 +106,11 @@ jobs: cd ${{ github.workspace }}/opencv arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo . + - name: Pylint test + run: | + arch -arm64 python${{ matrix.python-version }} -m pip install pylint + arch -arm64 python${{ matrix.python-version }} -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring + test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build, test] diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml index 0262c7b8..cee1d848 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_wheels_windows.yml @@ -130,6 +130,12 @@ jobs: python modules\python\test\test.py -v --repo . shell: cmd + - name: Pylint test + run: | + python -m pip install pylint + python -m pylint ${{ github.workspace }}\tests\pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring + shell: cmd + test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build-windows-x86_64, test] diff --git a/tests/pylint.py b/tests/pylint.py new file mode 100644 index 00000000..d10ad684 --- /dev/null +++ b/tests/pylint.py @@ -0,0 +1,3 @@ +from cv2 import getStructuringElement, MORPH_ELLIPSE + +a = getStructuringElement(MORPH_ELLIPSE, (3, 3)) diff --git a/travis_config.sh b/travis_config.sh index dfb656e8..751a1772 100644 --- a/travis_config.sh +++ b/travis_config.sh @@ -141,37 +141,36 @@ function run_tests { PYTHON=python$PYTHON_VERSION - if [ -n "$IS_OSX" ]; then - echo "Running for OS X" - - cd ../tests - $PYTHON get_build_info.py - - cd ../opencv/ - export OPENCV_TEST_DATA_PATH=../opencv_extra/testdata - else - echo "Running for linux" - - if [ $PYTHON == "python3.6" ]; then - $PYTHON -m pip install -U numpy==1.19.4 - fi - cd /io/tests - $PYTHON get_build_info.py + echo "Running for linux" - cd /io/opencv - export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata + if [ $PYTHON == "python3.6" ]; then + $PYTHON -m pip install -U numpy==1.19.4 fi + cd /io/tests + $PYTHON get_build_info.py + + cd /io/opencv + export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata test_wheels + pylint_test } function test_wheels { - echo "Starting tests..." + echo "Starting OpenCV tests..." #Test package $PYTHON modules/python/test/test.py -v --repo . } +function pylint_test { + + echo "Starting Pylint tests..." + + $PYTHON -m pip install pylint + $PYTHON -m pylint /io/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring +} + export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' set -x From 1e26c5d08c182fdbb09d73bc97594bab793e79f6 Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Wed, 23 Mar 2022 10:38:47 +0300 Subject: [PATCH 2/3] Pinned pylint version --- .github/workflows/build_wheels_macos.yml | 2 +- .github/workflows/build_wheels_macos_m1.yml | 2 +- .github/workflows/build_wheels_windows.yml | 2 +- travis_config.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml index 2e434a5f..f22d56e1 100644 --- a/.github/workflows/build_wheels_macos.yml +++ b/.github/workflows/build_wheels_macos.yml @@ -173,7 +173,7 @@ jobs: - name: Pylint test run: | - python -m pip install pylint + python -m pip install pylint==2.12.2 python -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring test_release_opencv_python: diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml index 46ecb631..1f51a342 100644 --- a/.github/workflows/build_wheels_macos_m1.yml +++ b/.github/workflows/build_wheels_macos_m1.yml @@ -108,7 +108,7 @@ jobs: - name: Pylint test run: | - arch -arm64 python${{ matrix.python-version }} -m pip install pylint + arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.12.2 arch -arm64 python${{ matrix.python-version }} -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring test_release_opencv_python: diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml index cee1d848..bf9f9906 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_wheels_windows.yml @@ -132,7 +132,7 @@ jobs: - name: Pylint test run: | - python -m pip install pylint + python -m pip install pylint==2.12.2 python -m pylint ${{ github.workspace }}\tests\pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring shell: cmd diff --git a/travis_config.sh b/travis_config.sh index 751a1772..db3bf773 100644 --- a/travis_config.sh +++ b/travis_config.sh @@ -168,7 +168,7 @@ function pylint_test { echo "Starting Pylint tests..." - $PYTHON -m pip install pylint + $PYTHON -m pip install pylint==2.12.2 $PYTHON -m pylint /io/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring } From ed16e8ef97a35647aa129f167ade956e4630714f Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Wed, 23 Mar 2022 16:20:07 +0300 Subject: [PATCH 3/3] Changed using custom test for pylint to opencv sample --- .github/workflows/build_wheels_linux.yml | 2 +- .github/workflows/build_wheels_macos.yml | 4 +++- .github/workflows/build_wheels_macos_m1.yml | 4 +++- .github/workflows/build_wheels_windows.yml | 4 +++- tests/pylint.py | 3 --- tests/pylintrc | 12 ++++++++++++ travis_config.sh | 3 ++- 7 files changed, 24 insertions(+), 8 deletions(-) delete mode 100644 tests/pylint.py create mode 100644 tests/pylintrc diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml index bd42944c..5ed44e21 100644 --- a/.github/workflows/build_wheels_linux.yml +++ b/.github/workflows/build_wheels_linux.yml @@ -102,7 +102,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 with: - submodules: false + submodules: true fetch-depth: 0 - name: Setup Environment variables diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml index f22d56e1..bccec01f 100644 --- a/.github/workflows/build_wheels_macos.yml +++ b/.github/workflows/build_wheels_macos.yml @@ -137,6 +137,7 @@ jobs: CONFIG_PATH: travis_config.sh PLAT: x86_64 OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata + PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py steps: - name: Checkout @@ -174,7 +175,8 @@ jobs: - name: Pylint test run: | python -m pip install pylint==2.12.2 - python -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring + cd ${{ github.workspace }}/tests + python -m pylint $PYLINT_TEST_FILE test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml index 1f51a342..9f7b0f37 100644 --- a/.github/workflows/build_wheels_macos_m1.yml +++ b/.github/workflows/build_wheels_macos_m1.yml @@ -81,6 +81,7 @@ jobs: env: OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata + PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py steps: - name: Checkout @@ -109,7 +110,8 @@ jobs: - name: Pylint test run: | arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.12.2 - arch -arm64 python${{ matrix.python-version }} -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring + cd ${{ github.workspace }}/tests + arch -arm64 python${{ matrix.python-version }} -m pylint $PYLINT_TEST_FILE test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml index bf9f9906..337c77b2 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_wheels_windows.yml @@ -96,6 +96,7 @@ jobs: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata + PYLINT_TEST_FILE: ${{ github.workspace }}\opencv\samples\python\squares.py steps: - name: Checkout @@ -133,7 +134,8 @@ jobs: - name: Pylint test run: | python -m pip install pylint==2.12.2 - python -m pylint ${{ github.workspace }}\tests\pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring + cd ${{ github.workspace }}\tests + python -m pylint $PYLINT_TEST_FILE shell: cmd test_release_opencv_python: diff --git a/tests/pylint.py b/tests/pylint.py deleted file mode 100644 index d10ad684..00000000 --- a/tests/pylint.py +++ /dev/null @@ -1,3 +0,0 @@ -from cv2 import getStructuringElement, MORPH_ELLIPSE - -a = getStructuringElement(MORPH_ELLIPSE, (3, 3)) diff --git a/tests/pylintrc b/tests/pylintrc new file mode 100644 index 00000000..a3892018 --- /dev/null +++ b/tests/pylintrc @@ -0,0 +1,12 @@ +# Source: opencv/platforms/scripts/pylintrc + +[MESSAGES CONTROL] + +# Disable all to choose the Tests one by one +disable=all + +# Tests +enable=bad-indentation, # Used when an unexpected number of indentation’s tabulations or spaces has been found. + mixed-indentation, # Used when there are some mixed tabs and spaces in a module. + unnecessary-semicolon, # Used when a statement is ended by a semi-colon (”;”), which isn’t necessary. + unused-variable # Used when a variable is defined but not used. (Use _var to ignore var). diff --git a/travis_config.sh b/travis_config.sh index db3bf773..4560f726 100644 --- a/travis_config.sh +++ b/travis_config.sh @@ -169,7 +169,8 @@ function pylint_test { echo "Starting Pylint tests..." $PYTHON -m pip install pylint==2.12.2 - $PYTHON -m pylint /io/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring + cd /io/tests + $PYTHON -m pylint /io/opencv/samples/python/squares.py } export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'