Skip to content

Commit

Permalink
chore: revamp lint and fix tasks naming (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
COil authored Nov 26, 2024
1 parent f065865 commit 9456c4e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php-versions: ['8.3']
php-versions: ['8.2']
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
# Setup ————————————————————————————————————————————————————————————————
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
php-version: '8.2'
tools: cs2pr, castor
- uses: actions/checkout@v3
- name: Get Composer Cache Directory
Expand Down
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ SHELL = sh
## —— 🎶 The MicroSymfony Makefile 🎶 ——————————————————————————————————————————
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help start stop go-prod go-dev purge test coverage cov-report stan fix-php lint-php lint-container lint-twig lint-yaml cs lint ci deploy
.PHONY: help start stop go-prod go-dev purge test coverage cov-report stan fix-php lint-php lint-container lint-twig lint-yaml fix lint ci deploy
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements

# You can modify the coverage threshold here
# You can modify the code coverage threshold here
COVERAGE_THRESHOLD = 100

## —— Symfony binary 💻 ————————————————————————————————————————————————————————
Expand Down Expand Up @@ -51,14 +51,14 @@ cov-report: var/coverage/index.html ## Open the PHPUnit code coverage report (va


## —— Coding standards/lints ✨ ————————————————————————————————————————————————
stan: var/cache/dev/App_KernelDevDebugContainer.xml ## Run PHPStan
stan: var/cache/dev/App_KernelDevDebugContainer.xml ## Run the PHPStan static analysis
@vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv

# PHPStan needs the dev/debug cache
var/cache/dev/App_KernelDevDebugContainer.xml:
APP_DEBUG=1 APP_ENV=dev bin/console cache:warmup

fix-php: ## Fix PHP files with php-cs-fixer (ignore PHP 8.2 warning)
fix-php: ## Fix PHP files with php-cs-fixer (ignore PHP version warning)
@PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix $(PHP_CS_FIXER_ARGS)

lint-php: ## Lint PHP files with php-cs-fixer (report only)
Expand All @@ -74,14 +74,14 @@ lint-twig: ## Lint Twig files
lint-yaml: ## Lint YAML files
@bin/console lint:yaml --parse-tags config/

cs: ## Run all CS checks
cs: fix-php stan
fix: ## Run all fixers
fix: fix-php

lint: ## Run all lints
lint: lint-php lint-container lint-twig lint-yaml
lint: ## Run all linters
lint: stan lint-php lint-container lint-twig lint-yaml

ci: ## Run CI locally
ci: coverage warmup cs lint
ci: coverage warmup lint


## —— Other tools and helpers 🔨 ———————————————————————————————————————————————
Expand All @@ -103,15 +103,15 @@ version-phpstan:
@vendor/bin/phpstan --version
version-php-cs-fixer:
@echo '\n—— php-cs-fixer ———————————————————————————————————————————————————'
@vendor/bin/php-cs-fixer --version
@PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer --version
@echo

check-requirements: ## Checks requirements for running Symfony
@vendor/bin/requirements-checker


## —— Deploy & Prod 🚀 —————————————————————————————————————————————————————————
deploy: ## Simple manual deploy on VPS (this is to update the demo site https://microsymfony.ovh/)
deploy: ## Simple manual deploy on a VPS (this is to update the demo site https://microsymfony.ovh/)
@git pull
@composer install
@chown -R www-data: var/*
Expand Down
25 changes: 13 additions & 12 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,14 @@ function ci_lint_php(): int
);
}

#[AsTask(name: 'all', namespace: 'cs', description: 'Run all CS checks', aliases: ['cs'])]
#[AsTask(name: 'all', namespace: 'fix', description: 'Run all CS checks', aliases: ['fix'])]
function cs_all(): int
{
title('cs:all');
title('fix:all');
$ec1 = fix_php();
$ec2 = stan();
io()->newLine();

return success($ec1 + $ec2);
return success($ec1);
}
#[AsTask(name: 'container', namespace: 'lint', description: 'Lint the Symfony DI container', aliases: ['lint-container'])]
function lint_container(): int
Expand Down Expand Up @@ -217,12 +216,13 @@ function lint_yaml(): int
function lint_all(): int
{
title('lint:all');
$ec1 = lint_php();
$ec2 = lint_container();
$ec3 = lint_twig();
$ec4 = lint_yaml();
$ec1 = stan();
$ec2 = lint_php();
$ec3 = lint_container();
$ec4 = lint_twig();
$ec5 = lint_yaml();

return success($ec1 + $ec2 + $ec3 + $ec4);
return success($ec1 + $ec2 + $ec3 + $ec4 + $ec5);

// if you want to speed up the process, you can run these commands in parallel
// parallel(
Expand All @@ -240,8 +240,6 @@ function ci(): void
purge();
io()->section('Coverage');
coverage();
io()->section('Codings standards');
cs_all();
io()->section('Lints');
lint_all();
}
Expand Down Expand Up @@ -270,7 +268,10 @@ function versions(): void
io()->newLine();

io()->note('php-cs-fixer');
run('vendor/bin/php-cs-fixer --version');
exit_code('vendor/bin/php-cs-fixer --version',
context: context()->withEnvironment(['PHP_CS_FIXER_IGNORE_ENV' => 1])
);

io()->newLine();

success(0);
Expand Down

0 comments on commit 9456c4e

Please sign in to comment.