-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
217 lines (186 loc) · 6.24 KB
/
Taskfile.yml
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
# Copyright (C) Damien Dart, <[email protected]>.
# This file is distributed under the MIT licence. For more information,
# please refer to the accompanying "LICENCE" file.
---
version: '3'
output: 'prefixed'
env:
RELEASE_TIMESTAMP:
sh: 'date +%Y%m%d%H%M%S'
tasks:
default:
deps:
- task: 'start'
ci:
cmds:
- task: 'git-filters'
- task: 'clean'
- task: 'dependencies'
- task: 'build'
- task: 'lint'
- task: 'static-analysis'
desc: 'Run all default CI-related tasks'
ci:end-to-end:
cmds:
- task: 'dependencies:php'
- task: 'test:end-to-end'
desc: 'Run all end-to-end-testing-related tasks'
build:
cmds:
- task: 'build:assets'
- task: 'build:css'
- task: 'build:javascript'
- task: 'build:ssg'
desc: 'Run all building tasks'
# While Task provides functionality that runs tasks when files
# changes, it's a little basic and slow to react to file changes. The
# following task is an attempt to improve this functionality. For more
# information about entr, see <http://eradman.com/entrproject/>.
# (See also: <https://github.com/go-task/task/issues/813>.)
build-watch:
cmds:
- cmd: 'command -v entr || (echo "\"entr\" is required."; exit 1)'
silent: true
- 'while sleep 0.1; do find src/ | entr -d task build && break; done'
desc: 'Runs entr to execute the "build" task on file changes'
build:assets:
cmds:
- 'cp -rTv ./node_modules/assets/www.robotinaponcho.net ./public'
desc: 'Copy pre-built assets'
sources:
- 'node_modules/assets/www.robotinaponcho.net/**/*'
build:css:
cmds:
- 'node_modules/.bin/sass --no-source-map src/sass/app.scss {{ .OUTPUT_FILE_MAIN }}'
- 'node_modules/.bin/lightningcss --minify --targets ">= 0.25%" {{ .OUTPUT_FILE_MAIN }} -o {{ .OUTPUT_FILE_MAIN }}'
- 'sed -i "s/00000000000000/$RELEASE_TIMESTAMP/g" {{ .OUTPUT_FILE_MAIN }}'
desc: 'Build CSS files with Sass and friends'
sources:
- 'src/sass/**/*.scss'
vars:
OUTPUT_FILE_MAIN: 'public/assets/style.css'
build:javascript:
cmds:
- 'node_modules/.bin/esbuild src/javascript/app.js --bundle --log-level=warning --minify --outfile={{ .OUTPUT_FILE }}'
desc: 'Build (IE11-incompatible) JavaScript files with esbuild'
sources:
- 'src/javascript/**/*.js'
vars:
OUTPUT_FILE: 'public/assets/app.js'
build:ssg:
cmds:
- 'src/ssg/ssg ./public/'
desc: 'Build static site files using ssg'
sources:
- 'src/ssg/**/*'
build:snapshot:
cmds:
- 'src/ssg/ssg ./ssg-output-{{ .TIMESTAMP }}/'
desc: 'Build static site files using ssg for snapshot testing'
env:
RELEASE_TIMESTAMP: '00000000000000'
vars:
TIMESTAMP:
sh: 'date +%Y%m%d%H%M%S'
clean:
cmds:
- 'rm -fr .task node_modules public release'
- task: 'clean:php'
- task: 'clean:snapshot'
desc: 'Delete all buildable files, caches, and third-party dependencies'
clean:php:
cmds:
- 'rm -fr protected/vendor'
desc: 'Delete third-party PHP dependencies'
clean:snapshot:
cmds:
- 'rm -fr ssg-output-*'
desc: 'Delete timestamp-prefixed snapshot directories'
dependencies:
cmds:
- task: 'dependencies:javascript'
- task: 'dependencies:php'
desc: 'Run dependency-installing-related tasks for development and testing environments'
dependencies:javascript:
cmds:
# <http://www.tiernok.com/posts/2019/faster-npm-installs-during-ci/>
- 'npm ci --prefer-offline --no-audit'
env:
CI: true
desc: 'Install JavaScript dependencies'
dependencies:php:
cmds:
- 'composer install --no-ansi --no-interaction --no-progress'
desc: 'Install PHP dependencies for development and testing environments'
dependencies:php-production:
cmds:
- 'composer install --classmap-authoritative --no-ansi --no-dev --no-interaction --no-progress'
desc: 'Install PHP dependencies for production environments'
git-filters:
cmds:
- 'git config filter.metadata.clean "./git-filter-metadata.sh"'
- 'git config filter.metadata.smudge "./git-filter-metadata.sh --smudge %f"'
- 'git config filter.metadata.required true'
# Git does not have a nice way of running filters manually.
- 'rm src/ssg/input/notes/*.md'
- 'git checkout src/ssg/input/notes'
desc: 'Install and run project-level Git filters'
lint:
cmds:
- task: 'lint:javascript'
- task: 'lint:php'
desc: 'Run all linting-related tasks'
lint:javascript:
cmds:
- 'node_modules/.bin/biome lint src/javascript/**'
desc: 'Lint JavaScript files with Biome'
lint:php:
cmds:
- 'protected/vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run --diff'
desc: 'Lint PHP scripts with PHP Coding Standards Fixer'
release:
cmds:
- cmd: |
{{ if .GIT_STATUS }}
echo 'Working directory is dirty! Aborting.'
exit 1
{{ end }}
silent: true
- task: 'ci'
- task: 'clean:php'
- task: 'dependencies:php-production'
- 'mkdir -p release'
- 'tar -cf release/release.tgz ./composer.* ./private/ ./protected/ ./public/'
- 'envsubst < deployment/metadata.yml > release/release.yml'
- 'cp deployment/*-tasks.yml release/'
desc: 'Create release artifacts for deployment'
env:
RELEASE_GIT_SHA:
sh: 'git log -n 1 --format=%H'
vars:
GIT_STATUS:
sh: 'git status --porcelain'
start:
cmds:
- task: 'ci'
desc: 'Run all development environment setup tasks'
static-analysis:
cmds:
- task: 'static-analysis:php'
desc: 'Run all static-analysis-related tasks'
static-analysis:php:
cmds:
- task: 'static-analysis:php:phpstan'
desc: 'Run all PHP static-analysis-related tasks'
static-analysis:php:phpstan:
cmds:
- 'protected/vendor/bin/phpstan analyse --no-progress'
desc: 'Analyse PHP files with PHPStan'
test:end-to-end:
cmds:
- 'protected/vendor/bin/phpunit --testdox'
desc: 'Run end-to-end tests with PHPUnit'
test:snapshot:
cmds:
- "find . -name 'ssg-output-*' | sort | tail -n 2 | xargs diff -qr"
desc: 'Compare the two more recent snapshot directories'