generated from nickderobertis/pypi-sphinx-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathjustfile
123 lines (94 loc) · 3.14 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
run := ""
run-lint := "just run lint"
run-test := "just run root"
run-docs := "just run docs"
default:
#!/usr/bin/env bash
exit_code=0
just format || ((exit_code++))
just strip || ((exit_code++))
just lint || ((exit_code++))
just test || ((exit_code++))
exit $exit_code
check:
#!/usr/bin/env bash
exit_code=0
just format-check || ((exit_code++))
just strip-check || ((exit_code++))
just lint || ((exit_code++))
# Use -vv to show full snapshot diff
just test -vv || ((exit_code++))
exit $exit_code
format *FILES='.':
{{run}} isort {{FILES}}
{{run}} black {{FILES}}
format-check *FILES='.':
{{run}} isort --check-only {{FILES}}
{{run}} black --check {{FILES}}
lint:
{{run-lint}} flake8 --count --select=E9,F63,F7,F82 --show-source --statistics
{{run-lint}} flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
{{run-lint}} mypy
strip-opts := "--remove-all-unused-imports --in-place --recursive --exclude=test*,__init__.py,venv*,build*,dist*,node_modules*"
strip *FILES='.':
{{run}} autoflake {{strip-opts}} {{FILES}}
strip-check *FILES='.':
{{run}} autoflake --check {{strip-opts}} {{FILES}}
test *OPTIONS:
{{run-test}} pytest {{OPTIONS}}
test-coverage *OPTIONS:
{{run-test}} pytest --cov=./ --cov-report=xml {{OPTIONS}}
docs-build:
cd docsrc && {{run-docs}} make github
docs-serve:
cd docsrc && {{run-docs}} ./dev-server.sh
docs:
just docs-build
just docs-serve
poetry command target *ARGS:
#!/usr/bin/env bash
cd {{invocation_directory()}}
# Set the directory depending on whether the target is root or not
if [ "{{target}}" = "root" ]; then
DIRECTORY="{{justfile_directory()}}"
else
if [ ! -d "{{justfile_directory()}}/.venvs/{{target}}" ]; then
echo "No such project environment {{target}}"
exit 1;
fi
DIRECTORY="{{justfile_directory()}}/.venvs/{{target}}"
fi
if [ ! -d "${DIRECTORY}/.venv" ]; then
echo "Creating virtual environment for {{target}}"
poetry --directory $DIRECTORY install --all-extras
fi
poetry --directory $DIRECTORY {{command}} {{ARGS}}
run target *ARGS:
@cd {{invocation_directory()}} && just poetry run {{target}} {{ARGS}}
poetry-all +ARGS:
#!/usr/bin/env bash
# Split args into command from the first argument
# and the rest of the arguments, which should be empty if there is only a command
IFS=' ' read -r command args <<< "{{ARGS}}"
for target in root lint docs; do
echo "just poetry $command $target $args"
just poetry $command $target $args
done
sync *TARGET:
#!/usr/bin/env bash
# Handle specific target sync
if [ ! -z "{{TARGET}}" ]; then
just poetry install {{TARGET}} --all-extras --sync
exit 0;
fi
# Sync all
just poetry-all install --all-extras --sync
inspect-build:
rm -rf dist
poetry build
@echo "Contents of sdist:"
@unzip -l dist/*.whl
@echo "Contents of wheel:"
@tar -tvf dist/*.tar.gz
update-test-snapshots *OPTIONS:
{{run-test}} pytest tests/snapshot --snapshot-update {{OPTIONS}}