From 3cb8ca83a497dd894586cdd76fdb108412a619fc Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 2 Oct 2023 18:55:07 +0200 Subject: [PATCH] Added dummy Python project to test the pipeline. --- .github/workflows/_Checking_Pipeline.yml | 160 +++++++++++++++++++++++ pyDummy/__init__.py | 48 +++++++ pyDummy/py.typed | 0 pyproject.toml | 60 +++++++++ setup.py | 50 +++++++ tests/requirements.txt | 13 ++ tests/unit/Dummy.py | 40 ++++++ 7 files changed, 371 insertions(+) create mode 100644 .github/workflows/_Checking_Pipeline.yml create mode 100644 pyDummy/__init__.py create mode 100644 pyDummy/py.typed create mode 100644 pyproject.toml create mode 100644 setup.py create mode 100644 tests/requirements.txt create mode 100644 tests/unit/Dummy.py diff --git a/.github/workflows/_Checking_Pipeline.yml b/.github/workflows/_Checking_Pipeline.yml new file mode 100644 index 00000000..e07878ca --- /dev/null +++ b/.github/workflows/_Checking_Pipeline.yml @@ -0,0 +1,160 @@ +name: Pipeline + +on: + push: + workflow_dispatch: + +jobs: + UnitTestingParams: + uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev + with: + name: pyTooling + 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" + + PlatformTestingParams: + uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev + with: + name: Platform + python_version_list: "" + system_list: "ubuntu windows macos mingw32 mingw64 clang64 ucrt64" + + UnitTesting: + uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@dev + needs: + - UnitTestingParams + with: + jobs: ${{ needs.UnitTestingParams.outputs.python_jobs }} + artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} + + PlatformTesting: + uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@dev + needs: + - PlatformTestingParams + with: + jobs: ${{ needs.PlatformTestingParams.outputs.python_jobs }} + tests_directory: "" + unittest_directory: tests/unit/Platform + artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_xml }} + + Coverage: + uses: pyTooling/Actions/.github/workflows/CoverageCollection.yml@dev + 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@dev + needs: + - Coverage + - PlatformTesting2 + 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@dev + needs: + - UnitTestingParams + with: + python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + commands: | + touch pyTooling/__init__.py + mypy --html-report htmlmypy -p pyTooling + html_report: 'htmlmypy' + html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} + + PublishTestResults: + uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev + needs: + - UnitTesting + - PerformanceTesting + - Benchmarking + + Package: + uses: pyTooling/Actions/.github/workflows/Package.yml@dev + needs: + - UnitTestingParams + - 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@dev + if: startsWith(github.ref, 'refs/tags') + needs: + - UnitTesting + - Coverage + - StaticTypeCheck + - Package + + PublishOnPyPI: + uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@dev + 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@dev +# needs: +# - UnitTestingParams +# with: +# python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + +# BuildTheDocs: +# uses: pyTooling/Actions/.github/workflows/BuildTheDocs.yml@dev +# needs: +# - UnitTestingParams +## - VerifyDocs +# with: +# artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} + + PublishToGitHubPages: + uses: pyTooling/Actions/.github/workflows/PublishToGitHubPages.yml@dev + needs: + - UnitTestingParams +# - BuildTheDocs + - Coverage + - 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 }} + + ArtifactCleanUp: + uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@dev + needs: + - UnitTestingParams + - UnitTesting + - PerformanceTesting + - Benchmarking + - PlatformTesting + - Coverage + - StaticTypeCheck +# - BuildTheDocs + - PublishToGitHubPages + - PublishTestResults + with: + package: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} + remaining: | + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-* + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} diff --git a/pyDummy/__init__.py b/pyDummy/__init__.py new file mode 100644 index 00000000..f2740322 --- /dev/null +++ b/pyDummy/__init__.py @@ -0,0 +1,48 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 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 # +# ==================================================================================================================== # +# +__author__ = "Patrick Lehmann" +__email__ = "Paebbels@gmail.com" +__copyright__ = "2017-2023, Patrick Lehmann" +__license__ = "Apache License, Version 2.0" +__version__ = "0.1.0" +__keywords__ = ["dummy"] +__issue_tracker__ = "https://GitHub.com/pyTooling/Actions/issues" + + +class Application: + _value: int + + def __init__(self): + self._value = 1 + + @property + def Value(self) -> int: + return self._value diff --git a/pyDummy/py.typed b/pyDummy/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..dca4a29a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[build-system] +requires = [ + "setuptools >= 68.0.0", + "wheel >= 0.40.0", + "pyTooling >= 5.0.0" +] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 120 + +[tool.mypy] +files = ["pyDummy"] +python_version = "3.11" +#ignore_missing_imports = true +strict = true +pretty = true +show_error_context = true +show_error_codes = true +namespace_packages = true +html_report = "report/typing" + +[tool.pytest.ini_options] +# Don't set 'python_classes = *' otherwise, pytest doesn't search for classes +# derived from unittest.Testcase +python_files = "*" +python_functions = "test_*" +filterwarnings = [ + "error::DeprecationWarning", + "error::PendingDeprecationWarning" +] + +[tool.coverage.run] +branch = true +omit = [ + "*site-packages*", + "setup.py", + "tests/*" +] + +[tool.coverage.report] +skip_covered = false +skip_empty = true +exclude_lines = [ + "pragma: no cover", + "raise NotImplementedError" +] +omit = [ + "tests/*" +] + +[tool.coverage.xml] +output = "report/coverage/coverage.xml" + +[tool.coverage.json] +output = "report/coverage/coverage.json" + +[tool.coverage.html] +directory = "report/coverage/html" +title="Code Coverage of pyDummy" diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..136ae707 --- /dev/null +++ b/setup.py @@ -0,0 +1,50 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 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 # +# ==================================================================================================================== # +# +from setuptools import setup + +from pathlib import Path +from pyTooling.Packaging import DescribePythonPackageHostedOnGitHub + +gitHubNamespace = "pyTooling" +packageName = "pyDummy" +packageDirectory = packageName +packageInformationFile = Path(f"{packageDirectory}/__init__.py") + +setup(**DescribePythonPackageHostedOnGitHub( + packageName=packageName, + description="pyDummy is a test package to verify GitHub actions for Python projects.", + gitHubNamespace=gitHubNamespace, + unittestRequirementsFile=Path("tests/requirements.txt"), + sourceFileWithVersion=packageInformationFile, + dataFiles={ + packageName: ["py.typed"] + } +)) diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 00000000..e75ed5ec --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,13 @@ +-r ../requirements.txt + +# Coverage collection +Coverage >= 7.3 + +# Test Runner +pytest >= 7.4.0 +pytest-cov >= 4.1.0 + +# Static Type Checking +mypy >= 1.5.0 +typing_extensions >= 4.7.1 +lxml>=4.9 diff --git a/tests/unit/Dummy.py b/tests/unit/Dummy.py new file mode 100644 index 00000000..2a5c3e64 --- /dev/null +++ b/tests/unit/Dummy.py @@ -0,0 +1,40 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 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 # +# ==================================================================================================================== # +# +from unittest import TestCase + +from pyDummy import Application + + +class Instantiation(TestCase): + def test_Application(self): + app = Application() + + self.assertEqual(1, app.Value)