From 9808b6c7f9415fe77d3aff52a7af3b3d3dac7961 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 10 Nov 2024 18:22:13 +0100 Subject: [PATCH] Handle simple packages and namespace packages by pipeline template. Added pipeline to check pipeline templates. --- ...espacePackage.yml => CompletePipeline.yml} | 39 ++++--- .github/workflows/ExtractConfiguration.yml | 50 +++++++++ .github/workflows/Parameters.yml | 36 ++++--- ...ipeline.yml => _Checking_JobTemplates.yml} | 18 ++-- .../_Checking_NamespacePackage_Pipeline.yml | 12 +++ .github/workflows/_Checking_Parameters.yml | 2 +- .../_Checking_SimplePackage_Pipeline.yml | 11 ++ pyExamples/Extensions/__init__.py | 101 ++++++++++++++++++ pyExamples/Extensions/py.typed | 0 9 files changed, 229 insertions(+), 40 deletions(-) rename .github/workflows/{Pipeline-NamespacePackage.yml => CompletePipeline.yml} (92%) rename .github/workflows/{_Checking_Pipeline.yml => _Checking_JobTemplates.yml} (97%) create mode 100644 .github/workflows/_Checking_NamespacePackage_Pipeline.yml create mode 100644 .github/workflows/_Checking_SimplePackage_Pipeline.yml create mode 100644 pyExamples/Extensions/__init__.py create mode 100644 pyExamples/Extensions/py.typed diff --git a/.github/workflows/Pipeline-NamespacePackage.yml b/.github/workflows/CompletePipeline.yml similarity index 92% rename from .github/workflows/Pipeline-NamespacePackage.yml rename to .github/workflows/CompletePipeline.yml index e6e24d4c..5d74c9b8 100644 --- a/.github/workflows/Pipeline-NamespacePackage.yml +++ b/.github/workflows/CompletePipeline.yml @@ -4,11 +4,12 @@ on: workflow_call: inputs: package_namespace: - description: 'Name of the tool.' - required: true + description: 'Name of the tool''s namespace.' + required: false + default: '' type: string package_name: - description: 'Name of the tool.' + description: 'Name of the tool''s package.' required: true type: string unittest_python_version: @@ -73,13 +74,20 @@ on: type: string jobs: + ConfigParams: + uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@dev + with: + package_namespace: ${{ inputs.package_namespace }} + package_name: ${{ inputs.package_name }} + UnitTestingParams: uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev with: - name: "${{ inputs.package_namespace }}.${{ inputs.package_name }}" - python_version: ${{ inputs.unittest_python_version }} + package_namespace: ${{ inputs.package_namespace }} + package_name: ${{ inputs.package_name }} + python_version: ${{ inputs.unittest_python_version }} python_version_list: ${{ inputs.unittest_python_version_list }} - system_list: ${{ inputs.unittest_system_list }} + system_list: ${{ inputs.unittest_system_list }} include_list: ${{ inputs.unittest_include_list }} exclude_list: ${{ inputs.unittest_exclude_list }} disable_list: ${{ inputs.unittest_disable_list }} @@ -87,10 +95,11 @@ jobs: AppTestingParams: uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev with: - name: "${{ inputs.package_namespace }}.${{ inputs.package_name }}" - python_version: ${{ inputs.apptest_python_version }} + package_namespace: ${{ inputs.package_namespace }} + package_name: ${{ inputs.package_name }} + python_version: ${{ inputs.apptest_python_version }} python_version_list: ${{ inputs.apptest_python_version_list }} - system_list: ${{ inputs.apptest_system_list }} + system_list: ${{ inputs.apptest_system_list }} include_list: ${{ inputs.apptest_include_list }} exclude_list: ${{ inputs.apptest_exclude_list }} disable_list: ${{ inputs.apptest_disable_list }} @@ -109,13 +118,14 @@ jobs: StaticTypeCheck: uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@dev needs: + - ConfigParams - UnitTestingParams with: python_version: ${{ needs.UnitTestingParams.outputs.python_version }} commands: | - touch ${{ inputs.package_namespace }}/__init__.py - mypy --html-report htmlmypy -p ${{ inputs.package_namespace }}.${{ inputs.name }} - html_report: 'htmlmypy' + ${{ needs.ConfigParams.outputs.mypy_prepare_command }} + mypy --html-report report/typing -p ${{ needs.ConfigParams.outputs.package_fullname }} + html_report: 'report/typing' html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} DocCoverage: @@ -127,11 +137,6 @@ jobs: directory: ${{ inputs.package_namespace }}/${{ inputs.package_name }} # fail_below: 70 - ConfigParams: - uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@dev - needs: - - DocCoverage - Package: uses: pyTooling/Actions/.github/workflows/Package.yml@dev needs: diff --git a/.github/workflows/ExtractConfiguration.yml b/.github/workflows/ExtractConfiguration.yml index 5ce99bc6..cf23938f 100644 --- a/.github/workflows/ExtractConfiguration.yml +++ b/.github/workflows/ExtractConfiguration.yml @@ -34,6 +34,15 @@ on: required: false default: '3.12' type: string + package_namespace: + description: 'Name of the tool''s namespace.' + required: false + default: '' + type: string + package_name: + description: 'Name of the tool''s package.' + required: true + type: string coverage_config: description: 'Path to the .coveragerc file. Use pyproject.toml by default.' required: false @@ -41,6 +50,15 @@ on: type: string outputs: + package_fullname: + description: "" + value: ${{ jobs.Extract.outputs.package_fullname }} + package_directory: + description: "" + value: ${{ jobs.Extract.outputs.package_directory }} + mypy_prepare_command: + description: "" + value: ${{ jobs.Extract.outputs.mypy_prepare_command }} coverage_report_html_directory: description: "" value: ${{ jobs.Extract.outputs.coverage_report_html_directory }} @@ -62,6 +80,9 @@ jobs: name: 📓 Extract configurations from pyproject.toml runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}" outputs: + package_fullname: ${{ steps.getPackageName.outputs.package_fullname }} + package_directory: ${{ steps.getPackageName.outputs.package_directory }} + mypy_prepare_command: ${{ steps.getPackageName.outputs.mypy_prepare_command }} coverage_report_html_directory: ${{ steps.getVariables.outputs.coverage_report_html_directory }} coverage_report_xml_directory: ${{ steps.getVariables.outputs.coverage_report_xml_directory }} coverage_report_xml: ${{ steps.getVariables.outputs.coverage_report_xml }} @@ -81,6 +102,35 @@ jobs: run: | python -m pip install --disable-pip-version-check -U wheel tomli + - name: 🔁 Full package name and directory + id: getPackageName + shell: python + run: | + from os import getenv + from pathlib import Path + from textwrap import dedent + + namespace = "${{ inputs.package_namespace }}".strip() + name = "${{ inputs.package_name }}".strip() + + if namespace == "" or namespace == ".": + fullname = f"{name}" + directory = f"{name}" + mypy_prepare_command = "" + else: + fullname = f"{namespace}.{name}" + directory = f"{namespace}/{name}" + mypy_prepare_command = f"touch {namespace}/__init__.py" + + 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"""\ + package_fullname={fullname} + package_directory={directory} + mypy_prepare_command={mypy_prepare_command} + """)) + - name: 🔁 Extract configurations from pyproject.toml id: getVariables shell: python diff --git a/.github/workflows/Parameters.yml b/.github/workflows/Parameters.yml index c6d03fc6..ca02b745 100644 --- a/.github/workflows/Parameters.yml +++ b/.github/workflows/Parameters.yml @@ -32,7 +32,18 @@ on: type: string name: description: 'Name of the tool.' - required: true + required: false + default: '' + type: string + package_namespace: + description: 'Name of the tool''s namespace.' + required: false + default: '' + type: string + package_name: + description: 'Name of the tool''s package.' + required: false + default: '' type: string python_version: description: 'Python version.' @@ -120,7 +131,9 @@ jobs: from textwrap import dedent from typing import Iterable - name = "${{ inputs.name }}".strip() + package_namespace = "${{ inputs.package_namespace }}".strip() + package_name = "${{ inputs.package_name }}".strip() + name = "${{ inputs.name }}".strip() python_version = "${{ inputs.python_version }}".strip() systems = "${{ inputs.system_list }}".strip() versions = "${{ inputs.python_version_list }}".strip() @@ -128,6 +141,12 @@ jobs: exclude_list = "${{ inputs.exclude_list }}".strip() disable_list = "${{ inputs.disable_list }}".strip() + if name == "": + if package_namespace == "" or package_namespace == ".": + name = f"{package_name}" + else: + name = f"{package_namespace}.{package_name}" + currentMSYS2Version = "3.11" currentAlphaVersion = "3.14" currentAlphaRelease = "3.14.0-alpha.1" @@ -296,18 +315,6 @@ jobs: "documentation_pdf": f"{name}-Documentation-PDF", } - # Deprecated structure - params = { - "python_version": python_version, - "artifacts": { - "unittesting": f"{artifact_names['unittesting_xml']}", - "coverage": f"{artifact_names['codecoverage_html']}", - "typing": f"{artifact_names['statictyping_html']}", - "package": f"{artifact_names['package_all']}", - "doc": f"{artifact_names['documentation_html']}", - } - } - print("Parameters:") print(f" python_version: {python_version}") print(f" python_jobs ({len(jobs)}):\n" + @@ -325,7 +332,6 @@ jobs: python_version={python_version} python_jobs={json_dumps(jobs)} artifact_names={json_dumps(artifact_names)} - params={json_dumps(params)} """)) - name: Verify out parameters diff --git a/.github/workflows/_Checking_Pipeline.yml b/.github/workflows/_Checking_JobTemplates.yml similarity index 97% rename from .github/workflows/_Checking_Pipeline.yml rename to .github/workflows/_Checking_JobTemplates.yml index e652bef3..a6b40895 100644 --- a/.github/workflows/_Checking_Pipeline.yml +++ b/.github/workflows/_Checking_JobTemplates.yml @@ -1,10 +1,17 @@ -name: Verification of Complete Pipeline +name: Verification of Job Templates on: push: workflow_dispatch: jobs: + ConfigParams: + uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@dev + needs: + - DocCoverage + with: + package_name: pyDummy + UnitTestingParams: uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev with: @@ -60,11 +67,13 @@ jobs: StaticTypeCheck: uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@dev needs: + - ConfigParams - UnitTestingParams with: python_version: ${{ needs.UnitTestingParams.outputs.python_version }} commands: | - mypy --html-report htmlmypy -p pyDummy + ${{ needs.ConfigParams.outputs.mypy_prepare_command }} + mypy --html-report htmlmypy -p ${{ needs.ConfigParams.outputs.package_fullname }} html_report: 'htmlmypy' html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} @@ -77,11 +86,6 @@ jobs: directory: sphinx_reports # fail_below: 70 - ConfigParams: - uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@dev - needs: - - DocCoverage - Package: uses: pyTooling/Actions/.github/workflows/Package.yml@dev needs: diff --git a/.github/workflows/_Checking_NamespacePackage_Pipeline.yml b/.github/workflows/_Checking_NamespacePackage_Pipeline.yml new file mode 100644 index 00000000..c597b0ae --- /dev/null +++ b/.github/workflows/_Checking_NamespacePackage_Pipeline.yml @@ -0,0 +1,12 @@ +name: Verification of Pipeline Templates + +on: + push: + workflow_dispatch: + +jobs: + NamespacePackage: + uses: pyTooling/Actions/.github/workflows/CompletePipeline.yml@dev + with: + package_namespace: pyExamples + package_name: Extensions diff --git a/.github/workflows/_Checking_Parameters.yml b/.github/workflows/_Checking_Parameters.yml index 3b8566b4..12a0ac53 100644 --- a/.github/workflows/_Checking_Parameters.yml +++ b/.github/workflows/_Checking_Parameters.yml @@ -460,7 +460,7 @@ jobs: expectedPythonVersion = "3.13" expectedPythons = ["3.12", "3.13"] - expectedSystems = ["ubuntu", "windows"] + expectedSystems = ["ubuntu", "macos-arm", "windows"] expectedJobs = [f"{system}:{python}" for system in expectedSystems for python in expectedPythons] + ["windows:3.10", "windows:3.11", "windows:3.13"] expectedName = "Example" expectedArtifacts = { diff --git a/.github/workflows/_Checking_SimplePackage_Pipeline.yml b/.github/workflows/_Checking_SimplePackage_Pipeline.yml new file mode 100644 index 00000000..d24c48d0 --- /dev/null +++ b/.github/workflows/_Checking_SimplePackage_Pipeline.yml @@ -0,0 +1,11 @@ +name: Verification of Pipeline Templates + +on: + push: + workflow_dispatch: + +jobs: + SimplePackage: + uses: pyTooling/Actions/.github/workflows/CompletePipeline.yml@dev + with: + package_name: pyDummy diff --git a/pyExamples/Extensions/__init__.py b/pyExamples/Extensions/__init__.py new file mode 100644 index 00000000..437cb700 --- /dev/null +++ b/pyExamples/Extensions/__init__.py @@ -0,0 +1,101 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2024 Patrick Lehmann - Bötzingen, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +# SPDX-License-Identifier: Apache-2.0 # +# ==================================================================================================================== # +# +""" +A module for a set of dummy classes. +""" + +__author__ = "Patrick Lehmann" +__email__ = "Paebbels@gmail.com" +__copyright__ = "2017-2024, Patrick Lehmann" +__license__ = "Apache License, Version 2.0" +__version__ = "0.14.8" +__keywords__ = ["GitHub Actions"] +__issue_tracker__ = "https://GitHub.com/pyTooling/Actions/issues" + +from pyTooling.Decorators import export, readonly +from pyTooling.Platform import Platform + + +@export +class Base: + """ + A base-class for dummy applications. + """ + + _value: int #: An internal value. + + def __init__(self) -> None: + """ + Initializes the base-class. + """ + self._value = 0 + + @readonly + def Value(self) -> int: + """ + Read-only property to return the internal value. + + :return: Internal value. + """ + return self._value + + +@export +class Application(Base): + """ + A dummy application for demonstration purposes. + """ + + def __init__(self) -> None: + """ + Initializes the dummy application. + """ + super().__init__() + + platform = Platform() + if platform.IsNativeLinux: + self._value += 1 + elif platform.IsNativeMacOS: + self._value += 2 + elif platform.IsNativeWindows: + self._value += 3 + elif platform.IsMSYSOnWindows: + self._value += 11 + elif platform.IsMinGW32OnWindows: + self._value += 12 + elif platform.IsMinGW64OnWindows: + self._value += 13 + elif platform.IsUCRT64OnWindows: + self._value += 14 + elif platform.IsClang32OnWindows: + self._value += 15 + elif platform.IsClang64OnWindows: + self._value += 16 diff --git a/pyExamples/Extensions/py.typed b/pyExamples/Extensions/py.typed new file mode 100644 index 00000000..e69de29b