-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
216 lines (179 loc) · 7.06 KB
/
Taskfile.yml
File metadata and controls
216 lines (179 loc) · 7.06 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# https://taskfile.dev
version: '3'
# https://taskfile.dev/usage/#env-files
dotenv: ['.env.local', '.env']
vars:
# https://taskfile.dev/reference/templating/
SITE_DOMAIN: '{{.TASK_SITE_DOMAIN | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default ""}}'
DOCKER_COMPOSE: '{{.TASK_DOCKER_COMPOSE | default "docker compose"}}'
COMPOSER_INSTALL_ARGUMENTS: '{{.TASK_COMPOSER_INSTALL_ARGUMENTS | default ""}}'
tasks:
default:
cmds:
- task --list
silent: true
# ---- Compose helpers --------------------------------------------------
compose:
desc: 'Run `docker compose` command. Example: task compose -- up --detach'
cmds:
- '{{.DOCKER_COMPOSE}} {{.CLI_ARGS}}'
compose-exec:
desc: 'Run `docker compose exec` command, handling content on stdin. Example: task compose-exec -- phpfpm php -v'
cmds:
# Detect whether anything is piped into stdin so non-interactive use
# (e.g. `cat foo.sql | task compose-exec -- ...`) does not allocate a TTY.
# https://unix.stackexchange.com/questions/762992/bash-check-if-the-standard-input-contains-anything
- if [[ ! -t 0 ]]; then task compose -- exec --no-TTY {{.CLI_ARGS}}; else task compose -- exec {{.CLI_ARGS}}; fi
silent: true
# ---- Lifecycle --------------------------------------------------------
site-install:
desc: 'Pull images, start the stack, and install Composer dependencies.'
cmds:
- task compose -- pull
- task compose -- up --detach --remove-orphans --wait
- task composer-install
silent: true
# ---- Composer ---------------------------------------------------------
composer:
desc: 'Run a Composer command inside phpfpm. Example: task composer -- require foo/bar'
cmds:
- task compose-exec -- phpfpm composer {{.CLI_ARGS}}
silent: true
composer-install:
desc: 'Run `composer install` inside phpfpm.'
cmds:
- task composer -- install {{.COMPOSER_INSTALL_ARGUMENTS}}
silent: true
# ---- Symfony console --------------------------------------------------
console:
desc: 'Run a Symfony console command. Example: task console -- cache:clear'
cmds:
# If phpfpm is not running, fall back to `run --rm`. See
# https://serverfault.com/a/935674 for the running-container check.
- |
if [ -z "$({{.DOCKER_COMPOSE}} ps -q phpfpm)" ] || [ -z "$(docker ps -q --no-trunc | grep $({{.DOCKER_COMPOSE}} ps -q phpfpm))" ]; then
task compose -- run --rm phpfpm bin/console {{.CLI_ARGS}}
else
task compose-exec -- phpfpm bin/console {{.CLI_ARGS}}
fi
silent: true
# ---- Site -------------------------------------------------------------
site-url:
desc: 'Print the site URL.'
cmds:
- echo "{{.URL}}"
vars:
URL:
sh: if [ -n "{{.SITE_DOMAIN}}" ]; then echo "https://{{.SITE_DOMAIN}}"; else echo "http://$({{.DOCKER_COMPOSE}} port nginx 8080)"; fi
silent: true
site-open:
desc: 'Open the site in the default browser.'
cmds:
- open "$(task site-url)"
silent: true
# ---- Tests ------------------------------------------------------------
test:
desc: 'Run the PHPUnit test suite (no coverage).'
cmds:
- task compose-exec -- phpfpm vendor/bin/phpunit
silent: true
test-coverage:
desc: 'Run PHPUnit with coverage and enforce the 100% gate.'
cmds:
- task compose -- exec -e XDEBUG_MODE=coverage phpfpm vendor/bin/phpunit --coverage-clover=coverage/clover.xml
- task compose-exec -- phpfpm vendor/bin/coverage-check coverage/clover.xml 100
silent: true
# ---- Coding standards -------------------------------------------------
coding-standards-check:
desc: 'Run every coding-standards check.'
cmds:
- task: coding-standards-php-check
- task: coding-standards-twig-check
- task: coding-standards-yaml-check
- task: coding-standards-js-check
- task: coding-standards-css-check
- task: coding-standards-markdown-check
- task: coding-standards-composer-check
silent: true
coding-standards-apply:
desc: 'Auto-fix every category of coding standards.'
cmds:
- task: coding-standards-php-apply
- task: coding-standards-twig-apply
- task: coding-standards-yaml-apply
- task: coding-standards-js-apply
- task: coding-standards-css-apply
- task: coding-standards-markdown-apply
- task: coding-standards-composer-apply
silent: true
coding-standards-php-check:
desc: 'Check PHP coding standards (php-cs-fixer, dry-run).'
cmds:
- task compose-exec -- phpfpm vendor/bin/php-cs-fixer fix --dry-run --diff
silent: true
coding-standards-php-apply:
desc: 'Apply PHP coding standards (php-cs-fixer).'
cmds:
- task compose-exec -- phpfpm vendor/bin/php-cs-fixer fix
silent: true
coding-standards-twig-check:
desc: 'Check Twig coding standards (twig-cs-fixer).'
cmds:
- task compose-exec -- phpfpm vendor/bin/twig-cs-fixer lint
silent: true
coding-standards-twig-apply:
desc: 'Apply Twig coding standards (twig-cs-fixer).'
cmds:
- task compose-exec -- phpfpm vendor/bin/twig-cs-fixer fix
silent: true
coding-standards-yaml-check:
desc: 'Check YAML formatting (Prettier).'
cmds:
- task compose -- --profile dev run --rm prettier '**/*.{yml,yaml}' --check
silent: true
coding-standards-yaml-apply:
desc: 'Apply YAML formatting (Prettier).'
cmds:
- task compose -- --profile dev run --rm prettier '**/*.{yml,yaml}' --write
silent: true
coding-standards-js-check:
desc: 'Check JavaScript formatting (Prettier). Mirrors the JavaScript CI workflow.'
cmds:
- task compose -- --profile dev run --rm prettier 'assets/**/*.js' --check
silent: true
coding-standards-js-apply:
desc: 'Apply JavaScript formatting (Prettier).'
cmds:
- task compose -- --profile dev run --rm prettier 'assets/**/*.js' --write
silent: true
coding-standards-css-check:
desc: 'Check CSS/SCSS formatting (Prettier). Mirrors the Styles CI workflow.'
cmds:
- task compose -- --profile dev run --rm prettier 'assets/**/*.{css,scss}' --check
silent: true
coding-standards-css-apply:
desc: 'Apply CSS/SCSS formatting (Prettier).'
cmds:
- task compose -- --profile dev run --rm prettier 'assets/**/*.{css,scss}' --write
silent: true
coding-standards-markdown-check:
desc: 'Check Markdown (markdownlint).'
cmds:
- task compose -- --profile dev run --rm markdownlint markdownlint '**/*.md'
silent: true
coding-standards-markdown-apply:
desc: 'Apply Markdown fixes (markdownlint).'
cmds:
- task compose -- --profile dev run --rm markdownlint markdownlint '**/*.md' --fix
silent: true
coding-standards-composer-check:
desc: 'Validate composer.json and check it is normalized.'
cmds:
- task composer -- validate --strict
- task composer -- normalize --dry-run
silent: true
coding-standards-composer-apply:
desc: 'Normalize composer.json.'
cmds:
- task composer -- normalize
silent: true