mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
Added Python 3.12 support.
Merge junit files. Merge coverage files. Extending UnitTesting to support code coverage in a matrix too.
This commit is contained in:
51
.github/workflows/Parameters.yml
vendored
51
.github/workflows/Parameters.yml
vendored
@@ -32,17 +32,17 @@ on:
|
||||
python_version:
|
||||
description: 'Python version.'
|
||||
required: false
|
||||
default: '3.11'
|
||||
default: '3.12'
|
||||
type: string
|
||||
python_version_list:
|
||||
description: 'Space separated list of Python versions to run tests with.'
|
||||
required: false
|
||||
default: '3.8 3.9 3.10 3.11'
|
||||
default: '3.8 3.9 3.10 3.11 3.12'
|
||||
type: string
|
||||
system_list:
|
||||
description: 'Space separated list of systems to run tests on.'
|
||||
required: false
|
||||
default: 'ubuntu windows mingw64 macos'
|
||||
default: 'ubuntu windows macos mingw64 ucrt64'
|
||||
type: string
|
||||
include_list:
|
||||
description: 'Space separated list of system:python items to be included into the list of test.'
|
||||
@@ -102,9 +102,9 @@ jobs:
|
||||
exclude_list = "${{ inputs.exclude_list }}".strip()
|
||||
disable_list = "${{ inputs.disable_list }}".strip()
|
||||
|
||||
currentMSYS2Version = "3.10"
|
||||
currentAlphaVersion = "3.12"
|
||||
currentAlphaRelease = "3.12.0-alpha.1"
|
||||
currentMSYS2Version = "3.11"
|
||||
currentAlphaVersion = "3.13"
|
||||
currentAlphaRelease = "3.13.0-alpha.1"
|
||||
|
||||
if systems == "":
|
||||
print("::error title=Parameter::system_list is empty.")
|
||||
@@ -131,8 +131,8 @@ jobs:
|
||||
else:
|
||||
disabled = [disable.strip() for disable in disable_list.split(" ")]
|
||||
|
||||
if "3.6" in versions:
|
||||
print("::warning title=Deprecated::Support for Python 3.6 ended in 2021.12.23.")
|
||||
if "3.7" in versions:
|
||||
print("::warning title=Deprecated::Support for Python 3.7 ended in 2023.06.27.")
|
||||
if "msys2" in systems:
|
||||
print("::warning title=Deprecated::System 'msys2' will be replaced by 'mingw64'.")
|
||||
if currentAlphaVersion in versions:
|
||||
@@ -143,16 +143,17 @@ jobs:
|
||||
data = {
|
||||
# Python and PyPy versions supported by "setup-python" action
|
||||
"python": {
|
||||
"3.6": { "icon": "⚫", "until": "2021.12.23" },
|
||||
"3.7": { "icon": "⚫", "until": "2023.06.27" },
|
||||
"3.8": { "icon": "🔴", "until": "2024.10" },
|
||||
"3.9": { "icon": "🟠", "until": "2025.10" },
|
||||
"3.10": { "icon": "🟡", "until": "2026.10" },
|
||||
"3.11": { "icon": "🟢", "until": "2027.10" },
|
||||
"3.12": { "icon": "🟣", "until": "2028.10" },
|
||||
"pypy-3.7": { "icon": "⟲🔴", "until": "????.??" },
|
||||
"pypy-3.8": { "icon": "⟲🟠", "until": "????.??" },
|
||||
"pypy-3.9": { "icon": "⟲🟡", "until": "????.??" },
|
||||
"3.12": { "icon": "🟢", "until": "2028.10" },
|
||||
# "3.13": { "icon": "🟣", "until": "2028.10" },
|
||||
"pypy-3.7": { "icon": "⟲⚫", "until": "????.??" },
|
||||
"pypy-3.8": { "icon": "⟲🔴", "until": "????.??" },
|
||||
"pypy-3.9": { "icon": "⟲🟠", "until": "????.??" },
|
||||
"pypy-3.10": { "icon": "⟲🟡", "until": "????.??" },
|
||||
},
|
||||
# Runner systems (runner images) supported by GitHub Actions
|
||||
"sys": {
|
||||
@@ -211,6 +212,7 @@ jobs:
|
||||
"sysicon": data["sys"][system]["icon"],
|
||||
"system": system,
|
||||
"runs-on": data["sys"][system]["runs-on"],
|
||||
"runtime": "native",
|
||||
"shell": data["sys"][system]["shell"],
|
||||
"pyicon": data["python"][version]["icon"],
|
||||
"python": currentAlphaRelease if version == currentAlphaVersion else version,
|
||||
@@ -232,16 +234,19 @@ jobs:
|
||||
]
|
||||
|
||||
artifact_names = {
|
||||
"unittesting_xml": f"{name}-UnitTestReportSummary-XML",
|
||||
"perftesting_xml": f"{name}-PerformanceTestReportSummary-XML",
|
||||
"benchtesting_xml": f"{name}-BenchmarkTestReportSummary-XML",
|
||||
"apptesting_xml": f"{name}-ApplicationTestReportSummary-XML",
|
||||
"codecoverage_xml": f"{name}-CodeCoverage-XML",
|
||||
"codecoverage_html": f"{name}-CodeCoverage-HTML",
|
||||
"statictyping_html": f"{name}-StaticTyping-HTML",
|
||||
"package_all": f"{name}-Packages",
|
||||
"documentation_pdf": f"{name}-Documentation-PDF",
|
||||
"documentation_html": f"{name}-Documentation-HTML",
|
||||
"unittesting_xml": f"{name}-UnitTestReportSummary-XML",
|
||||
"unittesting_html": f"{name}-UnitTestReportSummary-HTML",
|
||||
"perftesting_xml": f"{name}-PerformanceTestReportSummary-XML",
|
||||
"benchtesting_xml": f"{name}-BenchmarkTestReportSummary-XML",
|
||||
"apptesting_xml": f"{name}-ApplicationTestReportSummary-XML",
|
||||
"codecoverage_sqlite": f"{name}-CodeCoverage-SQLite",
|
||||
"codecoverage_xml": f"{name}-CodeCoverage-XML",
|
||||
"codecoverage_json": f"{name}-CodeCoverage-JSON",
|
||||
"codecoverage_html": f"{name}-CodeCoverage-HTML",
|
||||
"statictyping_html": f"{name}-StaticTyping-HTML",
|
||||
"package_all": f"{name}-Packages",
|
||||
"documentation_pdf": f"{name}-Documentation-PDF",
|
||||
"documentation_html": f"{name}-Documentation-HTML",
|
||||
}
|
||||
|
||||
# Deprecated structure
|
||||
|
||||
10
.github/workflows/Pipeline.yml
vendored
10
.github/workflows/Pipeline.yml
vendored
@@ -1,10 +0,0 @@
|
||||
#name: Pipeline
|
||||
name: Documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
BuildTheDocs:
|
||||
uses: pyTooling/Actions/.github/workflows/BuildTheDocs.yml@dev
|
||||
160
.github/workflows/PublishCoverageResults.yml
vendored
160
.github/workflows/PublishCoverageResults.yml
vendored
@@ -19,15 +19,35 @@
|
||||
# #
|
||||
# SPDX-License-Identifier: Apache-2.0 #
|
||||
# ==================================================================================================================== #
|
||||
name: Publish Unit Test Results
|
||||
name: Publish Code Coverage Results
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
report_files:
|
||||
description: 'Pattern of report files to upload. Can be a comma separated list.'
|
||||
coverage_config:
|
||||
description: 'Path to the .coveragerc file. Use pyproject.toml by default.'
|
||||
required: false
|
||||
default: 'artifacts/**/*.xml'
|
||||
default: 'pyproject.toml'
|
||||
type: string
|
||||
coverage_sqlite_artifact:
|
||||
description: 'Name of the SQLite coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
coverage_xml_artifact:
|
||||
description: 'Name of the XML coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
coverage_json_artifact:
|
||||
description: 'Name of the JSON coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
coverage_html_artifact:
|
||||
description: 'Name of the HTML coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
secrets:
|
||||
codacy_token:
|
||||
@@ -35,8 +55,8 @@ on:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
PublishTestResults:
|
||||
name: 📊 Publish Test Results
|
||||
PublishCoverageResults:
|
||||
name: 📊 Publish Code Coverage Results
|
||||
runs-on: ubuntu-latest
|
||||
if: always()
|
||||
|
||||
@@ -49,6 +69,134 @@ jobs:
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: 🔧 Install coverage and tomli
|
||||
run: |
|
||||
python -m pip install --disable-pip-version-check -U coverage[toml] tomli
|
||||
|
||||
- name: 🔁 Extract configurations from pyproject.toml
|
||||
id: getVariables
|
||||
shell: python
|
||||
run: |
|
||||
from os import getenv
|
||||
from pathlib import Path
|
||||
from sys import version
|
||||
from textwrap import dedent
|
||||
|
||||
print(f"Python: {version}")
|
||||
|
||||
from tomli import load as tomli_load
|
||||
|
||||
htmlDirectory = Path("htmlcov")
|
||||
xmlFile = Path("./coverage.xml")
|
||||
jsonFile = Path("./coverage.json")
|
||||
coverageRC = "${{ inputs.coverage_config }}".strip()
|
||||
|
||||
# Read output paths from 'pyproject.toml' file
|
||||
if coverageRC == "pyproject.toml":
|
||||
pyProjectFile = Path("pyproject.toml")
|
||||
if pyProjectFile.exists():
|
||||
with pyProjectFile.open("rb") as file:
|
||||
pyProjectSettings = tomli_load(file)
|
||||
|
||||
htmlDirectory = Path(pyProjectSettings["tool"]["coverage"]["html"]["directory"])
|
||||
xmlFile = Path(pyProjectSettings["tool"]["coverage"]["xml"]["output"])
|
||||
jsonFile = Path(pyProjectSettings["tool"]["coverage"]["json"]["output"])
|
||||
else:
|
||||
print(f"File '{pyProjectFile}' not found and no '.coveragerc' file specified.")
|
||||
|
||||
# Read output paths from '.coveragerc' file
|
||||
elif len(coverageRC) > 0:
|
||||
coverageRCFile = Path(coverageRC)
|
||||
if coverageRCFile.exists():
|
||||
with coverageRCFile.open("rb") as file:
|
||||
coverageRCSettings = tomli_load(file)
|
||||
|
||||
htmlDirectory = Path(coverageRCSettings["html"]["directory"])
|
||||
xmlFile = Path(coverageRCSettings["xml"]["output"])
|
||||
jsonFile = Path(coverageRCSettings["json"]["output"])
|
||||
else:
|
||||
print(f"File '{coverageRCFile}' not found.")
|
||||
|
||||
# Write jobs to special file
|
||||
github_output = Path(getenv("GITHUB_OUTPUT"))
|
||||
print(f"GITHUB_OUTPUT: {github_output}")
|
||||
with github_output.open("a+", encoding="utf-8") as f:
|
||||
f.write(dedent(f"""\
|
||||
coverage_report_html_directory={htmlDirectory.as_posix()}
|
||||
coverage_report_xml={xmlFile}
|
||||
coverage_report_json={jsonFile}
|
||||
"""))
|
||||
|
||||
print(f"DEBUG:\n html={htmlDirectory}\n xml={xmlFile}\n json={jsonFile}")
|
||||
|
||||
- name: Rename .coverage files and collect them all to coverage/
|
||||
run: |
|
||||
mkdir -p coverage
|
||||
find . -type f -path "*artifacts*SQLite*.coverage" -exec sh -c 'cp -v $0 "coverage/$(basename $0).$(basename $(dirname $0))"' {} ';'
|
||||
tree -a coverage
|
||||
|
||||
- name: Combine SQLite files (using Coverage.py)
|
||||
if: inputs.coverage_xml_artifact != ''
|
||||
run: coverage combine coverage/
|
||||
|
||||
- name: Report code coverage
|
||||
run: coverage report --rcfile=pyproject.toml --data-file=.coverage
|
||||
|
||||
- name: Convert to XML format (Cobertura)
|
||||
if: inputs.coverage_xml_artifact != ''
|
||||
run: coverage xml --data-file=.coverage
|
||||
|
||||
- name: Convert to JSON format
|
||||
if: inputs.coverage_json_artifact != ''
|
||||
run: coverage json --data-file=.coverage
|
||||
|
||||
- name: Convert to HTML format
|
||||
if: inputs.coverage_html_artifact != ''
|
||||
run: |
|
||||
coverage html --data-file=.coverage -d report/coverage/html
|
||||
rm report/coverage/html/.gitignore
|
||||
tree -a report/coverage/html
|
||||
|
||||
- name: 📤 Upload 'Coverage SQLite Database' artifact
|
||||
if: inputs.coverage_sqlite_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_sqlite_artifact }}
|
||||
path: .coverage
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: 📤 Upload 'Coverage XML Report' artifact
|
||||
if: inputs.coverage_xml_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_xml_artifact }}
|
||||
path: ${{ steps.getVariables.outputs.coverage_report_xml }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: 📤 Upload 'Coverage JSON Report' artifact
|
||||
if: inputs.coverage_json_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_json_artifact }}
|
||||
path: ${{ steps.getVariables.outputs.coverage_report_json }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: 📤 Upload 'Coverage HTML Report' artifact
|
||||
if: inputs.coverage_html_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_html_artifact }}
|
||||
path: ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: 📊 Publish code coverage at CodeCov
|
||||
if: inputs.CodeCov == true
|
||||
continue-on-error: true
|
||||
|
||||
34
.github/workflows/PublishTestResults.yml
vendored
34
.github/workflows/PublishTestResults.yml
vendored
@@ -24,12 +24,6 @@ name: Publish Unit Test Results
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
report_files:
|
||||
description: 'Pattern of report files to upload. Can be a comma separated list.'
|
||||
required: false
|
||||
default: 'artifacts/**/*.xml'
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
PublishTestResults:
|
||||
@@ -46,9 +40,35 @@ jobs:
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: 🔧 Install junitparser
|
||||
run: |
|
||||
python -m pip install --disable-pip-version-check -U junitparser
|
||||
|
||||
- name: Move JUnit files and collect them all to junit/
|
||||
run: |
|
||||
mkdir -p junit
|
||||
find . -type f -path "*artifacts*UnitTestReportSummary*.xml" -exec sh -c 'cp -v $0 "junit/$(basename $(dirname $0)).$(basename $0)"' {} ';'
|
||||
tree -a junit
|
||||
|
||||
- name: 🔁 Merge JUnit Unit Test Summaries
|
||||
shell: python
|
||||
run: |
|
||||
from pathlib import Path
|
||||
from junitparser import JUnitXml
|
||||
|
||||
junitDirectory = Path("junit")
|
||||
junitXml = None
|
||||
for file in junitDirectory.iterdir():
|
||||
if junitXml is None:
|
||||
junitXml = JUnitXml.fromfile(file)
|
||||
else:
|
||||
junitXml += JUnitXml.fromfile(file)
|
||||
|
||||
junitXml.write(junitDirectory / "merged.xml")
|
||||
|
||||
- name: 📊 Publish Unit Test Results
|
||||
uses: dorny/test-reporter@v1
|
||||
with:
|
||||
name: Unit Test Results
|
||||
path: ${{ inputs.report_files }}
|
||||
path: junit/merged.xml
|
||||
reporter: java-junit
|
||||
|
||||
228
.github/workflows/UnitTesting.yml
vendored
228
.github/workflows/UnitTesting.yml
vendored
@@ -20,7 +20,7 @@
|
||||
# #
|
||||
# SPDX-License-Identifier: Apache-2.0 #
|
||||
# ==================================================================================================================== #
|
||||
name: Unit Testing
|
||||
name: Unit Testing (Matrix)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
@@ -54,16 +54,45 @@ on:
|
||||
required: false
|
||||
default: 'unit'
|
||||
type: string
|
||||
artifact:
|
||||
coverage_config:
|
||||
description: 'Path to the .coveragerc file. Use pyproject.toml by default.'
|
||||
required: false
|
||||
default: 'pyproject.toml'
|
||||
type: string
|
||||
unittest_xml_artifact:
|
||||
description: "Generate unit test report with junitxml and upload results as an artifact."
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
unittest_html_artifact:
|
||||
description: "Generate unit test report with junitxml and upload results as an artifact."
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
coverage_sqlite_artifact:
|
||||
description: 'Name of the SQLite coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
coverage_xml_artifact:
|
||||
description: 'Name of the XML coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
coverage_json_artifact:
|
||||
description: 'Name of the JSON coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
coverage_html_artifact:
|
||||
description: 'Name of the HTML coverage artifact.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
|
||||
UnitTesting:
|
||||
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Unit Tests using Python ${{ matrix.python }}
|
||||
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Unit Tests - Python ${{ matrix.python }}
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
|
||||
strategy:
|
||||
@@ -79,6 +108,12 @@ jobs:
|
||||
- name: ⏬ Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 🔧 Install dependencies (system Python for Python shell)
|
||||
if: matrix.system == 'msys2'
|
||||
shell: pwsh
|
||||
run: |
|
||||
py -3.9 -m pip install --disable-pip-version-check -U tomli
|
||||
|
||||
- name: Compute pacman/pacboy packages
|
||||
id: pacboy
|
||||
if: matrix.system == 'msys2'
|
||||
@@ -87,6 +122,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 = []
|
||||
@@ -111,13 +149,14 @@ jobs:
|
||||
dependencies = [req.strip() for req in requirements.split(" ")]
|
||||
|
||||
packages = {
|
||||
"pip": "python-pip:p",
|
||||
"wheel": "python-wheel: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",
|
||||
"lxml": "python-lxml:p",
|
||||
"numpy": "python-numpy:p",
|
||||
"pip": "python-pip:p",
|
||||
"ruamel.yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p",
|
||||
"tomli": "python-tomli:p",
|
||||
"wheel": "python-wheel:p",
|
||||
}
|
||||
subPackages = {
|
||||
"pyTooling": {
|
||||
@@ -127,7 +166,7 @@ jobs:
|
||||
|
||||
regExp = compile(r"(?P<PackageName>[\w_\-\.]+)(?:\[(?P<SubPackages>(?:\w+)(?:,\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)}):")
|
||||
for dependency in dependencies:
|
||||
print(f" {dependency}")
|
||||
@@ -173,10 +212,10 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
|
||||
- name: 🔧 Install wheel and pip dependencies (native)
|
||||
- name: 🔧 Install wheel,tomli and pip dependencies (native)
|
||||
if: matrix.system != 'msys2'
|
||||
run: |
|
||||
python -m pip install --disable-pip-version-check -U wheel
|
||||
python -m pip install --disable-pip-version-check -U wheel tomli
|
||||
python -m pip install --disable-pip-version-check ${{ inputs.requirements }}
|
||||
|
||||
- name: 🔧 Install pip dependencies (MSYS2)
|
||||
@@ -188,33 +227,164 @@ jobs:
|
||||
python -m pip install --disable-pip-version-check ${{ inputs.requirements }}
|
||||
fi
|
||||
|
||||
- name: ☑ Run unit tests (Windows)
|
||||
if: matrix.system == 'windows'
|
||||
- name: 🔁 Extract configurations from pyproject.toml
|
||||
id: getVariables
|
||||
shell: python
|
||||
run: |
|
||||
$env:ENVIRONMENT_NAME = "${{ matrix.envname }}"
|
||||
$env:PYTHONPATH = (Get-Location).ToString()
|
||||
cd "${{ inputs.tests_directory || '.' }}"
|
||||
$PYTEST_ARGS = if ("${{ inputs.artifact }}") { "--junitxml=TestReportSummary.xml" } else { "" }
|
||||
Write-Host "python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_directory }}"
|
||||
python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_directory }}
|
||||
from os import getenv
|
||||
from pathlib import Path
|
||||
from sys import version
|
||||
from textwrap import dedent
|
||||
|
||||
print(f"Python: {version}")
|
||||
|
||||
from tomli import load as tomli_load
|
||||
|
||||
htmlDirectory = Path("htmlcov")
|
||||
xmlFile = Path("./coverage.xml")
|
||||
jsonFile = Path("./coverage.json")
|
||||
coverageRC = "${{ inputs.coverage_config }}".strip()
|
||||
|
||||
# Read output paths from 'pyproject.toml' file
|
||||
if coverageRC == "pyproject.toml":
|
||||
pyProjectFile = Path("pyproject.toml")
|
||||
if pyProjectFile.exists():
|
||||
with pyProjectFile.open("rb") as file:
|
||||
pyProjectSettings = tomli_load(file)
|
||||
|
||||
htmlDirectory = Path(pyProjectSettings["tool"]["coverage"]["html"]["directory"])
|
||||
xmlFile = Path(pyProjectSettings["tool"]["coverage"]["xml"]["output"])
|
||||
jsonFile = Path(pyProjectSettings["tool"]["coverage"]["json"]["output"])
|
||||
else:
|
||||
print(f"File '{pyProjectFile}' not found and no '.coveragerc' file specified.")
|
||||
|
||||
# Read output paths from '.coveragerc' file
|
||||
elif len(coverageRC) > 0:
|
||||
coverageRCFile = Path(coverageRC)
|
||||
if coverageRCFile.exists():
|
||||
with coverageRCFile.open("rb") as file:
|
||||
coverageRCSettings = tomli_load(file)
|
||||
|
||||
htmlDirectory = Path(coverageRCSettings["html"]["directory"])
|
||||
xmlFile = Path(coverageRCSettings["xml"]["output"])
|
||||
jsonFile = Path(coverageRCSettings["json"]["output"])
|
||||
else:
|
||||
print(f"File '{coverageRCFile}' not found.")
|
||||
|
||||
# Write jobs to special file
|
||||
github_output = Path(getenv("GITHUB_OUTPUT"))
|
||||
print(f"GITHUB_OUTPUT: {github_output}")
|
||||
with github_output.open("a+", encoding="utf-8") as f:
|
||||
f.write(dedent(f"""\
|
||||
unittest_report_html_directory={htmlDirectory}
|
||||
coverage_report_html_directory={htmlDirectory.as_posix()}
|
||||
coverage_report_xml={xmlFile}
|
||||
coverage_report_json={jsonFile}
|
||||
"""))
|
||||
|
||||
print(f"DEBUG:\n html={htmlDirectory}\n xml={xmlFile}\n json={jsonFile}")
|
||||
|
||||
- name: ☑ Run unit tests (Ubuntu/macOS)
|
||||
if: matrix.system != 'windows'
|
||||
run: |
|
||||
export ENVIRONMENT_NAME="${{ matrix.envname }}"
|
||||
export PYTHONPATH=$(pwd)
|
||||
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
|
||||
echo "python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_directory }}"
|
||||
python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_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 -rA $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}"
|
||||
coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}
|
||||
else
|
||||
echo "python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}"
|
||||
python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}
|
||||
fi
|
||||
|
||||
- name: ☑ Run unit tests (Windows)
|
||||
if: matrix.system == 'windows'
|
||||
run: |
|
||||
$env:ENVIRONMENT_NAME = "${{ matrix.envname }}"
|
||||
$env:PYTHONPATH = (Get-Location).ToString()
|
||||
|
||||
# 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 -rA --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}"
|
||||
coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}
|
||||
} else {
|
||||
Write-Host "python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}"
|
||||
python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}
|
||||
}
|
||||
|
||||
- name: Convert to XML format (Cobertura)
|
||||
if: inputs.coverage_xml_artifact != ''
|
||||
run: coverage xml --data-file=.coverage
|
||||
|
||||
- name: Convert to JSON format
|
||||
if: inputs.coverage_json_artifact != ''
|
||||
run: coverage json --data-file=.coverage
|
||||
|
||||
- name: Convert to HTML format
|
||||
if: inputs.coverage_html_artifact != ''
|
||||
run: |
|
||||
coverage html --data-file=.coverage -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
||||
rm ${{ steps.getVariables.outputs.coverage_report_html_directory }}/.gitignore
|
||||
|
||||
- name: 📤 Upload 'TestReportSummary.xml' artifact
|
||||
if: inputs.artifact != ''
|
||||
if: inputs.unittest_xml_artifact != ''
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.artifact }}-${{ matrix.system }}-${{ matrix.python }}
|
||||
path: ${{ inputs.tests_directory || '.' }}/TestReportSummary.xml
|
||||
name: ${{ inputs.unittest_xml_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
|
||||
path: report/unit/TestReportSummary.xml
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
# - name: 📤 Upload 'Unit Tests HTML Report' artifact
|
||||
# if: inputs.unittest_html_artifact != ''
|
||||
# continue-on-error: true
|
||||
# uses: actions/upload-artifact@v3
|
||||
# with:
|
||||
# name: ${{ inputs.unittest_html_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
|
||||
# path: ${{ steps.getVariables.outputs.unittest_report_html_directory }}
|
||||
# if-no-files-found: error
|
||||
# retention-days: 1
|
||||
|
||||
- name: 📤 Upload 'Coverage SQLite Database' artifact
|
||||
if: inputs.coverage_sqlite_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_sqlite_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
|
||||
path: .coverage
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: 📤 Upload 'Coverage XML Report' artifact
|
||||
if: inputs.coverage_xml_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_xml_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
|
||||
path: ${{ steps.getVariables.outputs.coverage_report_xml }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: 📤 Upload 'Coverage JSON Report' artifact
|
||||
if: inputs.coverage_json_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_json_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
|
||||
path: ${{ steps.getVariables.outputs.coverage_report_json }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: 📤 Upload 'Coverage HTML Report' artifact
|
||||
if: inputs.coverage_html_artifact != ''
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.coverage_html_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
|
||||
path: ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
158
.github/workflows/_Checking_Pipeline.yml
vendored
158
.github/workflows/_Checking_Pipeline.yml
vendored
@@ -9,18 +9,15 @@ jobs:
|
||||
uses: pyTooling/Actions/.github/workflows/Parameters.yml@cov
|
||||
with:
|
||||
name: pyDummy
|
||||
python_version_list: "3.11"
|
||||
# python_version_list: "3.7 3.8 pypy-3.8 3.9 pypy-3.9 3.10 3.11"
|
||||
exclude_list: "windows:pypy-3.8 windows:pypy-3.9"
|
||||
# disable_list: "windows:3.11"
|
||||
python_version_list: "3.8 3.9 3.10 3.11 3.12 pypy-3.8 pypy-3.9 pypy-3.10"
|
||||
disable_list: "windows:pypy-3.10"
|
||||
|
||||
PlatformTestingParams:
|
||||
uses: pyTooling/Actions/.github/workflows/Parameters.yml@cov
|
||||
with:
|
||||
name: Platform
|
||||
python_version_list: ""
|
||||
system_list: "ubuntu"
|
||||
# system_list: "ubuntu windows macos mingw32 mingw64 clang64 ucrt64"
|
||||
system_list: "ubuntu windows macos mingw32 mingw64 clang64 ucrt64"
|
||||
|
||||
UnitTesting:
|
||||
uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@cov
|
||||
@@ -28,7 +25,12 @@ jobs:
|
||||
- UnitTestingParams
|
||||
with:
|
||||
jobs: ${{ needs.UnitTestingParams.outputs.python_jobs }}
|
||||
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}
|
||||
unittest_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}
|
||||
unittest_html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_html }}
|
||||
# coverage_sqlite_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}
|
||||
# coverage_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}
|
||||
# coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}
|
||||
# coverage_html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
|
||||
|
||||
PlatformTesting:
|
||||
uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@cov
|
||||
@@ -36,27 +38,24 @@ jobs:
|
||||
- PlatformTestingParams
|
||||
with:
|
||||
jobs: ${{ needs.PlatformTestingParams.outputs.python_jobs }}
|
||||
tests_directory: ""
|
||||
unittest_directory: tests/unit/Platform
|
||||
artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_xml }}
|
||||
# tests_directory: ""
|
||||
unittest_directory: platform
|
||||
unittest_xml_artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_xml }}
|
||||
unittest_html_artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_html }}
|
||||
coverage_sqlite_artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_sqlite }}
|
||||
coverage_xml_artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_xml }}
|
||||
coverage_json_artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_json }}
|
||||
coverage_html_artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_html }}
|
||||
|
||||
Coverage:
|
||||
uses: pyTooling/Actions/.github/workflows/CoverageCollection.yml@cov
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
with:
|
||||
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
|
||||
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
|
||||
secrets:
|
||||
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
|
||||
PublishCoverageResults:
|
||||
uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@cov
|
||||
needs:
|
||||
- UnitTesting
|
||||
- Coverage
|
||||
secrets:
|
||||
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
# Coverage:
|
||||
# uses: pyTooling/Actions/.github/workflows/CoverageCollection.yml@cov
|
||||
# needs:
|
||||
# - UnitTestingParams
|
||||
# with:
|
||||
# python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
|
||||
# artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
|
||||
# secrets:
|
||||
# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
|
||||
StaticTypeCheck:
|
||||
uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@cov
|
||||
@@ -69,44 +68,38 @@ jobs:
|
||||
html_report: 'htmlmypy'
|
||||
html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}
|
||||
|
||||
PublishCoverageResults:
|
||||
uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@cov
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
- UnitTesting
|
||||
- PlatformTesting
|
||||
# - Coverage
|
||||
with:
|
||||
coverage_sqlite_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}
|
||||
coverage_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}
|
||||
coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}
|
||||
coverage_html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
|
||||
secrets:
|
||||
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
|
||||
PublishTestResults:
|
||||
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@cov
|
||||
needs:
|
||||
- UnitTesting
|
||||
- PlatformTesting
|
||||
|
||||
Package:
|
||||
uses: pyTooling/Actions/.github/workflows/Package.yml@cov
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
- Coverage
|
||||
- UnitTesting
|
||||
# - Coverage
|
||||
- PlatformTesting
|
||||
with:
|
||||
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
|
||||
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
|
||||
|
||||
Release:
|
||||
uses: pyTooling/Actions/.github/workflows/Release.yml@cov
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
needs:
|
||||
- UnitTesting
|
||||
- Coverage
|
||||
- StaticTypeCheck
|
||||
- Package
|
||||
|
||||
PublishOnPyPI:
|
||||
uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@cov
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
- Release
|
||||
- Package
|
||||
with:
|
||||
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
|
||||
requirements: -r dist/requirements.txt
|
||||
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
|
||||
secrets:
|
||||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
||||
|
||||
# VerifyDocs:
|
||||
# uses: pyTooling/Actions/.github/workflows/VerifyDocs.yml@cov
|
||||
# needs:
|
||||
@@ -114,33 +107,60 @@ jobs:
|
||||
# with:
|
||||
# python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
|
||||
|
||||
# BuildTheDocs:
|
||||
# uses: pyTooling/Actions/.github/workflows/BuildTheDocs.yml@cov
|
||||
# needs:
|
||||
# - UnitTestingParams
|
||||
## - VerifyDocs
|
||||
# with:
|
||||
# artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }}
|
||||
BuildTheDocs:
|
||||
uses: pyTooling/Actions/.github/workflows/BuildTheDocs.yml@cov
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
# - VerifyDocs
|
||||
with:
|
||||
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }}
|
||||
|
||||
PublishToGitHubPages:
|
||||
uses: pyTooling/Actions/.github/workflows/PublishToGitHubPages.yml@cov
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
# - BuildTheDocs
|
||||
- Coverage
|
||||
- BuildTheDocs
|
||||
# - Coverage
|
||||
- PublishCoverageResults
|
||||
- StaticTypeCheck
|
||||
with:
|
||||
doc: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }}
|
||||
coverage: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
|
||||
typing: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}
|
||||
|
||||
ReleasePage:
|
||||
uses: pyTooling/Actions/.github/workflows/Release.yml@cov
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
needs:
|
||||
- UnitTesting
|
||||
- PlatformTesting
|
||||
# - Coverage
|
||||
# - StaticTypeCheck
|
||||
- Package
|
||||
- PublishToGitHubPages
|
||||
|
||||
PublishOnPyPI:
|
||||
uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@cov
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
- ReleasePage
|
||||
# - Package
|
||||
with:
|
||||
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
|
||||
requirements: -r dist/requirements.txt
|
||||
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
|
||||
secrets:
|
||||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
||||
|
||||
ArtifactCleanUp:
|
||||
uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@cov
|
||||
needs:
|
||||
- UnitTestingParams
|
||||
- PlatformTestingParams
|
||||
- UnitTesting
|
||||
- PlatformTesting
|
||||
- Coverage
|
||||
# - Coverage
|
||||
- StaticTypeCheck
|
||||
# - BuildTheDocs
|
||||
- PublishToGitHubPages
|
||||
@@ -150,6 +170,22 @@ jobs:
|
||||
package: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
|
||||
remaining: |
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-*
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_html }}-*
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}-*
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}-*
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}-*
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}-*
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_html }}
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}
|
||||
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }}
|
||||
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_xml }}-*
|
||||
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_html }}-*
|
||||
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_sqlite }}-*
|
||||
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_xml }}-*
|
||||
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_json }}-*
|
||||
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_html }}-*
|
||||
|
||||
Reference in New Issue
Block a user