Skip to content

Commit

Permalink
[gui-tests] setup pylint for test code (#11836)
Browse files Browse the repository at this point in the history
* style: add python lint config

* test: add pylint config

* test: fix python lint

* test: fix python lint

* test: fix python lint

* ci: add python lint pipeline

* fix: lint fix command

* ci: merge lint and format
  • Loading branch information
saw-jan authored Aug 29, 2024
1 parent 8a122b9 commit 0c6a0a0
Show file tree
Hide file tree
Showing 13 changed files with 362 additions and 292 deletions.
7 changes: 3 additions & 4 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

DEFAULT_PHP_VERSION = "7.4"

PYFOUND_BLACK = "pyfound/black:24.8.0"
MYSQL = "mysql:8.0"
OC_CI_ALPINE = "owncloudci/alpine:latest"
OC_CI_BAZEL_BUILDIFIER = "owncloudci/bazel-buildifier"
Expand Down Expand Up @@ -354,10 +353,10 @@ def lint_gui_test():
def python_lint():
return [{
"name": "python-lint",
"image": PYFOUND_BLACK,
"image": OC_CI_ALPINE,
"commands": [
"cd %s" % dir["guiTest"],
"black --check --diff .",
"apk add --no-cache py3-pylint black",
"make -C %s python-lint" % dir["guiTest"],
],
}]

Expand Down
71 changes: 71 additions & 0 deletions test/gui/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[MASTER]
init-hook='import sys; sys.path.append("./shared/scripts")'

[MAIN]
enable=all
disable=
missing-docstring,
global-statement,
locally-disabled,
suppressed-message,
unused-variable,
too-many-public-methods,
bare-except,
fixme,
; TODO: enable later
invalid-name,
fail-under=10
ignore-paths=^tst_.*/test.py$|shared/scripts/names.py
ignored-modules=squish,object
load-plugins=
pylint.extensions.check_elif,
pylint.extensions.bad_builtin,
pylint.extensions.code_style,
pylint.extensions.overlapping_exceptions,
pylint.extensions.typing,
pylint.extensions.redefined_variable_type,
py-version=3.8
unsafe-load-any-extension=no

[BASIC]
attr-naming-style=snake_case
class-const-naming-style=UPPER_CASE
class-naming-style=PascalCase
const-naming-style=UPPER_CASE
function-naming-style=snake_case
method-naming-style=snake_case
module-naming-style=any
variable-naming-style=snake_case

[VARIABLES]
additional-builtins=
squish,
test,
testSettings,
OnFeatureStart,
OnFeatureEnd,
OnScenarioStart,
OnScenarioEnd,
QApplication,
Given,
When,
Then,
Step,
allow-global-unused-variables=no
dummy-variables-rgx=^hook$|^_*$|^step$
ignored-argument-names=^context$|^_*$

[STRING]
check-quote-consistency=yes

[FORMAT]
indent-string=' '
max-line-length=120

[TYPECHECK]
ignored-classes=object,test

[SIMILARITIES]
ignore-comments=yes
ignore-docstrings=yes
ignore-imports=yes
4 changes: 4 additions & 0 deletions test/gui/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
PYTHON_LINT_PATHS:=./shared/steps/* ./shared/scripts/bdd_hooks.py

.PHONY: install
install: pnpm-install pnpm-install-chromium pip-install

Expand All @@ -16,10 +18,12 @@ pip-install:
.PHONY: python-lint
python-lint:
black --check --diff .
pylint --rcfile ./.pylintrc $(PYTHON_LINT_PATHS)

.PHONY: python-lint-fix
python-lint-fix:
black .
pylint --rcfile ./.pylintrc $(PYTHON_LINT_PATHS)

.PHONY: gherkin-lint
gherkin-lint:
Expand Down
1 change: 1 addition & 0 deletions test/gui/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ requests==2.28.*; python_version >= "3.10"
PyGObject==3.42.*; python_version >= "3.10"
psutil==5.9.*; python_version >= "3.10"
black==24.2.*; python_version >= "3.10"
pylint==3.2.*; python_version >= "3.10"
pywin32==306; sys_platform == 'win32' and python_version >= "3.10"
Loading

0 comments on commit 0c6a0a0

Please sign in to comment.