mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 11:06:56 +08:00
Application testing.
This commit is contained in:
81
.github/workflows/ApplicationTesting.yml
vendored
81
.github/workflows/ApplicationTesting.yml
vendored
@@ -49,8 +49,13 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
type: string
|
type: string
|
||||||
|
root_directory:
|
||||||
|
description: 'Working directory for running tests.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
tests_directory:
|
tests_directory:
|
||||||
description: 'Path to the directory containing tests (test working directory).'
|
description: 'Path to the directory containing tests (relative to root_directory).'
|
||||||
required: false
|
required: false
|
||||||
default: 'tests'
|
default: 'tests'
|
||||||
type: string
|
type: string
|
||||||
@@ -59,14 +64,13 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: 'app'
|
default: 'app'
|
||||||
type: string
|
type: string
|
||||||
artifact:
|
apptest_xml_artifact:
|
||||||
description: "Generate application test report with junitxml and upload results as an artifact."
|
description: "Generate application test report with junitxml and upload results as an artifact."
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
ApplicationTesting:
|
ApplicationTesting:
|
||||||
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Application Tests using Python ${{ matrix.python }}
|
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Application Tests using Python ${{ matrix.python }}
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
@@ -98,6 +102,9 @@ jobs:
|
|||||||
from os import getenv
|
from os import getenv
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from re import compile
|
from re import compile
|
||||||
|
from sys import version
|
||||||
|
|
||||||
|
print(f"Python: {version}")
|
||||||
|
|
||||||
def loadRequirementsFile(requirementsFile: Path):
|
def loadRequirementsFile(requirementsFile: Path):
|
||||||
requirements = []
|
requirements = []
|
||||||
@@ -122,28 +129,32 @@ jobs:
|
|||||||
dependencies = [req.strip() for req in requirements.split(" ")]
|
dependencies = [req.strip() for req in requirements.split(" ")]
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
"pip": "python-pip:p",
|
|
||||||
"wheel": "python-wheel:p",
|
|
||||||
"coverage": "python-coverage:p",
|
"coverage": "python-coverage:p",
|
||||||
"lxml": "python-lxml:p",
|
|
||||||
"ruamel.yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p",
|
|
||||||
"numpy": "python-numpy:p",
|
|
||||||
"igraph": "igraph:p",
|
"igraph": "igraph:p",
|
||||||
|
"jinja2": "python-markupsafe:p",
|
||||||
|
"lxml": "python-lxml:p",
|
||||||
|
"numpy": "python-numpy: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 = {
|
subPackages = {
|
||||||
"pyTooling": {
|
"pytooling": {
|
||||||
"yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p",
|
"yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
regExp = compile(r"(?P<PackageName>[\w_\-\.]+)(?:\[(?P<SubPackages>(?:\w+)(?:,\w+)*)\])?(?:\s*(?P<Comperator>[<>=]+)\s*)(?P<Version>\d+(?:\.\d+)*)(?:-(?P<VersionExtension>\w+))?")
|
regExp = compile(r"(?P<PackageName>[\w_\-\.]+)(?:\[(?P<SubPackages>(?:\w+)(?:\s*,\s*\w+)*)\])?(?:\s*(?P<Comperator>[<>~=]+)\s*)(?P<Version>\d+(?:\.\d+)*)(?:-(?P<VersionExtension>\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)}):")
|
print(f"Processing dependencies ({len(dependencies)}):")
|
||||||
for dependency in dependencies:
|
for dependency in dependencies:
|
||||||
print(f" {dependency}")
|
print(f" {dependency}")
|
||||||
|
|
||||||
match = regExp.match(dependency)
|
match = regExp.match(dependency.lower())
|
||||||
if not match:
|
if not match:
|
||||||
print(f" Wrong format: {dependency}")
|
print(f" Wrong format: {dependency}")
|
||||||
print(f"::error title=Identifying Pacboy Packages::Unrecognized dependency format '{dependency}'")
|
print(f"::error title=Identifying Pacboy Packages::Unrecognized dependency format '{dependency}'")
|
||||||
@@ -200,31 +211,45 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 🔧 Install wheel from artifact
|
- name: 🔧 Install wheel from artifact
|
||||||
run: python -m pip install --disable-pip-version-check -U install/*.whl
|
|
||||||
|
|
||||||
- name: ☑ Run application tests (Windows)
|
|
||||||
if: matrix.system == 'windows'
|
|
||||||
run: |
|
run: |
|
||||||
$env:ENVIRONMENT_NAME = "${{ matrix.envname }}"
|
ls -l install
|
||||||
cd "${{ inputs.tests_directory || '.' }}"
|
python -m pip install --disable-pip-version-check -U install/*.whl
|
||||||
$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)
|
- name: ☑ Run application tests (Ubuntu/macOS)
|
||||||
if: matrix.system != 'windows'
|
if: matrix.system != 'windows'
|
||||||
run: |
|
run: |
|
||||||
export ENVIRONMENT_NAME="${{ matrix.envname }}"
|
export ENVIRONMENT_NAME="${{ matrix.envname }}"
|
||||||
ABSDIR=$(pwd)
|
|
||||||
cd "${{ inputs.tests_directory || '.' }}"
|
cd "${{ inputs.root_directory || '.' }}"
|
||||||
[ -n '${{ inputs.coverage_config }}' ] && PYCOV_ARGS="--cov-config=${ABSDIR}/${{ inputs.coverage_config }}" || unset PYCOV_ARGS
|
[ -n '${{ inputs.apptest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=report/unit/TestReportSummary.xml' || unset PYTEST_ARGS
|
||||||
[ -n '${{ inputs.artifact }}' ] && PYTEST_ARGS='--junitxml=TestReportSummary.xml' || unset PYTEST_ARGS
|
if [ -n '${{ inputs.coverage_config }}' ]; then
|
||||||
python -m pytest -rA ${{ inputs.apptest_directory }} $PYTEST_ARGS --color=yes
|
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.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 }}"
|
||||||
|
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
|
- name: 📤 Upload 'TestReportSummary.xml' artifact
|
||||||
if: inputs.artifact != ''
|
if: inputs.apptest_xml_artifact != ''
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.artifact }}-${{ matrix.system }}-${{ matrix.python }}
|
name: ${{ inputs.apptest_xml_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
|
||||||
path: ${{ inputs.tests_directory || '.' }}/TestReportSummary.xml
|
path: report/unit/TestReportSummary.xml
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|||||||
17
.github/workflows/UnitTesting.yml
vendored
17
.github/workflows/UnitTesting.yml
vendored
@@ -44,8 +44,13 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
type: string
|
type: string
|
||||||
|
root_directory:
|
||||||
|
description: 'Working directory for running tests.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
tests_directory:
|
tests_directory:
|
||||||
description: 'Path to the directory containing tests (test working directory).'
|
description: 'Path to the directory containing tests (relative to root_directory).'
|
||||||
required: false
|
required: false
|
||||||
default: 'tests'
|
default: 'tests'
|
||||||
type: string
|
type: string
|
||||||
@@ -293,7 +298,7 @@ jobs:
|
|||||||
export ENVIRONMENT_NAME="${{ matrix.envname }}"
|
export ENVIRONMENT_NAME="${{ matrix.envname }}"
|
||||||
export PYTHONPATH=$(pwd)
|
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
|
[ -n '${{ inputs.unittest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=report/unit/TestReportSummary.xml' || unset PYTEST_ARGS
|
||||||
if [ -n '${{ inputs.coverage_config }}' ]; then
|
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 }}"
|
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:ENVIRONMENT_NAME = "${{ matrix.envname }}"
|
||||||
$env:PYTHONPATH = (Get-Location).ToString()
|
$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 { "" }
|
$PYTEST_ARGS = if ("${{ inputs.unittest_xml_artifact }}") { "--junitxml=report/unit/TestReportSummary.xml" } else { "" }
|
||||||
if ("${{ inputs.coverage_config }}") {
|
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 }}"
|
Write-Host "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}"
|
||||||
@@ -319,15 +324,15 @@ jobs:
|
|||||||
python -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}
|
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 != ''
|
if: inputs.coverage_xml_artifact != ''
|
||||||
run: coverage xml --data-file=.coverage
|
run: coverage xml --data-file=.coverage
|
||||||
|
|
||||||
- name: Convert to JSON format
|
- name: Convert coverage to JSON format
|
||||||
if: inputs.coverage_json_artifact != ''
|
if: inputs.coverage_json_artifact != ''
|
||||||
run: coverage json --data-file=.coverage
|
run: coverage json --data-file=.coverage
|
||||||
|
|
||||||
- name: Convert to HTML format
|
- name: Convert coverage to HTML format
|
||||||
if: inputs.coverage_html_artifact != ''
|
if: inputs.coverage_html_artifact != ''
|
||||||
run: |
|
run: |
|
||||||
coverage html --data-file=.coverage -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
coverage html --data-file=.coverage -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Code Coverage Report
|
Code Coverage Report
|
||||||
####################
|
####################
|
||||||
|
|
||||||
Code coverage report generated with ``pytest`` and ``coverage.py``.
|
Code coverage report generated with `pytest <https://github.com/pytest-dev/pytest>`__ and `Coverage.py <https://github.com/nedbat/coveragepy/tree/master>`__.
|
||||||
|
|
||||||
.. report:code-coverage::
|
.. report:code-coverage::
|
||||||
:packageid: src
|
:packageid: src
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-r ../requirements.txt
|
-r ../requirements.txt
|
||||||
|
|
||||||
pyTooling >= 5.0.0, < 6.0
|
pyTooling ~= 6.0
|
||||||
|
|
||||||
# Enforce latest version on ReadTheDocs
|
# Enforce latest version on ReadTheDocs
|
||||||
sphinx >= 7.1, < 8.0
|
sphinx >= 7.1, < 8.0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Unittest Summary Report
|
Unittest Summary Report
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
Code coverage report generated with ``pytest``.
|
Unittest report generated with `pytest <https://github.com/pytest-dev/pytest>`__.
|
||||||
|
|
||||||
.. report:unittest-summary::
|
.. report:unittest-summary::
|
||||||
:reportid: src
|
:reportid: src
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
requires = [
|
requires = [
|
||||||
"setuptools >= 69.0.0",
|
"setuptools >= 69.0.0",
|
||||||
"wheel >= 0.40.0",
|
"wheel >= 0.40.0",
|
||||||
"pyTooling >= 5.0.0"
|
"pyTooling ~= 6.0"
|
||||||
]
|
]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
@@ -30,6 +30,14 @@ filterwarnings = [
|
|||||||
"error::PendingDeprecationWarning"
|
"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]
|
[tool.coverage.run]
|
||||||
branch = true
|
branch = true
|
||||||
relative_files = true
|
relative_files = true
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
pyTooling >= 5.0.0, <6.0.0
|
pyTooling ~= 6.0
|
||||||
|
|||||||
7
setup.py
7
setup.py
@@ -28,6 +28,7 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0 #
|
# SPDX-License-Identifier: Apache-2.0 #
|
||||||
# ==================================================================================================================== #
|
# ==================================================================================================================== #
|
||||||
#
|
#
|
||||||
|
"""Package installer for 'pyDummy'."""
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -38,8 +39,7 @@ packageName = "pyDummy"
|
|||||||
packageDirectory = packageName
|
packageDirectory = packageName
|
||||||
packageInformationFile = Path(f"{packageDirectory}/__init__.py")
|
packageInformationFile = Path(f"{packageDirectory}/__init__.py")
|
||||||
|
|
||||||
# setup(**
|
setup(**DescribePythonPackageHostedOnGitHub(
|
||||||
DescribePythonPackageHostedOnGitHub(
|
|
||||||
packageName=packageName,
|
packageName=packageName,
|
||||||
description="pyDummy is a test package to verify GitHub actions for Python projects.",
|
description="pyDummy is a test package to verify GitHub actions for Python projects.",
|
||||||
gitHubNamespace=gitHubNamespace,
|
gitHubNamespace=gitHubNamespace,
|
||||||
@@ -48,5 +48,4 @@ DescribePythonPackageHostedOnGitHub(
|
|||||||
dataFiles={
|
dataFiles={
|
||||||
packageName: ["py.typed"]
|
packageName: ["py.typed"]
|
||||||
}
|
}
|
||||||
)
|
))
|
||||||
# )
|
|
||||||
|
|||||||
Reference in New Issue
Block a user