-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile
More file actions
executable file
·114 lines (92 loc) · 4.83 KB
/
Taskfile
File metadata and controls
executable file
·114 lines (92 loc) · 4.83 KB
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
#!/bin/bash
# =========================================================
# Taskfile gives you a set of quick tasks for your project
# More info: https://github.com/Enrise/Taskfile
# =========================================================
function banner {
echo -e "${BLUE}\n"\
"██╗ ██╗███████╗███████╗██████╗ █████╗ ██████╗ ██████╗ ███████╗███████╗███╗ ███╗███████╗███╗ ██╗████████╗███████╗\n"\
"██║ ██║██╔════╝██╔════╝██╔══██╗██╔══██╗██╔════╝ ██╔══██╗██╔════╝██╔════╝████╗ ████║██╔════╝████╗ ██║╚══██╔══╝██╔════╝\n"\
"██║ ██║███████╗█████╗ ██████╔╝███████║██║ ███╗██████╔╝█████╗ █████╗ ██╔████╔██║█████╗ ██╔██╗ ██║ ██║ ███████╗\n"\
"██║ ██║╚════██║██╔══╝ ██╔══██╗██╔══██║██║ ██║██╔══██╗██╔══╝ ██╔══╝ ██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║ ╚════██║\n"\
"╚██████╔╝███████║███████╗██║ ██║██║ ██║╚██████╔╝██║ ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║ ╚████║ ██║ ███████║\n"\
" ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝${RESET}"
}
# =========================================================
## Project
# =========================================================
function task:start { ## Start the project in development mode
title "Run development environment"
dockercompose up -d
}
# =========================================================
## Docker
# =========================================================
function task:build { ## Build docker compose file
title "Build docker compose"
dockercompose build
}
function task:restart { ## Docker compose restart
title "Stop docker compose"
dockercompose restart
}
function task:stop { ## Docker compose down
title "Stop docker compose"
dockercompose stop
}
function task:shell { ## Shell into PHP container
dockercompose exec php bash
}
# =========================================================
## Tests
# =========================================================
function task:codestyle { ## Run codestyle test
dockercompose-exec vendor/bin/ecs --config=development/tooling/ecs.php
}
function task:phpstan { ## Run PHPStan
dockercompose-exec vendor/bin/phpstan --configuration=./development/tooling/phpstan.neon
}
function task:tests { ## Run unit tests
dockercompose-exec vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox
}
function task:tests-with-coverage { ## Run unit tests with codestyle reports
dockercompose-exec vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox --coverage-html coverage
}
# =========================================================
# Internal functions
# =========================================================
function dockercompose {
docker compose --file ./development/compose.yaml "$@"
}
function dockercompose-exec {
dockercompose exec php "$@"
}
# =========================================================
## Taskfile
# =========================================================
set -eo pipefail
BLUE=$(printf '\033[36m')
YELLOW=$(printf '\033[33m')
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
RESET=$(printf '\033[0m')
# Define global variables here
function title {
echo -e "\n${BLUE}=>${RESET} $1\n"
}
function task:help { ## Show all available tasks
title "Available tasks"
awk 'BEGIN {FS = " { [#][#][ ]?"} /^([a-zA-Z_-]*:?.*)(\{ )?[#][#][ ]?/ \
{printf "\033[33m%-34s\033[0m %s\n", $1, $2}' $0 |\
sed -E "s/[#]{2,}[ ]*/${RESET}/g" |\
sed -E "s/function task:*/ /g"
echo -e "\n${BLUE}Usage:${RESET} $0 ${YELLOW}<task>${RESET} <args>"
}
banner
if [[ ! "$(declare -F task:${@-help})" ]]; then
title "Task not found"
echo -e "Task ${YELLOW}$1${RESET} doesn't exist."
task:help
exit 1
fi
task:${@-help}