diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 3be6df8..25480c6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -9,18 +9,20 @@ on: pull_request: paths-ignore: - '**.md' - + jobs: test: runs-on: ${{ matrix.os }} + strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.7', '3.8', '3.9'] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: install deps @@ -34,7 +36,7 @@ jobs: # missing tests, sorry #- name: coveralls # if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' - # env: + # env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # run: coveralls - name: pylint @@ -45,12 +47,12 @@ jobs: run: | pytest --opentmi localhost:3000 --opentmi_token 123 --metadata foo bar --metadata DUT_SERIAL_NUMBER 123 --metadata DUT_MODEL S5 --metadata DUT_VENDOR samsang example.py - name: Archive artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: artifacts + name: artifacts-${{ runner.os }}-${{ matrix.python-version }} path: | - htmlcov - junit + htmlcov/* + junit/* - name: install rel deps if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' run: | diff --git a/.github/workflows/codeball.yml b/.github/workflows/codeball.yml deleted file mode 100644 index 43295e7..0000000 --- a/.github/workflows/codeball.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Codeball -on: - pull_request: {} - pull_request_review_comment: - types: [created, edited] - -jobs: - codeball_job: - runs-on: ubuntu-latest - name: Codeball - steps: - - name: Codeball - uses: sturdy-dev/codeball-action@v2 - with: - # For all configuration options see https://github.com/sturdy-dev/codeball-action/blob/v2/action.yml - approvePullRequests: "true" - labelPullRequestsWhenApproved: "true" - labelPullRequestsWhenReviewNeeded: "false" - failJobsWhenReviewNeeded: "false" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 46c3b73..94b02f8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. diff --git a/LICENSE b/LICENSE index 5285f42..c13f991 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 +Copyright (c) 2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/pylintrc b/pylintrc index 18bd28a..c423d50 100644 --- a/pylintrc +++ b/pylintrc @@ -50,7 +50,7 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,useless-object-inheritance +disable=logging-fstring-interpolation # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -233,12 +233,6 @@ max-line-length=120 # Maximum number of lines in a module max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no @@ -250,14 +244,9 @@ single-line-if-stmt=no [BASIC] -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct argument names argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Regular expression matching correct attribute names attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ @@ -265,21 +254,12 @@ attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - # Regular expression matching correct class names class-rgx=[A-Z_][a-zA-Z0-9]+$ -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct constant names const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ @@ -287,33 +267,18 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ # ones are exempt. docstring-min-length=-1 -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct function names function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Good variable names which should always be accepted, separated by a comma good-names=i,j,k,ex,Run,_ -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct method names method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ @@ -329,9 +294,6 @@ no-docstring-rgx=^_ # to this list to register other decorators that produce valid properties. property-classes=abc.abstractproperty -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct variable names variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ diff --git a/pytest_opentmi/OpenTmiReport.py b/pytest_opentmi/OpenTmiReport.py index 5700508..9a8656c 100644 --- a/pytest_opentmi/OpenTmiReport.py +++ b/pytest_opentmi/OpenTmiReport.py @@ -6,6 +6,7 @@ import datetime import uuid import inspect +import logging from multiprocessing.dummy import Pool as ThreadPool # 3rd party modules from opentmi_client import OpenTmiClient, Result @@ -13,6 +14,8 @@ # app modules from . import __pytest_info__ +logger = logging.getLogger(__name__) + # pylint: disable=too-many-instance-attributes class OpenTmiReport: @@ -283,7 +286,8 @@ def _link_session(self, session, result): # pylint: disable=unused-argument def _upload_report(self, result: Result): try: data = self._client.post_result(result) - print(data) + logger.info(f"Uploaded {result.tcid} successfully, id: {data['id']}") + logger.debug(f"Uploaded {result.tcid} successfully, data: {data}") self._uploaded_success += 1 except Exception: # pylint: disable=broad-except self._uploaded_failed += 1 @@ -298,8 +302,11 @@ def _upload_reports(self, session): [self._link_session(session, result) for result in self.results] # pylint: disable=expression-not-assigned - [print(result.data) for result in self.results] - [print(test) for test in self.tests] + logger.info(f'Test results to be upload ({len(self.results)})') + [logger.debug(result.data) for result in self.results] + + logger.info(f'Test cases to be upload ({len(self.tests)})') + [logger.debug(test) for test in self.tests] token = self.config.getoption("opentmi_token") pool = ThreadPool(10) @@ -310,8 +317,9 @@ def _upload_reports(self, session): pool.map(self._upload_report, self.results) pool.close() pool.join() + logger.info('All results uploaded successfully') except Exception as error: # pylint: disable=broad-except - print(error) + logger.error(error) @staticmethod def _get_test_key(item): diff --git a/pytest_opentmi/plugin.py b/pytest_opentmi/plugin.py index e86e101..ad88cdf 100644 --- a/pytest_opentmi/plugin.py +++ b/pytest_opentmi/plugin.py @@ -2,10 +2,13 @@ pytest plugin """ import os +import logging # app modules from . import __version__ from .OpenTmiReport import OpenTmiReport +logger = logging.getLogger(__name__) + # pylint: disable=unused-argument def pytest_report_header(config): @@ -59,6 +62,7 @@ def pytest_configure(config): # prevent opening opentmi reporter on slave nodes (xdist) config._opentmi = OpenTmiReport(config) # pylint: disable=protected-access config.pluginmanager.register(config._opentmi) # pylint: disable=protected-access + logger.debug(f'Opentmi reporter enabled: {host}') def pytest_unconfigure(config): diff --git a/setup.py b/setup.py index 8f31207..af74765 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ # Similar to `install_requires` above, these must be valid existing # projects. extras_require={ # Optional - 'dev': ['coverage', 'coveralls', 'mock', 'pylint==2.15.10', 'nose', 'pyinstaller'] + 'dev': ['coverage', 'coveralls', 'mock', 'pylint==2.15.10', 'pynose', 'pyinstaller'] }, license="Mozilla Public License 2.0 (MPL 2.0)", keywords="py.test pytest opentmi report", @@ -48,9 +48,10 @@ "Topic :: Utilities", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3 :: Only", ], ) diff --git a/tox.ini b/tox.ini index 6a9cc24..fd52019 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py{36,37,py3}{,-ansi2html}, linting +envlist = py{38,py3}{,-ansi2html}, linting [testenv] setenv = PYTHONDONTWRITEBYTECODE=1 @@ -12,7 +12,7 @@ deps = pytest-xdist pytest-rerunfailures pytest-mock - py{36,37,py3}-ansi2html: ansi2html + py{38,py3}-ansi2html: ansi2html commands = pytest -v -r a {posargs} [testenv:linting]