Skip to content

Commit c8f8063

Browse files
author
jmsche
committed
Add Taskfile
1 parent a0b67f3 commit c8f8063

File tree

3 files changed

+148
-2
lines changed

3 files changed

+148
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
.phpunit.result.cache
3131
.phpunit.cache
3232
###< phpunit/phpunit ###
33+
34+
/.task

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ Or with Castor:
7575

7676
castor start
7777

78+
Or with Task:
79+
80+
task start
81+
7882
Open [https://127.0.0.1:8000](https://127.0.0.1:8000) (considering your 8000 port is free) and enjoy! 🙂
7983

8084

@@ -118,7 +122,8 @@ You can also directly use the [FrankenPHP](https://github.com/strangebuzz/MicroS
118122

119123
* The [Xdebug](https://xdebug.org/) PHP extension if you want to run the code coverage report
120124
* [Castor](https://github.com/jolicode/castor) task runner if you don't want to use
121-
[Make](https://www.gnu.org/software/make/) and its [Makefile](https://github.com/strangebuzz/MicroSymfony/blob/main/Makefile)
125+
[Make](https://www.gnu.org/software/make/) and its [Makefile](https://github.com/strangebuzz/MicroSymfony/blob/main/Makefile) or
126+
[Task](https://taskfile.dev/) and its [Taskfile](https://github.com/strangebuzz/MicroSymfony/blob/main/Taskfile.yaml)
122127

123128

124129
## Stack 🔗
@@ -137,9 +142,10 @@ to fix some issues as the project is not maintained anymore.
137142

138143
**MicroSymfony** ships these features, ready to use:
139144

140-
* Two task runners
145+
* Three task runners
141146
* [Make](https://www.gnu.org/software/make/) ([source](https://github.com/strangebuzz/MicroSymfony/blob/main/Makefile)) ([demo](https://www.strangebuzz.com/en/blog/introducing-the-microsymfony-application-template#h3_4_1))
142147
* [Castor](https://github.com/jolicode/castor) ([source](https://github.com/strangebuzz/MicroSymfony/blob/main/castor.php)) ([demo](https://www.strangebuzz.com/en/blog/introducing-the-microsymfony-application-template#h3_4_2))
148+
* [Task](https://taskfile.dev/) ([source](https://github.com/strangebuzz/MicroSymfony/blob/main/Taskfile.yaml))
143149
* Static analysis with [PHPStan 2](https://github.com/phpstan/phpstan)
144150
* [Configuration](https://github.com/strangebuzz/MicroSymfony/blob/main/phpstan.neon)
145151
* Coding standards with [php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)

Taskfile.yaml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
version: '3'
2+
3+
vars:
4+
# You can modify the coverage threshold here
5+
COVERAGE_THRESHOLD: 100
6+
7+
tasks:
8+
## —— Symfony binary 💻 ————————————————————————————————————————————————————————
9+
start:
10+
desc: Serve the application with the Symfony binary
11+
cmd: symfony serve --daemon
12+
13+
stop:
14+
desc: Stop the web server
15+
cmd: symfony server:stop
16+
17+
## —— Symfony 🎶 ——————————————————————————————————————————————————————————————
18+
go-prod:
19+
desc: Switch to the production environment
20+
cmds:
21+
- cp .env.local.dist .env.local
22+
# uncomment this line to optimize the auto-loading of classes in the prod env
23+
# - composer dump-autoload --no-dev --classmap-authoritative
24+
- bin/console asset-map:compile
25+
26+
go-dev:
27+
desc: Switch to the development environment
28+
cmds:
29+
- rm -f .env.local
30+
- rm -rf ./public/assets/*
31+
32+
warmup:
33+
desc: Warmup the dev cache for the static analysis
34+
cmd: bin/console c:w --env=dev
35+
36+
purge:
37+
desc: Purge all Symfony cache and logs
38+
cmd: rm -rf ./var/cache/* ./var/logs/* ./var/coverage/*
39+
40+
## —— Tests ✅ —————————————————————————————————————————————————————————————————
41+
test:
42+
desc: Run all PHPUnit tests
43+
cmd: vendor/bin/phpunit
44+
45+
coverage:
46+
desc: Generate the HTML PHPUnit code coverage report (stored in var/coverage)
47+
cmds:
48+
- task: purge
49+
- XDEBUG_MODE=coverage php -d xdebug.enable=1 -d memory_limit=-1 vendor/bin/phpunit --coverage-html=var/coverage --coverage-clover=var/coverage/clover.xml
50+
- php bin/coverage-checker.php var/coverage/clover.xml {{.COVERAGE_THRESHOLD}}
51+
52+
cov-report:
53+
desc: Open the PHPUnit code coverage report (var/coverage/index.html)
54+
cmd: open var/coverage/index.html
55+
preconditions:
56+
- test -f var/coverage/index.html
57+
58+
## —— Coding standards/lints ✨ ————————————————————————————————————————————————
59+
stan:
60+
desc: Run PHPStan
61+
cmds:
62+
- APP_DEBUG=1 APP_ENV=dev bin/console cache:warmup
63+
- vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv
64+
65+
fix-php:
66+
desc: Fix PHP files with php-cs-fixer (ignore PHP 8.2 warning)
67+
cmd: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix
68+
69+
lint-php:
70+
desc: Lint PHP files with php-cs-fixer (report only)
71+
cmd: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run
72+
73+
lint-container:
74+
desc: Lint the Symfony DI container
75+
cmd: bin/console lint:container
76+
77+
lint-twig:
78+
desc: Lint Twig files
79+
cmd: bin/console lint:twig templates/
80+
81+
lint-yaml:
82+
desc: Lint YAML files
83+
cmd: bin/console lint:yaml --parse-tags config/
84+
85+
cs:
86+
desc: Run all CS checks
87+
cmds:
88+
- task: fix-php
89+
- task: stan
90+
91+
lint:
92+
desc: Run all lints
93+
cmds:
94+
- task: lint-php
95+
- task: lint-container
96+
- task: lint-twig
97+
- task: lint-yaml
98+
99+
ci:
100+
desc: Run CI locally
101+
cmds:
102+
- task: coverage
103+
- task: warmup
104+
- task: cs
105+
- task: lint
106+
107+
## —— Other tools and helpers 🔨 ———————————————————————————————————————————————
108+
versions:
109+
desc: Display current stack versions
110+
cmds:
111+
- task: version-php
112+
- task: version-composer
113+
- task: version-symfony
114+
- task: version-phpunit
115+
- task: version-phpstan
116+
- task: version-php-cs-fixer
117+
version-php:
118+
desc: Display PHP version
119+
cmd: php -v
120+
version-composer:
121+
desc: Display Composer version
122+
cmd: composer --version
123+
version-symfony:
124+
desc: Display Symfony version
125+
cmd: bin/console --version
126+
version-phpunit:
127+
desc: Display PHPUnit version
128+
cmd: vendor/bin/phpunit --version
129+
version-phpstan:
130+
desc: Display PHPStan version
131+
cmd: vendor/bin/phpstan --version
132+
version-php-cs-fixer:
133+
desc: Display PHP CS Fixer version
134+
cmd: vendor/bin/php-cs-fixer --version
135+
136+
check-requirements:
137+
desc: Checks requirements for running Symfony
138+
cmd: vendor/bin/requirements-checker

0 commit comments

Comments
 (0)