-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·65 lines (52 loc) · 1.26 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
#!/bin/bash
set -eo pipefail
function _source_venv {
{
source service-venv/bin/activate 2>&1
} || {
printf '\e[31m\n%s\n\n\e[0m' 'Venv does not exist, create it running ./run install_venv'
exit 1
}
}
function install_venv {
python3 -m venv service-venv
source service-venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements/development.txt
printf '\e[33m\n%s\n\n\e[0m' '"source ./service-venv/bin/activate" to activate venv (only needed if not running commands from the run script)'
}
function formatter {
_source_venv
# Format Python code with black
command black .
}
function check_format {
_source_venv
# Format Python code with black
command black . --check
}
function test {
_source_venv
python -m unittest discover -s tests
}
function linter {
_source_venv
command flake8
}
function remove_docker_containers {
docker compose ps -q | xargs docker rm
}
function remove_docker_images {
docker compose config --images | xargs docker rmi
}
function start {
docker compose up --build "${@}"
}
function stop {
docker compose stop
}
function help {
printf "%s <task> \n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
}
USER_ID=$(id -u) GROUP_ID=$(id -g) "${@:-help}"