+++ /dev/null
-set PY_SYS_INTERPRETER=python3
---
-name: CI
+name: test-linux
"on":
push: {}
jobs:
- test:
+ test-linux:
runs-on: ubuntu-latest
+
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/cache@v3
with:
path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
pip install testresources==2.0.1
make _deps
+ # TODO: Tests for: python-argcomplete (tab-completion)
+ - name: Test
+ run: |
+ export NUTRA_HOME=$(pwd)/tests/.nutra.test
+ make _test
+
- name: Lint
run: make _lint
- - name: Test
- run: make _test
+ - name: Install
+ run: make install
+
+ - name: Basic Tests / CLI / Integration
+ run: |
+ n -v
+ nutra -d init -y
+ nutra --no-pager nt
+ nutra --no-pager sort -c 789
+ nutra --no-pager search ultraviolet mushrooms
+ nutra --no-pager anl 9050
+ nutra --no-pager recipe
+ nutra day tests/resources/day/human-test.csv
--- /dev/null
+---
+name: test-win32
+"on":
+ push: {}
+
+jobs:
+ test-win32:
+ runs-on: windows-latest
+
+ steps:
+ - name: Configure Line Endings / git / LF
+ run: |
+ git config --global core.autocrlf input
+ git config --global core.eol lf
+
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ submodules: recursive
+
+ - name: Reload Cache / pip
+ uses: actions/cache@v3
+ with:
+ path: ~\AppData\Local\pip\Cache
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Install requirements
+ run: |
+ make _deps
+
+ # TODO: Tests for: python-argcomplete (tab-completion)
+ - name: Test
+ run: |
+ $curDir = (Get-Location).toString()
+ $Env:NUTRA_HOME = $curDir + '/tests/.nutra.test'
+ make _test
+
+ - name: Lint
+ run: make _lint
+
+ - name: Install
+ run: make install
+
+ - name: Basic Tests / CLI / Integration
+ run: |
+ n -v
+ nutra -d init -y
+ nutra --no-pager nt
+ nutra --no-pager sort -c 789
+ nutra --no-pager search ultraviolet mushrooms
+ nutra --no-pager anl 9050
+ nutra --no-pager recipe
+ nutra day tests/resources/day/human-test.csv
~~~~~
- Basic functionality of ``import`` and ``export`` sub-commands
+- Automated CI/CD integration tests for ``Windows`` platform
include ntclient/ntsqlite/sql/*.sql
include ntclient/ntsqlite/sql/data/*.csv
-include ntclient/ntsqlite/sql/upgrade_scripts/*.sql
global-exclude nt.sqlite3
# Install requirements
# ---------------------------------------
-PY_SYS_INTERPRETER ?= /usr/bin/python3
+PY_SYS_INTERPRETER ?=
+ifeq ($(PY_SYS_INTERPRETER),)
+ ifeq ($(OS),Windows_NT)
+ PY_SYS_INTERPRETER += python3
+ else
+ PY_SYS_INTERPRETER += /usr/bin/python3
+ endif
+endif
+
PY_VIRTUAL_INTERPRETER ?= python
PIP ?= $(PY_VIRTUAL_INTERPRETER) -m pip
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://badgen.net/pypi/v/nutra
:target: https://pypi.org/project/nutra/
:alt: Latest version unknown
-.. image:: https://github.com/nutratech/cli/actions/workflows/test.yml/badge.svg
- :target: https://github.com/nutratech/cli/actions/workflows/test.yml
- :alt: Build status 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
# Package info
__title__ = "nutra"
-__version__ = "0.2.4"
+__version__ = "0.2.5.dev0"
__author__ = "Shane Jaroch"
__email__ = "chown_tee@proton.me"
__license__ = "GPL v3"
# Global variables
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
-NUTRA_DIR = os.getenv("NUTRA_HOME", os.path.join(os.path.expanduser("~"), ".nutra"))
+NUTRA_HOME = os.getenv("NUTRA_HOME", os.path.join(os.path.expanduser("~"), ".nutra"))
USDA_DB_NAME = "usda.sqlite"
# NOTE: NT_DB_NAME = "nt.sqlite3" is defined in ntclient.ntsqlite.sql
DEBUG = False
PAGING = True
NTSQLITE_BUILDPATH = os.path.join(ROOT_DIR, "ntsqlite", "sql", NT_DB_NAME)
-NTSQLITE_DESTINATION = os.path.join(NUTRA_DIR, NT_DB_NAME)
+NTSQLITE_DESTINATION = os.path.join(NUTRA_HOME, NT_DB_NAME)
+print(NTSQLITE_BUILDPATH)
+print(NTSQLITE_DESTINATION)
# Check Python version
PY_MIN_VER = (3, 4, 0)
import json
import os
-from ntclient import NUTRA_DIR
+from ntclient import NUTRA_HOME
# TODO: init, handle when it doesn't exist yet
# TODO: prompt to create profile if copying default `prefs.json` with PROFILE_ID: -1
# (non-existent)
-PREFS_FILE = os.path.join(NUTRA_DIR, "prefs.json")
+PREFS_FILE = os.path.join(NUTRA_HOME, "prefs.json")
PREFS = {}
PROFILE_ID = None
NT_DB_NAME,
NTSQLITE_BUILDPATH,
NTSQLITE_DESTINATION,
- NUTRA_DIR,
+ NUTRA_HOME,
__db_target_nt__,
)
from ntclient.persistence.sql import _sql, _sql_headers, version
def nt_sqlite_connect(version_check=True) -> sqlite3.Connection:
"""Connects to the nt.sqlite3 file, or throws an exception"""
- db_path = os.path.join(NUTRA_DIR, NT_DB_NAME)
+ db_path = os.path.join(NUTRA_HOME, NT_DB_NAME)
if os.path.isfile(db_path):
con = sqlite3.connect(db_path)
con.row_factory = sqlite3.Row
import tarfile
import urllib.request
-from ntclient import NUTRA_DIR, USDA_DB_NAME, __db_target_usda__
+from ntclient import NUTRA_HOME, USDA_DB_NAME, __db_target_usda__
from ntclient.persistence.sql import _sql, _sql_headers, version
from ntclient.utils.exceptions import SqlConnectError, SqlInvalidVersionError
if yes or input_agree().lower() == "y":
# TODO: save with version in filename? Don't re-download tarball, just extract?
- save_path = os.path.join(NUTRA_DIR, "%s.tar.xz" % USDA_DB_NAME)
+ save_path = os.path.join(NUTRA_HOME, "%s.tar.xz" % USDA_DB_NAME)
# Download usda.sqlite3.tar.xz
print("curl -L %s -o %s.tar.xz" % (url, USDA_DB_NAME))
# Extract the archive
with tarfile.open(save_path, mode="r:xz") as usda_sqlite_file:
print("\ntar xvf %s.tar.xz" % USDA_DB_NAME)
- usda_sqlite_file.extractall(NUTRA_DIR)
+ usda_sqlite_file.extractall(NUTRA_HOME)
print("==> done downloading %s" % USDA_DB_NAME)
)
)
- if USDA_DB_NAME not in os.listdir(NUTRA_DIR):
+ if USDA_DB_NAME not in os.listdir(NUTRA_HOME):
print("INFO: usda.sqlite3 doesn't exist, is this a fresh install?")
download_extract_usda()
elif usda_ver() != __db_target_usda__:
"""Connects to the usda.sqlite3 file, or throws an exception"""
# TODO: support as customizable env var ?
- db_path = os.path.join(NUTRA_DIR, USDA_DB_NAME)
+ db_path = os.path.join(NUTRA_HOME, USDA_DB_NAME)
if os.path.isfile(db_path):
con = sqlite3.connect(db_path)
# con.row_factory = sqlite3.Row # see: https://chrisostrouchov.com/post/python_sqlite/
"""Services module, currently only home to SQL/persistence init method"""
import os
-from ntclient import NUTRA_DIR
+from ntclient import NUTRA_HOME
from ntclient.ntsqlite.sql import build_ntsqlite
from ntclient.persistence.sql.nt import nt_init
from ntclient.persistence.sql.usda import usda_init
4. prefs.json
"""
print("Nutra directory ", end="")
- if not os.path.isdir(NUTRA_DIR):
- os.makedirs(NUTRA_DIR, 0o755)
+ if not os.path.isdir(NUTRA_HOME):
+ os.makedirs(NUTRA_HOME, 0o755)
print("..DONE!")
# TODO: print off checks, return False if failed
from ntclient import (
NTSQLITE_BUILDPATH,
- NUTRA_DIR,
+ NUTRA_HOME,
USDA_DB_NAME,
__db_target_nt__,
__db_target_usda__,
from ntclient.utils.exceptions import SqlInvalidVersionError
TEST_HOME = os.path.dirname(os.path.abspath(__file__))
-os.environ["NUTRA_HOME"] = os.path.join(TEST_HOME, ".nutra.test")
+# NOTE: this doesn't work currently, b/c it's already read up (in imports above)
+# We're just setting it on the shell, as an env var
+# os.environ["NUTRA_HOME"] = os.path.join(TEST_HOME, ".nutra.test")
# TODO: integration tests.. create user, recipe, log.. analyze & compare
arg_parser = build_argparser()
# remove whole `.nutra` in a special test?
try:
# TODO: export USDA_DB_PATH at package level, don't pepper os.path.join() throughout code?
- usda_path = os.path.join(NUTRA_DIR, USDA_DB_NAME)
+ usda_path = os.path.join(NUTRA_HOME, USDA_DB_NAME)
os.remove(usda_path)
except (FileNotFoundError, PermissionError) as err:
# TODO: resolve PermissionError on Windows