From cfdff6a993999aae47c5fb6501db81dabf5fd954 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 17 Jan 2024 23:01:19 +0100 Subject: [PATCH 1/3] Set tests_directory to empty. --- .github/workflows/ApplicationTesting.yml | 42 +++++++++++++++--------- .github/workflows/UnitTesting.yml | 12 +++---- doc/coverage/index.rst | 2 +- doc/requirements.txt | 2 +- doc/unittests/index.rst | 2 +- pyproject.toml | 10 +++++- requirements.txt | 2 +- setup.py | 7 ++-- 8 files changed, 49 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ApplicationTesting.yml b/.github/workflows/ApplicationTesting.yml index c4830c6a..64b12a35 100644 --- a/.github/workflows/ApplicationTesting.yml +++ b/.github/workflows/ApplicationTesting.yml @@ -52,14 +52,14 @@ on: tests_directory: description: 'Path to the directory containing tests (test working directory).' required: false - default: 'tests' + default: '' type: string apptest_directory: description: 'Path to the directory containing application tests (relative to tests_directory).' required: false default: 'app' type: string - artifact: + apptest_xml_artifact: description: "Generate application test report with junitxml and upload results as an artifact." required: false default: '' @@ -202,29 +202,41 @@ jobs: - name: 🔧 Install wheel from artifact run: python -m pip install --disable-pip-version-check -U install/*.whl + - name: ☑ Run application tests (Ubuntu/macOS) + if: matrix.system != 'windows' + run: | + export ENVIRONMENT_NAME="${{ matrix.envname }}" + + cd "${{ inputs.tests_directory || '.' }}" + [ -n '${{ inputs.apptest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=report/unit/TestReportSummary.xml' || unset PYTEST_ARGS + if [ -n '${{ inputs.coverage_config }}' ]; then + echo "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }}" + coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }} + else + echo "python -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }}" + python -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }} + fi + - name: ☑ Run application tests (Windows) if: matrix.system == 'windows' run: | $env:ENVIRONMENT_NAME = "${{ matrix.envname }}" - cd "${{ inputs.tests_directory || '.' }}" - $PYTEST_ARGS = if ("${{ inputs.artifact }}") { "--junitxml=TestReportSummary.xml" } else { "" } - python -m pytest -rA ${{ inputs.apptest_directory }} $PYTEST_ARGS --color=yes - - name: ☑ Run application tests (Ubuntu/macOS) - if: matrix.system != 'windows' - run: | - export ENVIRONMENT_NAME="${{ matrix.envname }}" - ABSDIR=$(pwd) cd "${{ inputs.tests_directory || '.' }}" - [ -n '${{ inputs.coverage_config }}' ] && PYCOV_ARGS="--cov-config=${ABSDIR}/${{ inputs.coverage_config }}" || unset PYCOV_ARGS - [ -n '${{ inputs.artifact }}' ] && PYTEST_ARGS='--junitxml=TestReportSummary.xml' || unset PYTEST_ARGS - python -m pytest -rA ${{ inputs.apptest_directory }} $PYTEST_ARGS --color=yes + $PYTEST_ARGS = if ("${{ inputs.apptest_xml_artifact }}") { "--junitxml=report/unit/TestReportSummary.xml" } else { "" } + if ("${{ inputs.coverage_config }}") { + Write-Host "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }}" + coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }} + } else { + Write-Host "python -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }}" + python -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }} + } - name: 📤 Upload 'TestReportSummary.xml' artifact - if: inputs.artifact != '' + if: inputs.apptest_xml_artifact != '' uses: actions/upload-artifact@v4 with: - name: ${{ inputs.artifact }}-${{ matrix.system }}-${{ matrix.python }} + name: ${{ inputs.apptest_xml_artifact }}-${{ matrix.system }}-${{ matrix.python }} path: ${{ inputs.tests_directory || '.' }}/TestReportSummary.xml if-no-files-found: error retention-days: 1 diff --git a/.github/workflows/UnitTesting.yml b/.github/workflows/UnitTesting.yml index 99eecf85..6ab964a3 100644 --- a/.github/workflows/UnitTesting.yml +++ b/.github/workflows/UnitTesting.yml @@ -47,7 +47,7 @@ on: tests_directory: description: 'Path to the directory containing tests (test working directory).' required: false - default: 'tests' + default: '' type: string unittest_directory: description: 'Path to the directory containing unit tests (relative to tests_directory).' @@ -293,7 +293,7 @@ jobs: export ENVIRONMENT_NAME="${{ matrix.envname }}" export PYTHONPATH=$(pwd) - # cd "${{ inputs.tests_directory || '.' }}" + cd "${{ inputs.tests_directory || '.' }}" [ -n '${{ inputs.unittest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=report/unit/TestReportSummary.xml' || unset PYTEST_ARGS if [ -n '${{ inputs.coverage_config }}' ]; then echo "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}" @@ -309,7 +309,7 @@ jobs: $env:ENVIRONMENT_NAME = "${{ matrix.envname }}" $env:PYTHONPATH = (Get-Location).ToString() - # cd "${{ inputs.tests_directory || '.' }}" + cd "${{ inputs.tests_directory || '.' }}" $PYTEST_ARGS = if ("${{ inputs.unittest_xml_artifact }}") { "--junitxml=report/unit/TestReportSummary.xml" } else { "" } if ("${{ inputs.coverage_config }}") { Write-Host "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}" @@ -319,15 +319,15 @@ jobs: python -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }} } - - name: Convert to XML format (Cobertura) + - name: Convert coverage to XML format (Cobertura) if: inputs.coverage_xml_artifact != '' run: coverage xml --data-file=.coverage - - name: Convert to JSON format + - name: Convert coverage to JSON format if: inputs.coverage_json_artifact != '' run: coverage json --data-file=.coverage - - name: Convert to HTML format + - name: Convert coverage to HTML format if: inputs.coverage_html_artifact != '' run: | coverage html --data-file=.coverage -d ${{ steps.getVariables.outputs.coverage_report_html_directory }} diff --git a/doc/coverage/index.rst b/doc/coverage/index.rst index 4d4c329a..bad51b90 100644 --- a/doc/coverage/index.rst +++ b/doc/coverage/index.rst @@ -1,7 +1,7 @@ Code Coverage Report #################### -Code coverage report generated with ``pytest`` and ``coverage.py``. +Code coverage report generated with `pytest `__ and `Coverage.py `__. .. report:code-coverage:: :packageid: src diff --git a/doc/requirements.txt b/doc/requirements.txt index fbe0ef52..959de57d 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,6 +1,6 @@ -r ../requirements.txt -pyTooling >= 5.0.0, < 6.0 +pyTooling ~= 6.0 # Enforce latest version on ReadTheDocs sphinx >= 7.1, < 8.0 diff --git a/doc/unittests/index.rst b/doc/unittests/index.rst index ae372b8b..8b840ee6 100644 --- a/doc/unittests/index.rst +++ b/doc/unittests/index.rst @@ -1,7 +1,7 @@ Unittest Summary Report ####################### -Code coverage report generated with ``pytest``. +Unittest report generated with `pytest `__. .. report:unittest-summary:: :reportid: src diff --git a/pyproject.toml b/pyproject.toml index 34a2ea05..f2504354 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools >= 69.0.0", "wheel >= 0.40.0", - "pyTooling >= 5.0.0" + "pyTooling ~= 6.0" ] build-backend = "setuptools.build_meta" @@ -30,6 +30,14 @@ filterwarnings = [ "error::PendingDeprecationWarning" ] +[tool.interrogate] +color = true +verbose = 1 # possible values: 0 (minimal output), 1 (-v), 2 (-vv) +fail-under = 59 +generate-badge = "." +badge-format = "png" +ignore-setters = true + [tool.coverage.run] branch = true relative_files = true diff --git a/requirements.txt b/requirements.txt index 4ad7e0b2..3bea232d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pyTooling >= 5.0.0, <6.0.0 +pyTooling ~= 6.0 diff --git a/setup.py b/setup.py index 1885b98d..4c4e234d 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ # SPDX-License-Identifier: Apache-2.0 # # ==================================================================================================================== # # +"""Package installer for 'pyDummy'.""" from setuptools import setup from pathlib import Path @@ -38,8 +39,7 @@ packageDirectory = packageName packageInformationFile = Path(f"{packageDirectory}/__init__.py") -# setup(** -DescribePythonPackageHostedOnGitHub( +setup(**DescribePythonPackageHostedOnGitHub( packageName=packageName, description="pyDummy is a test package to verify GitHub actions for Python projects.", gitHubNamespace=gitHubNamespace, @@ -48,5 +48,4 @@ dataFiles={ packageName: ["py.typed"] } -) -# ) +)) From 9ae9a199bba29a3e71dea35439017fce886318c6 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 17 Jan 2024 23:25:49 +0100 Subject: [PATCH 2/3] Added root directory. --- .github/workflows/ApplicationTesting.yml | 18 +++++++++++------- .github/workflows/UnitTesting.yml | 13 +++++++++---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ApplicationTesting.yml b/.github/workflows/ApplicationTesting.yml index 64b12a35..afceb3c9 100644 --- a/.github/workflows/ApplicationTesting.yml +++ b/.github/workflows/ApplicationTesting.yml @@ -49,11 +49,16 @@ on: required: false default: '' type: string - tests_directory: - description: 'Path to the directory containing tests (test working directory).' + root_directory: + description: 'Working directory for running tests.' required: false default: '' type: string + tests_directory: + description: 'Path to the directory containing tests (relative to root_directory).' + required: false + default: 'tests' + type: string apptest_directory: description: 'Path to the directory containing application tests (relative to tests_directory).' required: false @@ -66,7 +71,6 @@ on: type: string jobs: - ApplicationTesting: name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Application Tests using Python ${{ matrix.python }} runs-on: ${{ matrix.runs-on }} @@ -207,7 +211,7 @@ jobs: run: | export ENVIRONMENT_NAME="${{ matrix.envname }}" - cd "${{ inputs.tests_directory || '.' }}" + cd "${{ inputs.root_directory || '.' }}" [ -n '${{ inputs.apptest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=report/unit/TestReportSummary.xml' || unset PYTEST_ARGS if [ -n '${{ inputs.coverage_config }}' ]; then echo "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }}" @@ -222,7 +226,7 @@ jobs: run: | $env:ENVIRONMENT_NAME = "${{ matrix.envname }}" - cd "${{ inputs.tests_directory || '.' }}" + cd "${{ inputs.root_directory || '.' }}" $PYTEST_ARGS = if ("${{ inputs.apptest_xml_artifact }}") { "--junitxml=report/unit/TestReportSummary.xml" } else { "" } if ("${{ inputs.coverage_config }}") { Write-Host "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.apptest_directory }}" @@ -236,7 +240,7 @@ jobs: if: inputs.apptest_xml_artifact != '' uses: actions/upload-artifact@v4 with: - name: ${{ inputs.apptest_xml_artifact }}-${{ matrix.system }}-${{ matrix.python }} - path: ${{ inputs.tests_directory || '.' }}/TestReportSummary.xml + name: ${{ inputs.apptest_xml_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }} + path: report/unit/TestReportSummary.xml if-no-files-found: error retention-days: 1 diff --git a/.github/workflows/UnitTesting.yml b/.github/workflows/UnitTesting.yml index 6ab964a3..81e86570 100644 --- a/.github/workflows/UnitTesting.yml +++ b/.github/workflows/UnitTesting.yml @@ -44,11 +44,16 @@ on: required: false default: '' type: string - tests_directory: - description: 'Path to the directory containing tests (test working directory).' + root_directory: + description: 'Working directory for running tests.' required: false default: '' type: string + tests_directory: + description: 'Path to the directory containing tests (relative to root_directory).' + required: false + default: 'tests' + type: string unittest_directory: description: 'Path to the directory containing unit tests (relative to tests_directory).' required: false @@ -293,7 +298,7 @@ jobs: export ENVIRONMENT_NAME="${{ matrix.envname }}" export PYTHONPATH=$(pwd) - cd "${{ inputs.tests_directory || '.' }}" + cd "${{ inputs.root_directory || '.' }}" [ -n '${{ inputs.unittest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=report/unit/TestReportSummary.xml' || unset PYTEST_ARGS if [ -n '${{ inputs.coverage_config }}' ]; then echo "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}" @@ -309,7 +314,7 @@ jobs: $env:ENVIRONMENT_NAME = "${{ matrix.envname }}" $env:PYTHONPATH = (Get-Location).ToString() - cd "${{ inputs.tests_directory || '.' }}" + cd "${{ inputs.root_directory || '.' }}" $PYTEST_ARGS = if ("${{ inputs.unittest_xml_artifact }}") { "--junitxml=report/unit/TestReportSummary.xml" } else { "" } if ("${{ inputs.coverage_config }}") { Write-Host "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}" From e4881c0956c70f6fef115310c355f9df14892d2d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Thu, 18 Jan 2024 00:46:48 +0100 Subject: [PATCH 3/3] Updated dependency extraction rules for pacman. --- .github/workflows/ApplicationTesting.yml | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ApplicationTesting.yml b/.github/workflows/ApplicationTesting.yml index afceb3c9..c327cb99 100644 --- a/.github/workflows/ApplicationTesting.yml +++ b/.github/workflows/ApplicationTesting.yml @@ -102,6 +102,9 @@ jobs: from os import getenv from pathlib import Path from re import compile + from sys import version + + print(f"Python: {version}") def loadRequirementsFile(requirementsFile: Path): requirements = [] @@ -126,28 +129,32 @@ jobs: dependencies = [req.strip() for req in requirements.split(" ")] packages = { - "pip": "python-pip:p", - "wheel": "python-wheel:p", "coverage": "python-coverage:p", + "igraph": "igraph:p", + "jinja2": "python-markupsafe:p", "lxml": "python-lxml:p", - "ruamel.yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p", "numpy": "python-numpy:p", - "igraph": "igraph:p", + "markupsafe": "python-markupsafe:p", + "pip": "python-pip:p", + "ruamel.yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p", + "sphinx": "python-markupsafe:p", + "tomli": "python-tomli:p", + "wheel": "python-wheel:p", } subPackages = { - "pyTooling": { + "pytooling": { "yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p", } } - regExp = compile(r"(?P[\w_\-\.]+)(?:\[(?P(?:\w+)(?:,\w+)*)\])?(?:\s*(?P[<>=]+)\s*)(?P\d+(?:\.\d+)*)(?:-(?P\w+))?") + regExp = compile(r"(?P[\w_\-\.]+)(?:\[(?P(?:\w+)(?:\s*,\s*\w+)*)\])?(?:\s*(?P[<>~=]+)\s*)(?P\d+(?:\.\d+)*)(?:-(?P\w+))?") - pacboyPackages = set(("python-pip:p", "python-wheel:p")) + pacboyPackages = set(("python-pip:p", "python-wheel:p", "python-tomli:p")) print(f"Processing dependencies ({len(dependencies)}):") for dependency in dependencies: print(f" {dependency}") - match = regExp.match(dependency) + match = regExp.match(dependency.lower()) if not match: print(f" Wrong format: {dependency}") print(f"::error title=Identifying Pacboy Packages::Unrecognized dependency format '{dependency}'") @@ -204,7 +211,9 @@ jobs: fi - name: 🔧 Install wheel from artifact - run: python -m pip install --disable-pip-version-check -U install/*.whl + run: | + ls -l install + python -m pip install --disable-pip-version-check -U install/*.whl - name: ☑ Run application tests (Ubuntu/macOS) if: matrix.system != 'windows'