-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
91 lines (78 loc) · 2.39 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# list all available commands
default:
just --list
# clean all build, python, and lint files
clean:
rm -fr build
rm -fr docs/_build
rm -fr dist
rm -fr .eggs
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
rm -fr .coverage
rm -fr coverage.xml
rm -fr htmlcov
rm -fr .pytest_cache
rm -fr .mypy_cache
# install with all deps
install:
pip install -e '.[lint,test,docs,dev]'
# lint, format, and check all files
lint:
pre-commit run --all-files
# generate tests
default_tests_file := justfile_directory() / "transcript_file_format" / "tests" / "test_fuzz_transcript.py"
generate-tests store_file=default_tests_file:
hypothesis \
write \
--annotate \
--roundtrip \
transcript_file_format.to_json \
transcript_file_format.from_json \
--style pytest \
--except IsADirectoryError \
--except FileNotFoundError \
--except TypeError \
transcript_file_format.Transcript \
> {{ store_file }}
# run tests
test:
pytest --cov-report xml --cov-report html --cov=transcript_file_format transcript_file_format/tests
# run lint and then run tests
build:
just lint
just test
# generate Sphinx HTML documentation
generate-docs:
rm -f docs/transcript_file_format*.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs transcript_file_format **/tests
python -msphinx "docs" "docs/_build"
# Generate project URI for browser opening
# We replace here to handle windows paths
# Windows paths are normally `\` separated but even in the browser they use `/`
# https://stackoverflow.com/a/61991869
project_uri := if "os_family()" == "unix" {
justfile_directory()
} else {
replace(justfile_directory(), "\\", "/")
}
# generate Sphinx HTML documentation and serve to browser
serve-docs:
just generate-docs
python -mwebbrowser -t "file://{{project_uri}}/docs/_build/index.html"
# tag a new version
tag-for-release version:
git tag -a "{{version}}" -m "{{version}}"
echo "Tagged: $(git tag --sort=-version:refname| head -n 1)"
# release a new version
release:
git push --follow-tags
# update this repo using latest cookiecutter-py-package
update-from-cookiecutter:
pip install cookiecutter
cookiecutter gh:evamaxfield/cookiecutter-py-package --config-file .cookiecutter.yaml --no-input --overwrite-if-exists --output-dir ..