-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
402 lines (349 loc) · 15.1 KB
/
Taskfile.yml
File metadata and controls
402 lines (349 loc) · 15.1 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
version: "3"
# https://taskfile.dev/usage/#env-files
dotenv: [".env.local", ".env"]
includes:
translations:
taskfile: ./task/Taskfile.translations.yml
vars:
TRANSLATION_MODULES:
# - aarhus_hero
- hoeringsportal_activity
- hoeringsportal_anonymous_edit
# - hoeringsportal_audit_log
# - hoeringsportal_base_fixtures
- hoeringsportal_citizen_proposal
- hoeringsportal_citizen_proposal_archiving
# - hoeringsportal_config_settings
# - hoeringsportal_content_access
# - hoeringsportal_content_blocks
# - hoeringsportal_data
# - hoeringsportal_deskpro
- hoeringsportal_dialogue
# - hoeringsportal_forms
- hoeringsportal_hearing
# - hoeringsportal_misc
# - hoeringsportal_openid_connect
- hoeringsportal_project
- hoeringsportal_public_meeting
# - hoeringsportal_quicklinks
# - hoeringsportal_test_delta_sync_fixtures
- itk_admin
- itk_admin_links
# - itk_media_entity
TRANSLATION_THEMES:
- hoeringsportal
# - hoeringsportal_admin
TRANSLATION_LANGUAGES:
- da
vars:
# https://taskfile.dev/reference/templating/
BASE_URL: '{{.TASK_BASE_URL | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default "https://deltag.local.itkdev.dk"}}'
DOCKER_COMPOSE: '{{.TASK_DOCKER_COMPOSE | default "docker compose"}}'
DOCKER_COMPOSE_PROFILES: '{{.TASK_DOCKER_COMPOSE_PROFILES | default ""}}'
COMPOSER_INSTALL_ARGUMENTS: '{{.TASK_COMPOSER_INSTALL_ARGUMENTS | default ""}}'
PRETIX_URL: '{{.TASK_PRETIX_URL | default "http://pretix.deltag.local.itkdev.dk"}}'
PRETIX_ORGANIZER: '{{.TASK_PRETIX_ORGANIZER | default "dpl-cms"}}'
tasks:
default:
cmds:
- task --list-all
silent: true
site-install:
prompt: "This will reset your setup. Continue?"
cmds:
- task compose -- down
- task compose -- pull
- task compose-up
- task composer-install
- task drush -- --yes site:install --existing-config
- task: translations:import
- task drush -- --yes cache:rebuild
- task assets-build
- task site-open
- task site-open-admin
silent: true
site-update:
cmds:
- task compose -- pull
- task compose-up
- task composer-install
- task assets-build
- task drush -- deploy
- task: translations:import
- task drush -- --yes cache:rebuild
silent: true
site-url:
cmds:
- task drush -- browse --no-browser
silent: true
site-open:
cmds:
- if command -v open 2>&1 >/dev/null; then open "$(task site-url)"; else echo "$(task site-url)"; fi
silent: true
site-open-admin:
cmds:
- if command -v open 2>&1 >/dev/null; then open "{{.URL}}"; else echo "{{.URL}}"; fi
vars:
URL:
sh: task drush -- user:login --no-browser
silent: true
assets-build:
cmds:
- |
if [[ -z "{{.SKIP_BUILD}}" ]]; then
{{.DOCKER_COMPOSE}} run --rm node npm install --prefix web/themes/custom/hoeringsportal
{{.DOCKER_COMPOSE}} run --rm node npm run build --prefix web/themes/custom/hoeringsportal
fi
vars:
SKIP_BUILD: "{{.ASSETS_SKIP_BUILD | default .TASK_ASSETS_SKIP_BUILD}}"
assets-watch:
cmds:
- "{{.DOCKER_COMPOSE}} run --rm node npm run watch --prefix web/themes/custom/hoeringsportal"
compose:
cmds:
- '{{.DOCKER_COMPOSE}} {{if .DOCKER_COMPOSE_PROFILES}}--profile {{.DOCKER_COMPOSE_PROFILES | splitList "," |join " --profile " }}{{end}} {{.CLI_ARGS}}'
vars:
DOCKER_COMPOSE_PROFILES: "{{.PROFILES | default .DOCKER_COMPOSE_PROFILES}}"
compose-up:
cmds:
- task compose -- up --detach --remove-orphans {{if .COMPOSE_UP_WAIT}}--wait{{end}}
silent: true
composer:
cmds:
- task compose -- exec phpfpm composer {{.CLI_ARGS}}
silent: true
composer-install:
cmds:
- task composer -- install {{.COMPOSER_INSTALL_ARGUMENTS}} {{.CLI_ARGS}}
silent: true
drush:
cmds:
# Check if we have content on stdin (cf.
# https://unix.stackexchange.com/questions/762992/bash-check-if-the-standard-input-contains-anything)
- >-
if [[ ! -t 0 ]]; then
task compose -- exec --no-TTY phpfpm {{.DRUSH_SCRIPT}} --uri={{.BASE_URL}} {{.CLI_ARGS}};
else
task compose -- exec phpfpm {{.DRUSH_SCRIPT}} --uri={{.BASE_URL}} {{.CLI_ARGS}};
fi
vars:
# Note: We use vendor/bin/drush.php (rather than vendor/bin/drush, say) to
# make debugging work for Drush commands.
DRUSH_SCRIPT: vendor/bin/drush.php
silent: true
database-dump:
cmds:
# Make sure that site is up to date
- task site-update
- task drush -- sql:dump --extra-dump='--skip-column-statistics' --structure-tables-list="cache,cache_*,advancedqueue,history,search_*,sessions,watchdog" --gzip --result-file=/app/.docker/drupal/dumps/drupal.sql
pretix:
cmds:
- task compose -- exec pretix pretix {{.CLI_ARGS}}
silent: true
pretix:database-dump:
cmds:
- task compose -- exec --env PGPASSWORD=pretix pretix_database pg_dump --user=pretix pretix > .docker/pretix/dumps/pretix.sql
pretix:database-cli:
cmds:
- task compose -- exec --env PGPASSWORD=pretix pretix_database psql --user=pretix pretix
pretix:database-reset:
prompt: "This will reset your pretix database. Continue?"
cmds:
# Remove the pretix database container
- task compose -- rm pretix_database --stop --force
# Starting the container will load dump from .docker/pretix/dumps (cf. docker-compose.pretix.yml).
- task compose -- up --detach
# https://docs.pretix.eu/en/latest/admin/installation/docker_smallscale.html#updates
- task compose -- exec pretix pretix upgrade
pretix:database-load:
prompt: "This will reset your pretix database. Continue?"
cmds:
- task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --quiet --user=pretix pretix <<< "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
- task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --quiet --user=pretix pretix < .docker/pretix/dumps/pretix.sql
# https://docs.pretix.eu/en/latest/admin/installation/docker_smallscale.html#updates
- task pretix -- upgrade
pretix:api-ping:
vars:
API_TOKEN:
sh: task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --user=pretix pretix --tuples-only --csv <<< "SELECT token FROM pretixbase_teamapitoken WHERE name = 'hoeringsportal'"
cmds:
- "task compose -- exec phpfpm curl --header 'Authorization: Token {{.API_TOKEN}}' {{.PRETIX_URL}}/api/v1/organizers/"
coding-standards:apply:
desc: "Apply coding standards"
cmds:
- task: coding-standards:javascript:apply
- task: coding-standards:markdown:apply
- task: coding-standards:php:apply
- task: coding-standards:styles:apply
- task: coding-standards:twig:apply
- task: coding-standards:yaml:apply
silent: true
coding-standards:check:
desc: "Apply coding standards"
cmds:
- task: coding-standards:javascript:check
- task: coding-standards:markdown:check
- task: coding-standards:php:check
- task: coding-standards:styles:check
- task: coding-standards:twig:check
- task: coding-standards:yaml:check
silent: true
coding-standards:javascript:apply:
desc: "Apply coding standards for javascript"
cmds:
# Cf. .github/workflows/javascript.yaml
- docker compose run --rm prettier 'web/themes/custom/**/js/**/*.js' --write
coding-standards:javascript:check:
desc: "Apply coding standards for javascript"
cmds:
- task: coding-standards:javascript:apply
# Cf. .github/workflows/javascript.yaml
- docker compose run --rm prettier 'web/themes/custom/**/js/**/*.js' --check
coding-standards:markdown:apply:
desc: "Apply coding standards for Markdown"
cmds:
# Cf. .github/workflows/markdown.yaml
- docker compose run --rm markdownlint markdownlint '**/*.md' --fix
coding-standards:markdown:check:
desc: "Apply and check coding standards for Markdown"
cmds:
- task: coding-standards:markdown:apply
# Cf. .github/workflows/markdown.yaml
- docker compose run --rm markdownlint markdownlint '**/*.md'
coding-standards:php:apply:
desc: "Apply coding standards for PHP"
cmds:
# Cf. .github/workflows/php.yaml
- docker compose run --rm phpfpm vendor/bin/phpcbf
silent: true
coding-standards:php:check:
desc: "Apply and check coding standards for PHP"
cmds:
- task: coding-standards:php:apply
# Cf. .github/workflows/php.yaml
- docker compose run --rm phpfpm vendor/bin/phpcs
silent: true
coding-standards:styles:apply:
desc: "Apply coding standards for styles"
cmds:
# Cf. .github/workflows/styles.yaml
- docker compose run --rm prettier 'web/themes/custom/**/css/**/*.{css,scss}' --write
coding-standards:styles:check:
desc: "Apply coding standards for styles"
cmds:
- task: coding-standards:styles:apply
# Cf. .github/workflows/styles.yaml
- docker compose run --rm prettier 'web/themes/custom/**/css/**/*.{css,scss}' --check
coding-standards:twig:apply:
desc: "Apply coding standards for Twig"
cmds:
- docker compose run --rm phpfpm vendor/bin/twig-cs-fixer fix
silent: true
coding-standards:twig:check:
desc: "Apply and check coding standards for Twig"
cmds:
- task: coding-standards:twig:apply
- docker compose run --rm phpfpm vendor/bin/twig-cs-fixer lint
silent: true
coding-standards:yaml:apply:
desc: "Apply coding standards for YAML"
cmds:
# Cf. .github/workflows/yaml.yaml
- docker compose run --rm prettier '**/*.{yml,yaml}' --write
coding-standards:yaml:check:
desc: "Apply coding standards for YAML"
cmds:
- task: coding-standards:yaml:apply
# Cf. .github/workflows/yaml.yaml
- docker compose run --rm prettier '**/*.{yml,yaml}' --check
code-analysis:
cmds:
- docker compose run --rm phpfpm vendor/bin/phpstan analyse --configuration=phpstan.neon
# Check some modules with a higher level.
#
# Note: The second `--` is needed to pass command line arguments (starting with `--`) to the composer script
# `code-analysis`
#
# @todo Update all our custom modules to resolve ‘level 9 (or 8) errors“
- docker compose run --rm phpfpm vendor/bin/phpstan analyse --configuration=phpstan.neon --level=9 web/modules/custom/hoeringsportal_audit_log/
docker-pull:
desc: "Pull all development docker images"
cmds:
- docker pull jauderho/prettier
- docker pull peterdavehello/markdownlint
- task compose -- pull
fixtures:load:
prompt: "This will reset your content. Continue?"
cmds:
# We need the pretix service to load public meeting fixtures (cf. https://docs.docker.com/compose/how-tos/environment-variables/envvars/#compose_profiles)
- COMPOSE_PROFILES=pretix COMPOSE_UP_WAIT=true task compose-up
- task drush -- --yes pm:enable hoeringsportal_base_fixtures $(find web/modules/custom -type f -name 'hoeringsportal_*_fixtures.info.yml' -exec basename -s .info.yml {} \;)
- task drush -- sql:query "TRUNCATE hoeringsportal_anonymous_edit_content"
- task drush -- sql:query "TRUNCATE hoeringsportal_anonymous_edit_owners"
- task drush -- --yes content-fixtures:load
# We don't set/use browser cookies when loading fixtures, so we need a little clean up to make sure that an email is associated with just one token.
# Update content to use a single token (the smallest) per email
- |
task drush -- sql:query "
UPDATE hoeringsportal_anonymous_edit_content AS c
JOIN hoeringsportal_anonymous_edit_owners AS o ON c.owner_token = o.owner_token
SET c.owner_token = (SELECT MIN(owner_token) FROM hoeringsportal_anonymous_edit_owners WHERE hoeringsportal_anonymous_edit_owners.email = o.email)
WHERE o.email != ''
;
"
# Delete all owners having an email and not the smallest token
- |
task drush -- sql:query "
DELETE FROM hoeringsportal_anonymous_edit_owners
WHERE email != ''
AND owner_token != (SELECT MIN(owner_token) FROM hoeringsportal_anonymous_edit_owners AS o WHERE hoeringsportal_anonymous_edit_owners.email = o.email)
;
"
- task drush -- --yes pm:uninstall content_fixtures
# Update states on public meetings.
- task drush -- --yes hoeringsportal:public_meeting:state-update
- task compose-up
silent: true
translations:import:
desc: Import and update translations
cmds:
- task compose -- exec phpfpm bash -c '(cd web && ../vendor/bin/drush locale:import --type=customized --override=all da ../translations/custom-translations.da.po)'
- task drush -- locale:check
- task drush -- locale:update
- task drush -- cache:rebuild
silent: true
# Development settings tasks (`/admin/config/development/settings`) (cf. https://www.drupal.org/docs/develop/development-tools/disabling-and-debugging-caching).
development-settings:do-not-cache-markup-enable:
desc: Disable markup cache (check ‘Do not cache markup“ on `/admin/config/development/settings`)
cmds:
- task drush -- php:eval "Drupal::keyValue('development_settings')->setMultiple(['disable_rendered_output_cache_bins' => TRUE]);"
- task drush -- cache:rebuild
development-settings:do-not-cache-markup-disable:
desc: Enable markup cache (for production) (uncheck ‘Do not cache markup“ on `/admin/config/development/settings`)
cmds:
- task drush -- php:eval "Drupal::keyValue('development_settings')->setMultiple(['disable_rendered_output_cache_bins' => FALSE]);"
- task drush -- cache:rebuild
development-settings:twig-develoment-mode-enable:
desc: Enable Twig development mode (check ‘Twig development mode“ on `/admin/config/development/settings`)
cmds:
- task drush -- php:eval "Drupal::keyValue('development_settings')->setMultiple(['twig_debug' => TRUE, 'twig_cache_disable' => TRUE]);"
- task drush -- cache:rebuild
development-settings:twig-develoment-mode-disable:
desc: Disable Twig development mode (for production) (uncheck ‘Twig development mode“ on `/admin/config/development/settings`)
cmds:
- task drush -- php:eval "Drupal::keyValue('development_settings')->setMultiple(['twig_debug' => FALSE, 'twig_cache_disable' => FALSE]);"
- task drush -- cache:rebuild
development-settings:development:
desc: Set cache settings for development
cmds:
- task development-settings:do-not-cache-markup-enable
- task development-settings:twig-develoment-mode-enable
- task drush -- cache:rebuild
silent: true
development-settings:production:
desc: Set cache settings for production
cmds:
- task development-settings:do-not-cache-markup-disable
- task development-settings:twig-develoment-mode-disable
- task drush -- cache:rebuild
silent: true