-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·73 lines (58 loc) · 1.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
#!/bin/bash
set -eo pipefail
function _source_venv {
{
source ocr-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 ocr-service-venv
source ocr-service-venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
printf '\e[33m\n%s\n\n\e[0m' '"source ./ocr-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 src
}
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 start:testing {
docker compose --profile testing up --build "${@}"
}
function start:local {
docker compose -f docker-compose.yml -f docker-compose.local.yml up --build "${@}"
}
function stop {
docker compose --profile testing 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}"