generated from Justintime50/python-template
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
justfile
70 lines (56 loc) · 2.21 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
PYTHON_BINARY := "python3"
VIRTUAL_ENV := "venv"
VIRTUAL_BIN := VIRTUAL_ENV / "bin"
PROJECT_NAME := "homebrew_releaser"
TEST_DIR := "test"
CURRENT_DIR := `pwd`
# Runs brew audit against the generated formula
audit:
#!/usr/bin/env bash
brew tap-new homebrew-releaser/test --no-git
cp -r test/formulas/* $(brew --repository)/Library/Taps/homebrew-releaser/homebrew-test/Formula
cp -r test/formula_imports $(brew --repository)/Library/Taps/homebrew-releaser/homebrew-test
for file in $(brew --repository)/Library/Taps/homebrew-releaser/homebrew-test/Formula/*
do
brew audit --formula "homebrew-releaser/test/$(basename ${file%.rb})"
done
brew untap homebrew-releaser/test
# Scans the project for security vulnerabilities
bandit:
{{VIRTUAL_BIN}}/bandit -r {{PROJECT_NAME}}/
# Runs the Black Python formatter against the project
black:
{{VIRTUAL_BIN}}/black {{PROJECT_NAME}}/ {{TEST_DIR}}/
# Checks if the project is formatted correctly against the Black rules
black-check:
{{VIRTUAL_BIN}}/black {{PROJECT_NAME}}/ {{TEST_DIR}}/ --check
# Test the project and generate an HTML coverage report
coverage:
{{VIRTUAL_BIN}}/pytest --cov={{PROJECT_NAME}} --cov-branch --cov-report=html --cov-report=lcov --cov-report=term-missing --cov-fail-under=95
# Remove the virtual environment and clear out .pyc files
clean:
rm -rf {{VIRTUAL_ENV}} dist *.egg-info .coverage htmlcov .*cache
find . -name '*.pyc' -delete
# Lints the project
lint: black-check isort-check flake8 mypy bandit
# Fixes lint issues
lint-fix: black isort
# Install the project locally
install:
{{PYTHON_BINARY}} -m venv {{VIRTUAL_ENV}}
{{VIRTUAL_BIN}}/pip install -e ."[dev]"
# Sorts imports throughout the project
isort:
{{VIRTUAL_BIN}}/isort {{PROJECT_NAME}}/ {{TEST_DIR}}/
# Checks that imports throughout the project are sorted correctly
isort-check:
{{VIRTUAL_BIN}}/isort {{PROJECT_NAME}}/ {{TEST_DIR}}/ --check-only
# Run flake8 checks against the project
flake8:
{{VIRTUAL_BIN}}/flake8 {{PROJECT_NAME}}/ {{TEST_DIR}}/
# Run mypy type checking on the project
mypy:
{{VIRTUAL_BIN}}/mypy --install-types --non-interactive {{PROJECT_NAME}}/ {{TEST_DIR}}/
# Test the project
test:
{{VIRTUAL_BIN}}/pytest