Package: incolumepy.gwa
incolumepy.gwaProspection GitHub Workflows ActionsContains:poetrypytestcoveragePython multiversions (pyenv)toxblackisortflake8pylintpydocstylemypysemverStart ProjectCreate a github project on github.com;Clone the project, on local host;Create the branch dev and branches of control when necessary:$gitbrdev
$gitco-bfeature#1dev
$gitco-bfeature#2dev
$gitco-bbug#2devConfigure project structure:Set Editor configuration:$curlhttps://pastebin.com/raw/TrDhuvFZ-o.editorconfig# or$curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.editorconfig-o.editorconfigUpdate gitignore:$curlhttps://pastebin.com/raw/C910Dqze-o.gitignore#or$curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.gitignore-o.gitignoreCommit changesConfigure poetry:Init poetry$poetryinit# response that needAdding package path in configuration:[tool.poetry]...packages=[{include='incolumepy/gwa',from=''},]Define Python version (3.6.8+):Change..[tool.poetry.dependencies]python="~3.10"To..[tool.poetry.dependencies]python=">=3.6.8,<4"Commit changesConfigure unit tests with pytest:Install pytest$poetryadd-Dpytest## adding pytest$poetryadd-Dpytest-cov## adding pytest-covCreate tests structure$cdincolumepy.gwa;# home_project$mkdirtests# create directory$>conftest.py# create file$>__init__.py# create fileAdd test environment$gitadd-fpoetry.lockpyproject.tomltests/Commit changesLinters and CheckersAdding lint/control tools$poetryadd-Dblackflake8isortmypypydocstylepylintpytest-covtox[tomli]$gitci-m"Adding tox and lint tools"poetry.lockpyproject.tomlConfigure code coverageEditpyproject.toml, add on end file.$...[tool.pytest.ini_options]addopts="--cov=incolumepy.gwa"testpaths=["tests",]Configure pylint toolEditpyproject.toml, add on end file....[tool.pylint.format]# Maximum number of characters on a single line.max-line-length=160[tool.pylint.basic]# Allow shorter and longer variable names than the default.argument-rgx="[a-z_][a-z0-9_]*$"attr-rgx="[a-z_][a-z0-9_]*$"variable-rgx="[a-z_][a-z0-9_]*$"# Ensure that orjson is analysed as a C extension by pylint.extension-pkg-whitelist="orjson"[tool.pylint.messages_control]disable=[# Disable too many and too few checks."too-many-ancestors","too-many-arguments","too-many-boolean-expressions","too-many-branches","too-many-function-args","too-many-instance-attributes","too-many-lines","too-many-locals","too-many-nested-blocks","too-many-public-methods","too-many-return-statements","too-many-statements","too-few-public-methods",# Similar lines in files (often the case in tests)."duplicate-code",# Many functions (e.g. callbacks) will naturally have unused arguments."unused-argument",# Disable checking that method could be a function in classes (often used for organisation)."no-self-use",# Disable failure for TODO items in the codebase (code will always have TODOs)."fixme",# Disable docstrings checks as we don't require excessive documentation."missing-docstring","no-member","unspecified-encoding",]Commit$gitci-m"Configure pylint tool"pyproject.tomlConfigure mypy toolEditpyproject.toml, add on end file....[tool.mypy]mypy_path="incolumepy"check_untyped_defs=truedisallow_any_generics=trueignore_missing_imports=trueno_implicit_optional=trueshow_error_codes=truestrict_equality=truewarn_redundant_casts=truewarn_return_any=truewarn_unreachable=truewarn_unused_configs=trueno_implicit_reexport=trueCommit$gitci-m"Configure mypy tool"pyproject.tomlConfigure isort toolEditpyproject.toml, add on end file....[tool.isort]multi_line_output=3line_length=160include_trailing_comma=trueCommit$gitci-m"Configure isort tool"pyproject.tomlConfigure flake8 toolEditpyproject.toml, add on end file....[flake8]max-line-length=160Commit$gitci-m"Configure flake8 tool"pyproject.tomlConfigure black tool:Editpyproject.toml, add on end file....[tool.black]line_length=160Commit$gitci-m"Configure black tool"pyproject.tomlConfigure tox tool:Editpyproject.toml, add on end file.[tool.tox]legacy_tox_ini="""[tox]minversion = 3.3.0isolated_build = Trueenvlist =blackflake8isortmypypydocstylepylintpy{36,37,38,39,310};[tox:.package];basepython = python3[testenv]whitelist_externals = poetryskip_install = truecommands =poetry env use {envpython}poetry install -vv --no-rootpoetry run pytest {posargs} tests/[testenv:flake8]deps = flake8commands = flake8 --config pyproject.toml incolumepy/ tests/[testenv:mypy]deps =mypytypes-tomlcommands = mypy incolumepy/[testenv:pydocstyle]commands = poetry run pydocstyle incolumepy/ tests/[testenv:isort]commands = poetry run isort --check --atomic --py all incolumepy/ tests/[testenv:pylint]commands = poetry run pylint incolumepy/ tests/[testenv:black]commands = poetry run black --check incolumepy/ tests/"""Commit$gitci-m"Configure tox tool"pyproject.tomlTestting lint configurateTest pydocstyle:$pydocstyleincolumepy/tests/Test pylint$pylintincolumepy/tests/Test mypy$mypyincolumepy/tests/Test isort$isort--checkincolumepy/tests/Test flake8$flake8--configpyproject.tomlincolumepy/tests/Test black$black--checkincolumepy/tests/Testting tox configurateText tox$toxControl version with poetryUnlike bumpversion, poetry changes the version of the main file only.
To work around this situation and update the version of pyproject.toml,init.py and version.txt, we will do the following procedure.$cat>incolumepy/gwa/__init__.py<< eofimport tomlfrom pathlib import Path__root__ = Path(__file__).parents[0]version_file = __root__.joinpath('version.txt')version_file.write_text(f"{toml.load(Path(__file__).parents[2].joinpath('pyproject.toml'))['tool']['poetry']['version']}\n")__version__ = version_file.read_text().strip()eof$v=`poetryversionprerelease`;pytesttests/&&gitci-m"$v"pyproject.toml$(find-name"version.txt")#sem tag$s=`poetryversionpatch`;pytesttests/&&gitci-m"`echo$s`"pyproject.toml`find-name"version.txt"`;gittag-f`poetryversion-s`-m"$(echo$s)"#com tagFacility with makeUse make to easy various commands.$curlhttps://pastebin.com/raw/eTHpL70G-oMakefile# or$curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/Makefile-oMakefile# last versionMakefile help$makehelpNew prerelease with Makefile$gitcodev
$gitmerge--no-ff[branch]--autostash
$makeprereleaseNew release with Makefile$gitcodev
$makereleaseChecking lint$makelintRun tox over make$maketoxGithub Workflows Actions (GWA)First create the directory for GWA:mkdir-pv.github/workflowsThis Models:GitHub WorkFlow with tags Running tox; Build pack; Create release; publish TestPyPI and PyPIcurlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.github/workflows/gwa-flow.yml-o.github/workflows/gwa-flow.ymlRun tox and  generate coverage report:curlhttps://raw.githubuserconcurlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.github/workflows/tests_ci_cd.yaml-o.github/workflows/tests_ci_cd.ymlPublish manualy releases/prereleases into test.pypi.org with poetry:curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.github/workflows/poetry-testpypi-manual-publish.yml-o.github/workflows/poetry-testpypi-manual-publish.ymlPublish automatically releases into pypi.org and test.pypi.org with poetry, after pass on tests from tests_ci_cd:curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.github/workflows/poetry-mine-publish-automatically.yml-o.github/workflows/poetry-mine-publish-automatically.ymlPublish automatically releases into pypi.org only, after pass on tests from tests_ci_cd:curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.github/workflows/poetry-mine-pypi-autopublish.yml-o.github/workflows/poetry-mine-pypi-autopublish.ymlPublish automatically releases into pypi.org and test.pypi.org without poetry, after pass on tests from tests_ci_cd:curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.github/workflows/publish-automatically.yml-o.github/workflows/publish-automatically.ymlPublish automatically releases into pypi.org and test.pypi.org with multiprocess poetry, after pass on tests from tests_ci_cd:curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.github/workflows/poetry-multiprocess.yml-o.github/workflows/poetry-multiprocess.ymlGit Hookscreate .git-hooks folder into your project root directory, at the same level you already have .git folder;mkdir.git-hookscreate hook files into this folder: pre-commit, prepare-commit-msg and all hooks (these files don't have an extension);put the correct code into each file (I will add them below these steps);curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.git-hooks/pre-commit-o.git-hooks/pre-commit
curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.git-hooks/prepare-commit-msg-o.git-hooks/prepare-commit-msg
curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.git-hooks/commit-msg-o.git-hooks/commit-msg
curlhttps://raw.githubusercontent.com/incolumepy-prospections/incolumepy.gwa/main/.git-hooks/pre-push-o.git-hooks/pre-pushchange to execute mode;chmod+x.git-hooks/*run this command in your command line, into your main folder of your project (one level up from .git-hooks):gitconfigcore.hooksPath.git-hooks;READY;