Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature branch: add Taskfile #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@
.phpunit.result.cache
.phpunit.cache
###< phpunit/phpunit ###

/.task
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Or with Castor:

castor start

Or with Task:

task start

Open [https://127.0.0.1:8000](https://127.0.0.1:8000) (considering your 8000 port is free) and enjoy! 🙂


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

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


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

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

* Two task runners
* Three task runners
* [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))
* [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))
* [Task](https://taskfile.dev/) ([source](https://github.com/strangebuzz/MicroSymfony/blob/main/Taskfile.yaml))
* Static analysis with [PHPStan 2](https://github.com/phpstan/phpstan)
* [Configuration](https://github.com/strangebuzz/MicroSymfony/blob/main/phpstan.neon)
* Coding standards with [php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
Expand Down
138 changes: 138 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
version: '3'

vars:
# You can modify the coverage threshold here
COVERAGE_THRESHOLD: 100

tasks:
## —— Symfony binary 💻 ————————————————————————————————————————————————————————
start:
desc: Serve the application with the Symfony binary
cmd: symfony serve --daemon

stop:
desc: Stop the web server
cmd: symfony server:stop

## —— Symfony 🎶 ——————————————————————————————————————————————————————————————
go-prod:
desc: Switch to the production environment
cmds:
- cp .env.local.dist .env.local
# uncomment this line to optimize the auto-loading of classes in the prod env
# - composer dump-autoload --no-dev --classmap-authoritative
- bin/console asset-map:compile

go-dev:
desc: Switch to the development environment
cmds:
- rm -f .env.local
- rm -rf ./public/assets/*

warmup:
desc: Warmup the dev cache for the static analysis
cmd: bin/console c:w --env=dev

purge:
desc: Purge all Symfony cache and logs
cmd: rm -rf ./var/cache/* ./var/logs/* ./var/coverage/*

## —— Tests ✅ —————————————————————————————————————————————————————————————————
test:
desc: Run all PHPUnit tests
cmd: vendor/bin/phpunit

coverage:
desc: Generate the HTML PHPUnit code coverage report (stored in var/coverage)
cmds:
- task: purge
- 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
- php bin/coverage-checker.php var/coverage/clover.xml {{.COVERAGE_THRESHOLD}}

cov-report:
desc: Open the PHPUnit code coverage report (var/coverage/index.html)
cmd: open var/coverage/index.html
preconditions:
- test -f var/coverage/index.html

## —— Coding standards/lints ✨ ————————————————————————————————————————————————
stan:
desc: Run PHPStan
cmds:
- APP_DEBUG=1 APP_ENV=dev bin/console cache:warmup
- vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv

fix-php:
desc: Fix PHP files with php-cs-fixer (ignore PHP 8.2 warning)
cmd: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix

lint-php:
desc: Lint PHP files with php-cs-fixer (report only)
cmd: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run

lint-container:
desc: Lint the Symfony DI container
cmd: bin/console lint:container

lint-twig:
desc: Lint Twig files
cmd: bin/console lint:twig templates/

lint-yaml:
desc: Lint YAML files
cmd: bin/console lint:yaml --parse-tags config/

cs:
desc: Run all CS checks
cmds:
- task: fix-php
- task: stan

lint:
desc: Run all lints
cmds:
- task: lint-php
- task: lint-container
- task: lint-twig
- task: lint-yaml

ci:
desc: Run CI locally
cmds:
- task: coverage
- task: warmup
- task: cs
- task: lint

## —— Other tools and helpers 🔨 ———————————————————————————————————————————————
versions:
desc: Display current stack versions
cmds:
- task: version-php
- task: version-composer
- task: version-symfony
- task: version-phpunit
- task: version-phpstan
- task: version-php-cs-fixer
version-php:
desc: Display PHP version
cmd: php -v
version-composer:
desc: Display Composer version
cmd: composer --version
version-symfony:
desc: Display Symfony version
cmd: bin/console --version
version-phpunit:
desc: Display PHPUnit version
cmd: vendor/bin/phpunit --version
version-phpstan:
desc: Display PHPStan version
cmd: vendor/bin/phpstan --version
version-php-cs-fixer:
desc: Display PHP CS Fixer version
cmd: vendor/bin/php-cs-fixer --version

check-requirements:
desc: Checks requirements for running Symfony
cmd: vendor/bin/requirements-checker