Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
325 lines (279 loc) · 10.7 KB
/
Copy pathTaskfile.yml
File metadata and controls
325 lines (279 loc) · 10.7 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
# https://taskfile.dev
version: "3"
tasks:
default:
cmd: task --list-all
silent: true
ddev:
desc: "Run DDEV command"
cmd: ddev {{.TASK_ARGS}} {{.CLI_ARGS}}
internal: true
coding-standards:apply:
desc: "Apply coding standards"
cmds:
- task: coding-standards:composer:apply
- task: coding-standards:javascript:apply
- task: coding-standards:markdown:apply
- task: coding-standards:php:apply
- task: coding-standards:yaml:apply
coding-standards:check:
desc: "Check coding standards"
cmds:
- task: coding-standards:composer:check
- task: coding-standards:javascript:check
- task: coding-standards:markdown:check
- task: coding-standards:php:check
- task: coding-standards:yaml:check
coding-standards:composer:apply:
desc: "Apply coding standards for composer"
cmds:
- task: ddev
vars:
TASK_ARGS: composer normalize
coding-standards:composer:check:
- task: coding-standards:composer:apply
- task: ddev
vars:
TASK_ARGS: composer normalize --dry-run
- task: ddev
vars:
TASK_ARGS: composer validate
coding-standards:javascript:apply:
desc: "Apply coding standards for JavaScript"
cmds:
# Cf. .github/workflows/javascript.yaml
- docker compose run --rm prettier 'tests/**/*.{js,ts}' --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 'tests/**/*.{js,ts}' --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
- task: ddev
vars:
TASK_ARGS: phpcbf
coding-standards:php:check:
desc: "Apply and check coding standards for PHP"
cmds:
- task: coding-standards:php:apply
# phpcbf has weird exit codes …
ignore_error: true
# Cf. .github/workflows/php.yaml
- task: ddev
vars:
TASK_ARGS: phpcs
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:
desc: "Run static code analysis"
cmds:
- task: code-analysis:rector
- task: code-analysis:phpstan
code-analysis:phpstan:
desc: "Run PHPStan"
cmds:
- task: ddev
vars:
TASK_ARGS: phpstan
code-analysis:rector:
desc: "Run rector"
cmds:
- task: ddev
vars:
TASK_ARGS: php vendor/bin/rector
ddev:start:
desc: Start DDEV Drupal Contrib setup (https://github.com/ddev/ddev-drupal-contrib)
cmds:
# We want a clean slate
- rm -f composer.lock
- ddev start
- ddev poser --no-interaction
- ddev symlink-project
ddev:update:
desc: Update DDEV Drupal Contrib setup (https://github.com/ddev/ddev-drupal-contrib#update)
cmds:
- ddev add-on get ddev/ddev-drupal-contrib
- ddev restart
translations:extract:
desc: Extract module translations
deps:
- drupal:site:is-installed
cmds:
- for:
- da
cmd: >-
ddev drush --yes drupal_translation_extractor:translation:extract {{.ITEM}}
--dump-messages --force --output=%source/translations/%module.%locale.po
--require-context=os2forms_f2 module:os2forms_f2
--sort=asc --clean --debug
--finder-do-not-ignore-vcs-ignored
# Show any changes
- task: translations:git:diff
ignore_error: true
# Restore if only some metadata is changed
- task: translations:git:restore
translations:git:diff:
desc: "`git diff` all translation files ignoring timestamp changes"
# Ignore some PO metadata when git diff'ing, e.g.
#
# "POT-Creation-Date: 2025-03-12 18:18+0100\n"
# "PO-Revision-Date: 2025-03-12 18:18+0100\n"
cmd: git diff --exit-code --ignore-blank-lines --ignore-matching-lines='^"PO.*-Date' '*.po'
translations:git:restore:
desc: '`git restore` all translation file changes if only timestamps are changed (cf. `task {{.TASK | replace ":restore" ":diff" }}`)'
# https://taskfile.dev/reference/schema#preconditions
preconditions:
- sh: task {{.TASK | replace ":restore" ":diff" }}
msg: |
Translations seem to have changed.
Run
task {{.TASK | replace ":restore" ":diff" }}
to check.
cmd: git restore '*.po'
drupal:site:is-installed:
internal: true
preconditions:
# https://drupal.stackexchange.com/a/318384
- sh: '[ $(ddev drush status --field=bootstrap) = "Successful" ]'
msg: |
It seems that Drupal has not been installed. Run
task drupal:site:install
before running this task.
drupal:site:install:
desc: Installs Drupal site, enables OS2Forms F2 module and configures Drupal for development and testing
prompt: Really install (and reset) Drupal site?
cmds:
- ddev drush --yes site:install
- ddev drush --yes user:password admin password
- ddev drush --yes pm:uninstall update announcements_feed
# Patch https://github.com/OS2Forms/os2forms/blob/develop/config/optional/pathauto.pattern.os2forms_wf_webforms.yml
- |
ddev exec sed --in-place 's/id: node_type$/id: entity_bundle:node/' */modules/contrib/os2forms/config/optional/pathauto.pattern.os2forms_wf_webforms.yml
- ddev drush --yes pm:install os2forms_f2 os2forms_f2_examples os2forms_f2_test drupal_translation_extractor
# Some defaults
- ddev drush --yes config:set os2forms_f2.settings f2_api.log_level debug
- ddev drush --yes config:set os2forms_f2.settings general.queue os2forms_f2
# Gin theme
- ddev drush --yes theme:install gin
- ddev drush --yes config:set system.theme default gin
- ddev drush --yes config:set system.theme admin gin
- ddev drush --yes pm:uninstall navigation
# - ddev drush --yes config:set gin.settings classic_toolbar horizontal
- ddev drush --yes config:set webform.settings ui.description_help false --input-format yaml
- ddev drush --yes config:set webform.settings settings.default_submission_log true --input-format=yaml
# Languages and locales
- ddev drush --yes pm:install language locale
- ddev drush --yes language:add da
# - ddev drush --yes locale:check
# - ddev drush --yes locale:update
# Import our module translations
- ddev drush --yes locale:import da modules/custom/os2forms_f2/translations/os2forms_f2.da.po
- task: drupal:site:reset
drupal:site:reset:
decs: Create settings for os2forms_f2 module
prompt: Really reset Drupal site?
cmds:
- ddev drush --yes config:import --partial --source modules/custom/os2forms_f2/modules/os2forms_f2_examples/config/install
- ddev drush --yes config:import --partial --source modules/custom/os2forms_f2/modules/os2forms_f2_test/config/install
- >-
ddev drush --yes sql:query "
TRUNCATE advancedqueue;
TRUNCATE webform_submission_log;
TRUNCATE webform_submission_data;
TRUNCATE webform_submission;
TRUNCATE os2forms_f2_f2_item;
ALTER TABLE webform_submission AUTO_INCREMENT = 1;
UPDATE webform SET next_serial = 1;
"
playwright:install:
desc: Install Playwright stuff
cmd: ddev playwright-install --pm npm
user-manual:images:generate:
desc: Generate user manual images
deps:
- drupal:site:is-installed
- playwright:install
cmds:
- cmd: ddev playwright test user-manual-images.spec.ts {{.CLI_ARGS}}
# We want to postprocess any updated images even if something fails
ignore_error: true
- task: user-manual:images:trim
- task: user-manual:images:restore
user-manual:images:trim:
desc: "Trim docs images"
silent: true
vars:
BORDER_WIDTH: 4
# Trim and add border
cmd:
cmd: |
docker run --volume $PWD:/app --workdir /app --rm itkdev/php8.5-fpm mogrify \
-strip \
-background white \
-trim \
-gravity north -splice 0x{{.BORDER_WIDTH}}+0+0 \
-gravity south -splice 0x{{.BORDER_WIDTH}}+0+0 \
-gravity west -splice {{.BORDER_WIDTH}}x0+0+0 \
-gravity east -splice {{.BORDER_WIDTH}}x0+0+0 \
docs/user-manual/da/images/generated/**/*.png
# https://taskfile.dev/docs/reference/schema#shopt
shopt: [globstar]
user-manual:images:restore:
desc: "Restore docs images that are not visually modified"
silent: true
cmd:
cmd: |
# https://stackoverflow.com/a/949391
latest_commit=$(git rev-parse --verify HEAD)
# M docs/en/images/manager/006-entry-look-up.png
status_modified_pattern="^ M "
debug_output_filename=false
if [[ '{{.COMPARE_OUTPUT_FILENAME | default "-"}}' != '-' ]]; then
debug_output_filename=true
fi
shopt -s globstar nullglob
for file in docs/user-manual/da/images/generated/**/*.png; do
status=$(git status --porcelain "$file")
if [[ "$status" =~ $status_modified_pattern ]]; then
if git cat-file -p "$latest_commit":"$file" | \
docker run --volume $PWD:/app --workdir /app --rm itkdev/php8.5-fpm compare \
- \
"$file" \
{{.COMPARE_OUTPUT_FILENAME | default "-"}} > /dev/null 2>&1; then
echo "Restoring $file"
git restore "$file"
else
echo "$file modified"
if [ "$debug_output_filename" = true ]; then
echo
echo "Comparison image written to {{.COMPARE_OUTPUT_FILENAME | default "-"}}"
echo
fi
fi
fi
done
shopt: [globstar]