-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskfile.yaml
More file actions
287 lines (251 loc) · 8.37 KB
/
taskfile.yaml
File metadata and controls
287 lines (251 loc) · 8.37 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
version: '3'
vars:
PROTO_DIR: protos/proto
SDK_GEN_DIR: protos/gen
DOCS_GEN_DIR: docs
PHP: php
COMPOSER: composer
tasks:
install:
desc: Install project dependencies
cmd: "{{.COMPOSER}} install"
sources:
- composer.json
generates:
- vendor/autoload.php
var:
cmd: mkdir -p var
status:
- test -d var
silent: true
internal: true
fixcs:
desc: Fix code style issues
deps: [ var, install ]
cmds:
- "{{.PHP}} vendor/bin/php-cs-fixer fix --verbose {{.CLI_ARGS}}"
lint:
desc: Check code style (dry-run)
cmds:
- task: fixcs
vars:
CLI_ARGS: "--dry-run {{.CLI_ARGS}}"
verify:
desc: Run the default verification gate (lint, phpstan, sql check, unit tests)
deps: [ var, install ]
cmds:
- task: lint
- task: phpstan
- task: sql:check
- task: test
verify:integration:
desc: Run integration verification against real PostgreSQL
deps: [ var, install ]
cmds:
- task: sql:check:pg
- task: test:integration
verify:full:
desc: Run all verification steps including integration tests
cmds:
- task: verify
- task: tools:sql:check
- task: verify:integration
phpstan:
desc: Run static analysis
deps: [ var, install ]
cmds:
- "{{.PHP}} vendor/bin/phpstan analyse --memory-limit=256M {{.CLI_ARGS}}"
cache:clear:
desc: Clear application cache
deps: [ var, install ]
cmds:
- "{{.PHP}} bin/cache-clear.php"
test:
desc: Run unit tests without external services
cmds:
- "{{.PHP}} vendor/bin/phpunit --colors=never -c phpunit.xml {{.CLI_ARGS}}"
test:integration:
desc: Run integration tests against real PostgreSQL
deps: [ var, install ]
cmds:
- "{{.PHP}} vendor/bin/phpunit --colors=never -c phpunit.integration.xml {{.CLI_ARGS}}"
test:full:
desc: Run unit and integration tests
deps: [ test, test:integration ]
proto:gen:sdk:
desc: Generate PHP SDK classes from core proto files
cmds:
- rm -rf {{.SDK_GEN_DIR}}/*
- >
protoc -I={{.PROTO_DIR}}
--php_out={{.SDK_GEN_DIR}}
--php_opt=aggregate_metadata
{{.PROTO_DIR}}/app/v1/*.proto
{{.PROTO_DIR}}/google/api/*.proto
{{.PROTO_DIR}}/protoc-gen-openapiv2/options/*.proto
proto:gen:docs:
desc: Generate OpenAPI spec for the core template surface
cmds:
- rm -f {{.DOCS_GEN_DIR}}/api.swagger.json
- >
protoc -I={{.PROTO_DIR}}
--openapiv2_out=logtostderr=true:{{.DOCS_GEN_DIR}}
--openapiv2_opt=json_names_for_fields=true,allow_merge=true,merge_file_name=api
{{.PROTO_DIR}}/app/v1/*.proto
proto:gen:endpoints:
desc: Generate server-side endpoints and operation manifests from core protobuf services
deps: [ tools:proto:setup, install ]
cmds:
- rm -rf gen/Generated/Endpoint
- rm -rf gen/Generated/OperationManifest
- >
protoc -I={{.PROTO_DIR}}
--plugin=protoc-gen-php-endpoint=tools/protoc-php-gen/bin/protoc-php-gen.php
--php-endpoint_out=namespace=App\\Generated\\Endpoint,output_dir=gen,source_root=src,bootstrap=codegen/protoc-php-gen-bootstrap.php,endpoint_profile_class=ProjectCodegen\\Protobuf\\BaseApiTemplateEndpointProfile,generate_endpoints=true,generate_endpoint_validation=true,generate_operation_manifest=true:.
{{.PROTO_DIR}}/app/v1/*.proto
proto:gen:all:
desc: Generate the default protobuf-first runtime artifacts
cmds:
- task: proto:gen:sdk
- task: proto:gen:docs
- task: proto:gen:endpoints
sql:gen:
desc: Generate typed PHP query classes from SQL source files
deps: [ tools:sql:runtime:setup ]
cmds:
- mkdir -p sql/queries
- rm -rf gen/Generated/Sql
- >
php tools/sql-gen/bin/sql-gen.php
--input-dir=sql/queries
--output-dir=gen/Generated/Sql
--namespace=App\\Generated\\Sql
--schema=sql/schema.sql
--bootstrap=codegen/sql-gen-bootstrap.php
--profile-class=ProjectCodegen\\Sql\\BaseApiTemplateSqlGenerationProfile
sql:check:
desc: Validate SQL sources and ensure generated SQL artifacts are synchronized
deps: [ tools:sql:runtime:setup ]
cmds:
- mkdir -p sql/queries
- >
php tools/sql-gen/bin/sql-check.php
--input-dir=sql/queries
--output-dir=gen/Generated/Sql
--namespace=App\\Generated\\Sql
--schema=sql/schema.sql
--bootstrap=codegen/sql-gen-bootstrap.php
--profile-class=ProjectCodegen\\Sql\\BaseApiTemplateSqlGenerationProfile
sql:check:pg:
desc: Validate SQL queries against a live PostgreSQL database
deps: [ tools:sql:runtime:setup ]
cmds:
- mkdir -p sql/queries
- >
php tools/sql-gen/bin/sql-check-pg.php
--input-dir=sql/queries
--schema=sql/schema.sql
--db-host={{default "localhost" .DB_HOST}}
--db-port={{default "5432" .DB_PORT}}
--db-name={{default "app" .DB_NAME}}
--db-user={{default "app" .DB_USER}}
--db-password={{default "password" .DB_PASSWORD}}
tools:proto:setup:
desc: Setup protoc-php-gen plugin
cmds:
- cd tools/protoc-php-gen && {{.COMPOSER}} install
- chmod +x tools/protoc-php-gen/bin/protoc-php-gen.php
- echo "Proto code generator setup complete"
tools:proto:lint:
desc: Run PHP-CS-Fixer on the protoc-php-gen library
cmds:
- cd tools/protoc-php-gen && {{.COMPOSER}} cs
tools:proto:fixcs:
desc: Fix code style issues in the protoc-php-gen library
cmds:
- cd tools/protoc-php-gen && {{.COMPOSER}} cs-fix
tools:proto:phpstan:
desc: Run PHPStan on the protoc-php-gen library
cmds:
- cd tools/protoc-php-gen && {{.COMPOSER}} phpstan
tools:proto:test:
desc: Run PHP-CS-Fixer on the protoc-php-gen library
cmds:
- cd tools/protoc-php-gen && {{.COMPOSER}} test
tools:proto:check:
desc: Run all code quality checks on the protoc-php-gen library
cmds:
- cd tools/protoc-php-gen && {{.COMPOSER}} check
tools:sql:runtime:setup:
desc: Setup sql-gen runtime dependencies
sources:
- tools/sql-gen/composer.json
- tools/sql-gen/composer.lock
generates:
- tools/sql-gen/vendor/autoload.php
cmds:
- cd tools/sql-gen && {{.COMPOSER}} install --no-progress
- chmod +x tools/sql-gen/bin/sql-gen.php
- chmod +x tools/sql-gen/bin/sql-check-pg.php
- echo "SQL generator setup complete"
tools:sql:setup:
desc: Setup full sql-gen development environment
sources:
- tools/sql-gen/composer.json
- tools/sql-gen/composer.lock
generates:
- tools/sql-gen/vendor/bin/phpunit
cmds:
- cd tools/sql-gen && {{.COMPOSER}} install --no-progress
- chmod +x tools/sql-gen/bin/sql-gen.php
- chmod +x tools/sql-gen/bin/sql-check-pg.php
- echo "SQL generator development setup complete"
tools:sql:check:
desc: Run all code quality checks on the sql-gen library
deps: [ tools:sql:setup ]
cmds:
- cd tools/sql-gen && {{.COMPOSER}} check
# Performance tasks
perf:test:
desc: Run single performance test
deps: [ var, install ]
cmds:
- k6 run load-tests/scenarios/{{.CLI_ARGS | default "home.js"}}
perf:test:all:
desc: Run all performance tests
deps: [ var, install ]
cmds:
- for f in load-tests/scenarios/*.js; do k6 run "$f"; done
services:start:
desc: Start all application services
cmds:
- docker compose up -d
- echo "Waiting for services to be ready..."
- for i in $(seq 1 10); do
if docker compose exec -T db-postgres pg_isready -U app >/dev/null 2>&1; then
echo "Database is ready!";
break;
fi;
echo "Services not ready yet, retrying in 1 second...";
sleep 1;
done
- task: migrate
migrate:
desc: Run database migrations
deps: [ var, install ]
cmds:
- "{{.PHP}} bin/migrate.php"
services:stop:
desc: Stop all application services
cmds:
- docker compose stop
services:status:
desc: Check the status of all application services
cmds:
- docker compose ps
run:
desc: Start all required services and run the application with RoadRunner
deps: [ services:start ]
cmds:
- echo "Starting application with RoadRunner on http://localhost:8080..."
- rr serve -c .rr.yaml