From: Shane Jaroch Date: Wed, 20 Jul 2022 17:42:40 +0000 (-0400) Subject: separate lint workflow, update readme (#10) X-Git-Tag: v0.2.5~2 X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=018f59399ce7bad21034a2be65a779ab0b2364af;p=nutratech%2Fcli.git separate lint workflow, update readme (#10) --- diff --git a/.editorconfig b/.editorconfig index 3f9ce44..149ee88 100644 --- a/.editorconfig +++ b/.editorconfig @@ -30,6 +30,7 @@ trim_trailing_whitespace = false [*.rst] +indent_size = 2 max_line_length = 79 diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index b0c8879..b33b196 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -1,5 +1,6 @@ --- name: coveralls + "on": push: {} diff --git a/.github/workflows/coveralls.yml b/.github/workflows/lint.yml similarity index 52% copy from .github/workflows/coveralls.yml copy to .github/workflows/lint.yml index b0c8879..ffff075 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,11 @@ --- -name: coveralls +name: lint + "on": push: {} jobs: - cov-submit: + lint: runs-on: ubuntu-latest steps: @@ -22,20 +23,12 @@ jobs: ${{ runner.os }}-pip- - name: Install requirements - # NOTE: container lacks OS dist for testresources/launchpadlib run: | - pip install coveralls==3.3.1 - pip install testresources==2.0.1 pip install -r requirements.txt - pip install -r requirements-test.txt + pip install -r requirements-lint.txt - # TODO: Tests for: python-argcomplete (tab-completion) - - name: Test - run: | - export NUTRA_HOME=$(pwd)/tests/.nutra.test - make _test + # NOTE: pytest is needed to lint the folder: "tests/" + pip install -r requirements-test.txt - - name: Submit coverage report / coveralls - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: coveralls --service=github + - name: Lint + run: make _lint diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index a765426..7c970d5 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -1,5 +1,6 @@ --- name: test-linux + "on": push: {} @@ -30,17 +31,13 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - - name: Install requirements - # NOTE: container lacks OS dist for testresources/launchpadlib + # NOTE: These are the last supported versions on Python 3.4 + - name: Install requirements (Python 3.4) + if: matrix.python-version == '3.4.10' run: | - # NOTE: This is the latest version on GitHub for Python 3.4 - if [[ "$(python --version)" =~ "3.4." ]]; then - pip install colorama==0.4.1; - fi - - pip install -r requirements.txt + pip install colorama==0.4.1 - - name: Install + - name: Install CLI env: PY_SYS_INTERPRETER: python3 run: make install diff --git a/README.rst b/README.rst index ae9f54b..cca93f9 100644 --- a/README.rst +++ b/README.rst @@ -2,41 +2,57 @@ nutratracker ************** -.. image:: https://github.com/nutratech/cli/actions/workflows/test-linux.yml/badge.svg - :target: https://github.com/nutratech/cli/actions/workflows/test-linux.yml - :alt: Build status unknown (Linux) -.. image:: https://github.com/nutratech/cli/actions/workflows/test-win32.yml/badge.svg - :target: https://github.com/nutratech/cli/actions/workflows/test-win32.yml - :alt: Build status unknown (Windows) - -.. image:: https://coveralls.io/repos/github/nutratech/cli/badge.svg?branch=master - :target: https://coveralls.io/github/nutratech/cli?branch=master - :alt: Coverage unknown - -.. image:: https://badgen.net/pypi/v/nutra - :target: https://pypi.org/project/nutra/ - :alt: Latest version unknown - -.. image:: https://pepy.tech/badge/nutra/month - :target: https://pepy.tech/project/nutra - :alt: Monthly downloads unknown - -.. image:: https://img.shields.io/pypi/pyversions/nutra.svg - :alt: Python3 (3.4 - 3.10) - -.. image:: https://badgen.net/badge/code%20style/black/000 - :target: https://github.com/ambv/black - :alt: Code style: black - -.. image:: https://badgen.net/pypi/license/nutra - :target: https://www.gnu.org/licenses/gpl-3.0.en.html - :alt: License GPL-3 - -Extensible command-line tools for nutrient analysis. +.. list-table:: + :widths: 15 25 20 + :header-rows: 1 + + * - + - + - + * - Test / Linux + - .. image:: https://github.com/nutratech/cli/actions/workflows/test-linux.yml/badge.svg + :target: https://github.com/nutratech/cli/actions/workflows/test-linux.yml + :alt: Test status unknown (Linux) + - + * - Test / Windows + - .. image:: https://github.com/nutratech/cli/actions/workflows/test-win32.yml/badge.svg + :target: https://github.com/nutratech/cli/actions/workflows/test-win32.yml + :alt: Test status unknown (Windows) + - + * - Other checks + - .. image:: https://coveralls.io/repos/github/nutratech/cli/badge.svg?branch=master + :target: https://coveralls.io/github/nutratech/cli?branch=master + :alt: Coverage unknown + - .. image:: https://github.com/nutratech/cli/actions/workflows/lint.yml/badge.svg + :target: https://github.com/nutratech/cli/actions/workflows/lint.yml + :alt: Lint status unknown + * - PyPI Release + - .. image:: https://badgen.net/pypi/v/nutra + :target: https://pypi.org/project/nutra/ + :alt: Latest version unknown + - .. image:: https://pepy.tech/badge/nutra/month + :target: https://pepy.tech/project/nutra + :alt: Monthly downloads unknown + * - Supported Runtime + - .. image:: https://img.shields.io/pypi/pyversions/nutra.svg + :alt: Python3 (3.4 - 3.10) + - + * - Code Style + - .. image:: https://badgen.net/badge/code%20style/black/000 + :target: https://github.com/ambv/black + :alt: Code style: black + - + * - License + - .. image:: https://badgen.net/pypi/license/nutra + :target: https://www.gnu.org/licenses/gpl-3.0.en.html + :alt: License GPL-3 + - + +Command line tools for interacting with government food databases. *Requires:* -- Python 3.4.0 or later (lzma, ssl & sqlite3 modules) [Win XP / Ubuntu 16.04]. +- Python 3.4.0 or later (lzma, ssl & sqlite3 modules) [Win XP / Ubuntu 14.04]. - Packages: see ``setup.py``, and ``requirements.txt`` files. - Internet connection, to download food database & package dependencies. @@ -44,6 +60,12 @@ See nt database: https://github.com/nutratech/nt-sqlite See usda database: https://github.com/nutratech/usda-sqlite +Plugin Development +================== + +We're looking to start developing plugins or data modifications sets that +can be imported and built on the base installation, which remains pure. + Notes ===== @@ -58,15 +80,15 @@ Windows users may not be able to install ``python-Levenshtein``. Mac and Linux developers will do well to install ``direnv``. -Main program works 100%, but test and lint may not on older operating -systems (Ubuntu 16.04, Windows XP). +Main program works 100%, but ``test`` and ``lint`` may break on older operating +systems (Ubuntu 14.04, Windows XP). Install PyPi release (from pip) =============================== .. code-block:: bash - pip install nutra + pip install nutra (**Specify:** flag ``-U`` to upgrade, or ``--pre`` for development releases) @@ -76,24 +98,24 @@ Clone down, initialize ``nt-sqlite`` submodule, and install requirements: .. code-block:: bash - git clone https://github.com/nutratech/cli.git - cd cli - make init - # source .venv/bin/activate # uncomment if NOT using direnv - make deps + git clone https://github.com/nutratech/cli.git + cd cli + make init + # source .venv/bin/activate # uncomment if NOT using direnv + make deps - ./nutra -h + ./nutra -h Initialize the DBs (nt and usda). .. code-block:: bash - # source .venv/bin/activate # uncomment if NOT using direnv - ./nutra init + # source .venv/bin/activate # uncomment if NOT using direnv + ./nutra init - # Or install and run as package script - make install - nutra init + # Or install and run as package script + make install + nutra init If installed (or inside ``cli``) folder, the program can also run with ``python -m ntclient`` @@ -103,9 +125,9 @@ Building the PyPi release .. code-block:: bash - # source .venv/bin/activate # uncomment if NOT using direnv - make build # python3 setup.py --quiet sdist - twine upload dist/nutra-X.X.X.tar.gz + # source .venv/bin/activate # uncomment if NOT using direnv + make build # python3 setup.py --quiet sdist + twine upload dist/nutra-X.X.X.tar.gz Linting & Tests =============== @@ -114,8 +136,8 @@ Install the dependencies (``make deps``) and then: .. code-block:: bash - # source .venv/bin/activate # uncomment if NOT using direnv - make format lint test + # source .venv/bin/activate # uncomment if NOT using direnv + make format lint test ArgComplete (tab completion / autocomplete) =========================================== @@ -130,7 +152,7 @@ specifics on using other shells, e.g. ``zsh``, ``fish``, or ``tsh``. .. code-block:: bash - activate-global-python-argcomplete + activate-global-python-argcomplete Then you can press tab to fill in or complete subcommands and to list argument flags. @@ -144,19 +166,19 @@ I've run the command to seed the autocomplete script. .. code-block:: bash - mkdir -p $HOME/.bash_completion.d - activate-global-python-argcomplete --dest=$HOME/.bash_completion.d + mkdir -p $HOME/.bash_completion.d + activate-global-python-argcomplete --dest=$HOME/.bash_completion.d And my ``~/.bashrc`` file looks like this. .. code-block:: bash - export ARGCOMPLETE_USE_TEMPFILES=1 + export ARGCOMPLETE_USE_TEMPFILES=1 - # python bash completion - if [ -f ~/.bash_completion.d/python-argcomplete ]; then - source ~/.bash_completion.d/python-argcomplete - fi + # python bash completion + if [ -f ~/.bash_completion.d/python-argcomplete ]; then + source ~/.bash_completion.d/python-argcomplete + fi **NOTE:** This is a work in progress, we are adding more autocomplete functions. @@ -189,21 +211,21 @@ Commands :: - usage: nutra [-h] [-v] [-d] [--no-pager] - {init,nt,search,sort,anl,day,recipe,bio} ... - - optional arguments: - -h, --help show this help message and exit - -v, --version show program's version number and exit - -d, --debug enable detailed error messages - --no-pager disable paging (print full output) - - nutra subcommands: - {init,nt,search,sort,anl,day,recipe,bio} - init setup profiles, USDA and NT database - nt list out nutrients and their info - search search foods by name, list overview info - sort sort foods by nutrient ID - anl analyze food(s) - day analyze a DAY.csv file, RDAs optional - recipe list and analyze recipes + usage: nutra [-h] [-v] [-d] [--no-pager] + {init,nt,search,sort,anl,day,recipe,bio} ... + + optional arguments: + -h, --help show this help message and exit + -v, --version show program's version number and exit + -d, --debug enable detailed error messages + --no-pager disable paging (print full output) + + nutra subcommands: + {init,nt,search,sort,anl,day,recipe,bio} + init setup profiles, USDA and NT database + nt list out nutrients and their info + search search foods by name, list overview info + sort sort foods by nutrient ID + anl analyze food(s) + day analyze a DAY.csv file, RDAs optional + recipe list and analyze recipes