From 5bf9f3657d698028a6e38f59001f4f74e1e1a863 Mon Sep 17 00:00:00 2001 From: Nathaniel Landau Date: Wed, 30 Aug 2023 08:53:10 -0400 Subject: [PATCH] build: add poethepoet --- .shellcheckrc | 2 +- .yamllint.yml | 1 + README.md | 21 +++++++++++++++++++++ poetry.lock | 45 ++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 22 ++++++++++++++++++++++ 5 files changed, 89 insertions(+), 2 deletions(-) diff --git a/.shellcheckrc b/.shellcheckrc index 24ecef5..474549e 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -5,6 +5,6 @@ external-sources=true shell=bash disable=SC2236 # Allow [ ! -z foo ] instead of suggesting -n -disable=SC2001 # Allow string="stirng" ; echo "$string" | sed -e "s/ir/ri/" +disable=SC2001 # Allow string="string" ; echo "$string" | sed -e "s/ir/ri/" disable=SC2317 # Allow Command appears to be unreachable disable=SC2034 # Allow unused variables diff --git a/.yamllint.yml b/.yamllint.yml index ccd4c85..40a2b53 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -5,6 +5,7 @@ locale: en_US.UTF-8 ignore: | .venv + test/test_helper rules: braces: diff --git a/README.md b/README.md index 36b20a3..b4ecf35 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,27 @@ Functions required to allow the script template and alert functions to be used I compiled these scripting utilities over many years without having an intention to make them public. As a novice programmer, I have Googled, GitHubbed, and StackExchanged a path to solve my own scripting needs. I often lift a function whole-cloth from a GitHub repo don't keep track of its original location. I have done my best within these files to recreate my footsteps and give credit to the original creators of the code when possible. Unfortunately, I fear that I missed as many as I found. My goal in making this repository public is not to take credit for the code written by others. If you recognize something that I didn't credit, please let me know. +## Contributing + +### Setup + +1. Install Python 3.11 and [Poetry](https://python-poetry.org) +2. Clone this repository. `git clone https://github.com/natelandau/shell-scripting-templates.git` +3. Install the Poetry environment with `poetry install`. +4. Activate your Poetry environment with `poetry shell`. +5. Install the pre-commit hooks with `pre-commit install --install-hooks`. + +### Developing + +- Activate your Poetry environment with `poetry shell`. +- This project follows the [Conventional Commits](https://www.conventionalcommits.org/) standard to automate [Semantic Versioning](https://semver.org/) and [Keep A Changelog](https://keepachangelog.com/) with [Commitizen](https://github.com/commitizen-tools/commitizen). + - When you're ready to commit changes run `cz c` +- Run `poe` from within the development environment to print a list of [Poe the Poet](https://github.com/nat-n/poethepoet) tasks available to run on this project. Common commands: + - `poe lint` runs all linters and tests +- Run `poetry add {package}` from within the development environment to install a runtime dependency and add it to `pyproject.toml` and `poetry.lock`. +- Run `poetry remove {package}` from within the development environment to uninstall a runtime dependency and remove it from `pyproject.toml` and `poetry.lock`. +- Run `poetry update` from within the development environment to upgrade all dependencies to the latest versions allowed by `pyproject.toml`. + ## License MIT diff --git a/poetry.lock b/poetry.lock index 2019455..4f5510b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -329,6 +329,18 @@ files = [ {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, ] +[[package]] +name = "pastel" +version = "0.2.1" +description = "Bring colors to your terminal." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "pastel-0.2.1-py2.py3-none-any.whl", hash = "sha256:4349225fcdf6c2bb34d483e523475de5bb04a5c10ef711263452cb37d7dd4364"}, + {file = "pastel-0.2.1.tar.gz", hash = "sha256:e6581ac04e973cac858828c6202c1e1e81fee1dc7de7683f3e1ffe0bfd8a573d"}, +] + [[package]] name = "pathspec" version = "0.11.2" @@ -357,6 +369,25 @@ files = [ docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] +[[package]] +name = "poethepoet" +version = "0.22.0" +description = "A task runner that works well with poetry." +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "poethepoet-0.22.0-py3-none-any.whl", hash = "sha256:f654e52c19b7c689d5293ab6a065787b21f125884c0b367650292df4f3cb508c"}, + {file = "poethepoet-0.22.0.tar.gz", hash = "sha256:659d7678fd8b349bd40941e3de7d6d386171dab3e7c8babcdcd8ead288c9ea47"}, +] + +[package.dependencies] +pastel = ">=0.2.1,<0.3.0" +tomli = ">=1.2.2" + +[package.extras] +poetry-plugin = ["poetry (>=1.0,<2.0)"] + [[package]] name = "pre-commit" version = "3.3.3" @@ -491,6 +522,18 @@ files = [ [package.extras] tests = ["pytest", "pytest-cov"] +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + [[package]] name = "tomlkit" version = "0.12.1" @@ -594,4 +637,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "54e105b0b6c5998507ab75393f875db4856f3ceb20820c8cf298640d76058b1a" +content-hash = "ef6f88c4eb4131c2bc51eee77b4d0d10fc0a806fc4d4cb172af7b8b3dddcf3cb" diff --git a/pyproject.toml b/pyproject.toml index 8aa6467..881e72c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,10 +5,12 @@ license = "MIT" name = "shell-scripting-templates" readme = "README.md" + repository = "https://github.com/natelandau/shell-scripting-templates" version = "0.1.0" [tool.poetry.dependencies] commitizen = "^3.7.0" + poethepoet = "^0.22.0" pre-commit = "^3.3.3" python = "^3.11" typos = "^1.16.8" @@ -24,3 +26,23 @@ update_changelog_on_bump = true version = "0.1.0" version_files = ["pyproject.toml:version"] + +[tool.poe.tasks] + + [tool.poe.tasks.lint] + help = "Lint this package" + + [[tool.poe.tasks.lint.sequence]] + shell = "poetry check" + + [[tool.poe.tasks.lint.sequence]] + shell = "typos" + + [[tool.poe.tasks.lint.sequence]] + shell = "yamllint ." + + # [[tool.poe.tasks.lint.sequence]] + # shell = "shellcheck bin-*/*" + + [[tool.poe.tasks.lint.sequence]] + shell = "pre-commit run --all-files"