diff --git a/.github/workflows/CompletePipeline.yml b/.github/workflows/CompletePipeline.yml index 1e2045c..bbef59c 100644 --- a/.github/workflows/CompletePipeline.yml +++ b/.github/workflows/CompletePipeline.yml @@ -177,6 +177,58 @@ jobs: exclude_list: ${{ inputs.unittest_exclude_list }} disable_list: ${{ inputs.unittest_disable_list }} + VersionCheck: + name: '' + runs-on: 'ubuntu-24.04' + needs: + - Prepare + - UnitTestingParams + if: needs.Prepare.outputs.version != '' && needs.UnitTestingParams.outputs.package_version_file != '' + outputs: + code_version: ${{ steps.extract.outputs.code_version }} + steps: + - name: ⏬ Checkout repository + uses: actions/checkout@v5 + with: + # The command 'git describe' (used for version) needs the history. + fetch-depth: 0 + + - name: 🔧 Install pyTooling dependencies (native) + run: | + python -m pip install --disable-pip-version-check -U pyTooling + + - name: Extract version from Python source file + id: extract + if: endsWith(needs.UnitTestingParams.outputs.package_version_file, '.py') + shell: python + run: | + from pathlib import Path + from sys import exit + from pyTooling.Packaging import extractVersionInformation + + expectedVersion = "${{ needs.Prepare.outputs.version }}".strip() + + versionFile = Path("${{ needs.UnitTestingParams.outputs.package_version_file }}") + if not versionFile.exists(): + print(f"::error title=CompletePipeline::Version file '{versionFile}' not found.") + exit(1) + + versionInformation = extractVersionInformation(versionFile) + print(f"expected: {expectedVersion}") + print(f"from code: {versionInformation.Version}") + + if expectedVersion != versionInformation.Version: + print(f"::error title=CompletePipeline::Expected version does not version in Python code.") + exit(2) + + # 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"""\ + code_version={versionInformation.Version} + """)) + UnitTesting: uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@main needs: diff --git a/.github/workflows/Parameters.yml b/.github/workflows/Parameters.yml index b005fb8..9227533 100644 --- a/.github/workflows/Parameters.yml +++ b/.github/workflows/Parameters.yml @@ -45,6 +45,11 @@ on: required: false default: '' type: string + version_file: + description: "Path to module containing the version ('__version__' variable)." + required: false + default: '__init__.py' + type: string python_version: description: 'Python version.' required: false @@ -121,6 +126,9 @@ on: package_directory: description: "The package's directory." value: ${{ jobs.Parameters.outputs.package_directory }} + package_version_file: + description: "Path to the package's module containing the version ('__version__' variable)." + value: ${{ jobs.Parameters.outputs.package_version_file }} artifact_basename: description: "Artifact base name." value: ${{ jobs.Parameters.outputs.artifact_basename }} @@ -136,14 +144,21 @@ jobs: name: ✎ Generate pipeline parameters runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}" outputs: - python_version: ${{ steps.variables.outputs.python_version }} - package_fullname: ${{ steps.variables.outputs.package_fullname }} - package_directory: ${{ steps.variables.outputs.package_directory }} - artifact_basename: ${{ steps.variables.outputs.artifact_basename }} - artifact_names: ${{ steps.artifacts.outputs.artifact_names }} - python_jobs: ${{ steps.jobs.outputs.python_jobs }} + python_version: ${{ steps.variables.outputs.python_version }} + package_fullname: ${{ steps.variables.outputs.package_fullname }} + package_directory: ${{ steps.variables.outputs.package_directory }} + package_version_file: ${{ steps.variables.outputs.package_version_file }} + artifact_basename: ${{ steps.variables.outputs.artifact_basename }} + artifact_names: ${{ steps.artifacts.outputs.artifact_names }} + python_jobs: ${{ steps.jobs.outputs.python_jobs }} steps: + - name: ⏬ Checkout repository + uses: actions/checkout@v5 + with: + # The command 'git describe' (used for version) needs the history. + fetch-depth: 0 + - name: Generate a startup delay of ${{ inputs.pipeline-delay }} seconds id: delay if: inputs.pipeline-delay >= 0 @@ -162,6 +177,7 @@ jobs: python_version = "${{ inputs.python_version }}".strip() package_namespace = "${{ inputs.package_namespace }}".strip() package_name = "${{ inputs.package_name }}".strip() + version_file = "${{ inputs.version_file }}".strip() name = "${{ inputs.name }}".strip() if package_namespace == "": @@ -174,16 +190,28 @@ jobs: package_fullname = f"{package_namespace}.{package_name}" package_directory = f"{package_namespace}/{package_name}" + packageDirectory = Path(package_directory) + packageVersionFile = packageDirectory / version_file + print(f"Check if package version file '{packageVersionFile}' exists ... ", end="") + if packageVersionFile.exists(): + print("✅") + package_version_file = packageVersionFile.as_posix() + else: + print("❌") + package_version_file = "" + print(f"::warning title=Parameters::Version file '{packageVersionFile}' not found.") + artifact_basename = package_fullname if name == "" else name if artifact_basename == "" or artifact_basename == ".": - print("::error title=Parameter::artifact_basename is empty.") + print("::error title=Parameters::artifact_basename is empty.") exit(1) print("Variables:") - print(f" python_version: {python_version}") - print(f" package_fullname: {package_fullname}") - print(f" package_directory: {package_directory}") - print(f" artifact_basename: {artifact_basename}") + print(f" python_version: {python_version}") + print(f" package_fullname: {package_fullname}") + print(f" package_directory: {package_directory}") + print(f" package_version_file: {package_directory}") + print(f" artifact_basename: {artifact_basename}") # Write jobs to special file github_output = Path(getenv("GITHUB_OUTPUT")) @@ -193,6 +221,7 @@ jobs: python_version={python_version} package_fullname={package_fullname} package_directory={package_directory} + package_version_file={package_version_file} artifact_basename={artifact_basename} """)) @@ -263,7 +292,7 @@ jobs: currentAlphaRelease = "3.15.0-a.1" if systems == "": - print("::error title=Parameter::system_list is empty.") + print("::error title=Parameters::system_list is empty.") else: systems = [sys.strip() for sys in systems.split(" ")] @@ -428,12 +457,13 @@ jobs: - name: Verify out parameters id: verify run: | - printf "python_version: %s\n" '${{ steps.variables.outputs.python_version }}' - printf "package_fullname: %s\n" '${{ steps.variables.outputs.package_fullname }}' - printf "package_directory: %s\n" '${{ steps.variables.outputs.package_directory }}' - printf "artifact_basename: %s\n" '${{ steps.variables.outputs.artifact_basename }}' - printf "====================\n" - printf "artifact_names: %s\n" '${{ steps.artifacts.outputs.artifact_names }}' - printf "====================\n" - printf "python_jobs: %s\n" '${{ steps.jobs.outputs.python_jobs }}' - printf "====================\n" + printf "python_version: %s\n" '${{ steps.variables.outputs.python_version }}' + printf "package_fullname: %s\n" '${{ steps.variables.outputs.package_fullname }}' + printf "package_directory: %s\n" '${{ steps.variables.outputs.package_directory }}' + printf "package_version_file: %s\n" '${{ steps.variables.outputs.package_version_file }}' + printf "artifact_basename: %s\n" '${{ steps.variables.outputs.artifact_basename }}' + printf "================================================================================\n" + printf "artifact_names: %s\n" '${{ steps.artifacts.outputs.artifact_names }}' + printf "================================================================================\n" + printf "python_jobs: %s\n" '${{ steps.jobs.outputs.python_jobs }}' + printf "================================================================================\n" diff --git a/.github/workflows/PublishReleaseNotes.yml b/.github/workflows/PublishReleaseNotes.yml index 4fb926e..36c090a 100644 --- a/.github/workflows/PublishReleaseNotes.yml +++ b/.github/workflows/PublishReleaseNotes.yml @@ -549,7 +549,7 @@ jobs: )" \ '{"tag": $tag, "version": $version, "git-hash": $hash, "repository-url": $repo, "release-url": $release, "categories": $categories, "latest": $jsonLatest}' \ )" \ - '{"version": "$structVersion", "timestamp": $date, "meta": $jsonMeta, "files": {}}' + '{"version": $structVersion, "timestamp": $date, "meta": $jsonMeta, "files": {}}' ) fi diff --git a/.github/workflows/_Checking_JobTemplates.yml b/.github/workflows/_Checking_JobTemplates.yml index 8d9e5c5..c341420 100644 --- a/.github/workflows/_Checking_JobTemplates.yml +++ b/.github/workflows/_Checking_JobTemplates.yml @@ -15,9 +15,8 @@ jobs: uses: pyTooling/Actions/.github/workflows/Parameters.yml@main with: package_name: 'myPackage' - python_version: '3.13' # workaround to use Sphinx in Python 3.13 for sphinx_reports not yet supporting lxml 6.0 - python_version_list: '3.10 3.11 3.12 3.13 3.14 pypy-3.10 pypy-3.11' - disable_list: 'windows-arm:pypy-3.10 windows-arm:pypy-3.11' + python_version_list: '3.11 3.12 3.13 3.14 pypy-3.11' + disable_list: 'windows-arm:pypy-3.11' PlatformTestingParams: uses: pyTooling/Actions/.github/workflows/Parameters.yml@main diff --git a/.github/workflows/_Checking_NamespacePackage_Pipeline.yml b/.github/workflows/_Checking_NamespacePackage_Pipeline.yml index ebb9cc5..7d4cc60 100644 --- a/.github/workflows/_Checking_NamespacePackage_Pipeline.yml +++ b/.github/workflows/_Checking_NamespacePackage_Pipeline.yml @@ -10,7 +10,7 @@ jobs: with: package_namespace: 'myFramework' package_name: 'Extension' - unittest_python_version: '3.13' # workaround to use Sphinx in Python 3.13 for sphinx_reports not yet supporting lxml 6.0 + unittest_python_version_list: '3.11 3.12 3.13 3.14 pypy-3.11' bandit: 'true' pylint: 'true' codecov: 'true' diff --git a/.github/workflows/_Checking_SimplePackage_Pipeline.yml b/.github/workflows/_Checking_SimplePackage_Pipeline.yml index 337fd05..f40e3fa 100644 --- a/.github/workflows/_Checking_SimplePackage_Pipeline.yml +++ b/.github/workflows/_Checking_SimplePackage_Pipeline.yml @@ -9,7 +9,7 @@ jobs: uses: pyTooling/Actions/.github/workflows/CompletePipeline.yml@main with: package_name: 'myPackage' - unittest_python_version: '3.13' # workaround to use Sphinx in Python 3.13 for sphinx_reports not yet supporting lxml 6.0 + unittest_python_version_list: '3.11 3.12 3.13 3.14 pypy-3.11' bandit: 'true' pylint: 'true' codecov: 'true' diff --git a/doc/index.rst b/doc/index.rst index 0242c18..344e2cf 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -164,7 +164,7 @@ Example Pipelines .. code-block:: toml [build-system] - requires = ["setuptools >= 80.0", "wheel ~= 0.45", "pyTooling ~= 8.7"] + requires = ["setuptools >= 80.0", "wheel ~= 0.45", "pyTooling ~= 8.8"] build-backend = "setuptools.build_meta" [tool.mypy] diff --git a/doc/requirements.txt b/doc/requirements.txt index 67873db..725f8ae 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,6 +1,6 @@ -r ../requirements.txt -pyTooling ~= 8.7 +pyTooling ~= 8.8 # Enforce latest version on ReadTheDocs sphinx ~= 8.2 diff --git a/pyproject.toml b/pyproject.toml index 8108040..11c4f18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools >= 80.0", "wheel ~= 0.45", - "pyTooling ~= 8.7" + "pyTooling ~= 8.8" ] build-backend = "setuptools.build_meta" @@ -38,23 +38,21 @@ junit_xml = "report/typing/StaticTypingSummary.xml" cobertura_xml_report = "report/typing" [tool.pytest] -junit_xml = "report/unit/UnittestReportSummary.xml" - -[tool.pyedaa-reports] -junit_xml = "report/unit/unittest.xml" - -[tool.pytest.ini_options] -addopts = "--tb=native" +addopts = ["--tb=native"] # Don't set 'python_classes = *' otherwise, pytest doesn't search for classes # derived from unittest.Testcase -python_files = "*" -python_functions = "test_*" +python_files = ["*"] +python_functions = ["test_*"] filterwarnings = [ "error::DeprecationWarning", "error::PendingDeprecationWarning" ] +junit_xml = "report/unit/UnittestReportSummary.xml" junit_logging = "all" +[tool.pyedaa-reports] +junit_xml = "report/unit/unittest.xml" + [tool.interrogate] color = true verbose = 1 # possible values: 0 (minimal output), 1 (-v), 2 (-vv) diff --git a/requirements.txt b/requirements.txt index 4fcd219..a5238b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pyTooling ~= 8.7 +pyTooling ~= 8.8 diff --git a/tests/requirements.txt b/tests/requirements.txt index 787c2e6..7a7add3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,7 +4,7 @@ Coverage ~= 7.11 # Test Runner -pytest ~= 8.4 +pytest ~= 9.0 pytest-cov ~= 7.0 # Static Type Checking