-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·108 lines (85 loc) · 2.47 KB
/
run
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
#!/usr/bin/env bash
set -o errexit
set -o pipefail
DC="${DC:-exec}"
# If we're running in CI we need to disable TTY allocation for docker compose
# commands that enable it by default, such as exec and run.
TTY=""
if [[ ! -t 1 ]]; then
TTY="-T"
fi
# -----------------------------------------------------------------------------
# Helper functions start with _ and aren't listed in this script's help menu.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
function cov:pytest {
# Run pytest
coverage run -m pytest "${@}"
}
function cov:report {
# Generate coverage report to terminal
coverage report "${@}"
}
function cov:html {
# Output coverage report to ./htmlcov
coverage html "${@}"
}
function nox:black {
# Check code for formatting violations
nox -s black-3.11 "${@}"
}
function nox:docs {
# Create Sphinx documentation in ./docs/_build directory
nox -s docs-3.11 "${@}"
}
function nox:lint {
# Run a number of flake8 linting tests
nox -s lint-3.11 "${@}"
}
function nox:safety {
# Check code/packages for vulnerabilites against Safety db
nox -s safety-3.11 "${@}"
}
function nox:tests {
# Run several pytest and coverage checks
nox -s tests-3.11 "${@}"
# cmd black . "${@}"
}
function nox:all {
# Perform all nox code quality tests together(except black)
# cmd nox -s black-3.11 "${@}"
nox -s lint-3.11 "${@}"
nox -s safety-3.11 "${@}"
nox -s tests-3.11 "${@}"
}
function poe:old {
# List any installed packages that are outdated
poetry show -ol
# The following command runs twice as fast; but, requires the container
# to be running:
# cmd poetry show -ol
}
function poe:up {
# Update any outdated packages
poetry update
}
function reqs:dev {
# Export all package requirements
poetry export --with=dev --output requirements-dev.txt
}
function reqs:prod {
# Export production package requirements
poetry export --output requirements.txt
}
function secret {
# Generate a random secret that can be used for your SECRET_KEY and more
python3 -c 'import secrets; print(secrets.token_urlsafe(38))'
}
function help {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
# This idea is heavily inspired by: https://github.com/adriancooney/Taskfile
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"