From 8639fdb10f5c339cf44f716464b71f8787e4e9fb Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Thu, 12 Sep 2024 09:44:41 -0400 Subject: [PATCH 1/3] Static checks: introduce usage of "avocado-static-checks" project This enables the bare minimum of the avocado-static-checks usage, adds the submodule switches the "isort" check, one of the most simplistic, to the one provided by the avocado-static-checks repo. Fixes: https://github.com/avocado-framework/avocado/issues/5991 Signed-off-by: Cleber Rosa --- .github/workflows/ci.yml | 1 + .gitmodules | 3 +++ docs/source/guides/contributor/chapters/how.rst | 8 +++++++- selftests/check.py | 3 +++ selftests/isort.sh | 3 --- static-checks | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .gitmodules delete mode 100755 selftests/isort.sh create mode 160000 static-checks diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0b8641ccb..999c442a8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + submodules: true - name: Allow git to operate on directory checked out by GH Actions run: git config --global --add safe.directory `pwd` - name: Installing Avocado development dependencies diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..d9445cc719 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "static-checks"] + path = static-checks + url = https://github.com/avocado-framework/avocado-static-checks diff --git a/docs/source/guides/contributor/chapters/how.rst b/docs/source/guides/contributor/chapters/how.rst index 93feece2cf..e5daa41474 100644 --- a/docs/source/guides/contributor/chapters/how.rst +++ b/docs/source/guides/contributor/chapters/how.rst @@ -63,7 +63,13 @@ Git workflow - Clone from your fork:: - $ git clone git@github.com:/avocado.git + $ git clone --recurse-submodules git@github.com:/avocado.git + +.. note:: The ``--recurse-submodules`` option is used to checkout the + contents from the `avocado-static-checks + `_ + repository, which is not needed for general Avocado installations, + but which is very important for development purposes. - Enter the directory:: diff --git a/selftests/check.py b/selftests/check.py index ea81932dfa..575de2d8de 100755 --- a/selftests/check.py +++ b/selftests/check.py @@ -597,6 +597,9 @@ def create_suites(args): # pylint: disable=W0621 if args.dict_tests["static-checks"]: config_check_static = copy.copy(config_check) config_check_static["resolver.references"] = glob.glob("selftests/*.sh") + config_check_static["resolver.references"].append( + "static-checks/check-import-order" + ) suites.append(TestSuite.from_config(config_check_static, "static-checks")) # ======================================================================== diff --git a/selftests/isort.sh b/selftests/isort.sh deleted file mode 100755 index c257898c87..0000000000 --- a/selftests/isort.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -isort --check-only --profile black . diff --git a/static-checks b/static-checks new file mode 160000 index 0000000000..2f53ec2948 --- /dev/null +++ b/static-checks @@ -0,0 +1 @@ +Subproject commit 2f53ec2948d33e45bc7ecbbb8bf248426aae81d8 From 64b816e1026b334a22182b5fc98994de0a82ae3c Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Thu, 12 Sep 2024 09:44:41 -0400 Subject: [PATCH 2/3] Static checks: replace style with one by avocado-static-checks This replaces another one of the in-tree check scripts with the one provided by avocado-static-checks. Fixes: https://github.com/avocado-framework/avocado/issues/5989 Signed-off-by: Cleber Rosa --- selftests/check.py | 1 + selftests/style.sh | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100755 selftests/style.sh diff --git a/selftests/check.py b/selftests/check.py index 575de2d8de..10080a9271 100755 --- a/selftests/check.py +++ b/selftests/check.py @@ -600,6 +600,7 @@ def create_suites(args): # pylint: disable=W0621 config_check_static["resolver.references"].append( "static-checks/check-import-order" ) + config_check_static["resolver.references"].append("static-checks/check-style") suites.append(TestSuite.from_config(config_check_static, "static-checks")) # ======================================================================== diff --git a/selftests/style.sh b/selftests/style.sh deleted file mode 100755 index 511bccf09a..0000000000 --- a/selftests/style.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -e -echo "** Running black..." - -python3 -m black --check --diff --color . From 41edcced833141af98887959c727090a67545860 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Thu, 12 Sep 2024 09:44:41 -0400 Subject: [PATCH 3/3] Static checks: use lint check from avocado-static-checks This switches to the script provided by the avocado-static-checks repo, while using the local pylintrc configuration (set through the use of "avocado-static-checks.conf". In the near future, at least the "avocado/utils" directory needs to made compliant with the standard pylint configuration provided by avocado-static-checks, so that code can be easily moved to autils. Fixes: https://github.com/avocado-framework/avocado/issues/5990 Signed-off-by: Cleber Rosa --- avocado-static-checks.conf | 2 ++ selftests/check.py | 1 + selftests/lint.sh | 7 ------- 3 files changed, 3 insertions(+), 7 deletions(-) create mode 100644 avocado-static-checks.conf delete mode 100755 selftests/lint.sh diff --git a/avocado-static-checks.conf b/avocado-static-checks.conf new file mode 100644 index 0000000000..1248049bef --- /dev/null +++ b/avocado-static-checks.conf @@ -0,0 +1,2 @@ +[lint] +.:.pylintrc diff --git a/selftests/check.py b/selftests/check.py index 10080a9271..29a3e9f815 100755 --- a/selftests/check.py +++ b/selftests/check.py @@ -601,6 +601,7 @@ def create_suites(args): # pylint: disable=W0621 "static-checks/check-import-order" ) config_check_static["resolver.references"].append("static-checks/check-style") + config_check_static["resolver.references"].append("static-checks/check-lint") suites.append(TestSuite.from_config(config_check_static, "static-checks")) # ======================================================================== diff --git a/selftests/lint.sh b/selftests/lint.sh deleted file mode 100755 index 561b669440..0000000000 --- a/selftests/lint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -e -echo "** Running lint..." - -# Those are files from our main packages, we should follow the .pylintrc file with all -# enabled by default. Some are disabled, we are working to reduce this list. -FILES=$(git ls-files '*.py') -python3 -m pylint ${PYLINT_OPTIONS} ${FILES}