Skip to content

Commit

Permalink
just
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrauth committed Jul 22, 2024
1 parent 93b9a62 commit 6f3cf81
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 35 deletions.
79 changes: 79 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
PIP := "./venv/bin/python -m pip --require-venv"

# Display recipe listing
help:
@just --list

# Update all dev dependencies
update:
echo Installing when ...
{{PIP}} install -U -e .

echo Installing dev dependencies ...
{{PIP}} install -U pytest coverage pytest-cov tox ipython flake8 black twine bump isort

# Create a virtual environment if needed
venv: && update
#!/usr/bin/env bash
if [ ! -d ./venv ]; then
echo Creating virtual env in dir ./venv ...
python3 -m venv venv
fi
# Run test suite
test:
./venv/bin/pytest -vv -s

# Remove the virtual env dir
rmvenv:
#!/usr/bin/env bash
if [ -d ./venv ]; then
if [ -s $VIRTUAL_ENV ]; then
echo You must now run `deactivate` manually
fi
rm -rf ./venv
fi
# Run coverage report from test suite
cov:
./venv/bin/pytest -vv -s --cov-config setup.cfg --cov-report html --cov-report term --cov=when
echo HTML coverage report: ./build/coverage/index.html
open ./build/coverage/index.html

# Remove all *.pyc files and __pycache__ dirs
clean:
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete

# Remove all test and coverage artifacts
clean-test:
rm -rf .coverage
rm -rf ./pytest_cache ./.tox

# Remove all build and dist artifacts
clean-build:
rm -rf ./src/when.egg-info ./dist ./build

# Clean all build, test, and compile artifacts and remove venv
[confirm('Remove all build, test, coverage, and compiled artifacts and delete venv?')]
purge: clean clean-test rmvenv clean-build
echo All artifacts purged

# Run linter and code formatter tools
lint:
./venv/bin/flake8 src/when tests
./venv/bin/black --check --diff -l 100 src/when tests setup.py

# Show current version
version:
#!/usr/bin/env python3
local_ctx = {}
with open("src/when/__init__.py") as fp:
exec(fp.read(), {}, local_ctx)
print(f"Current version: {local_ctx['VERSION']}")
# Launch sqlite data browser (macOS only)
[macos]
db:
open ./src/when/db/when.db

35 changes: 0 additions & 35 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,6 @@ commands =
deps =
pytest

[testenv:cov]
basepython = python3.10
allowlist_externals =
echo
commands =
pytest -v --cov-config setup.cfg --cov-report html --cov-report term --cov=when
echo HTML coverage report: {toxinidir}/build/coverage/index.html
deps =
pytest
coverage
pytest-cov

[testenv:clean]
allowlist_externals =
find
rm
commands =
find {toxinidir} -type f -name "*.pyc" -delete
find {toxinidir} -type d -name "__pycache__" -delete
rm -f {toxworkdir} {toxinidir}/.pytest_cache {toxinidir}/build {toxinidir}/dist
rm -f {toxinidir}/when.egg-info
rm -f .coverage

[testenv:lint]
description = Run PEP8 flake8 against the src/when/ package directory and tests/
skipsdist = true
skip_install = true
basepython = python3.10
deps =
flake8
black
commands =
flake8 src/when tests
black --check --diff -l 100 src/when tests

[gh-actions]
python =
3.10: py310
Expand Down

0 comments on commit 6f3cf81

Please sign in to comment.