Skip to content
Merged
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
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ APP_SECRET=
# To test the production environment, run "make go-prod" or "castor symfony:go-prod"

# To come back to the development environment, run "make go-dev" or "castor symfony:go-dev"

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
###< doctrine/doctrine-bundle ###
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ warmup: ## Warmup the dev cache for the static analysis
purge: ## Purge all Symfony cache and logs
@rm -rf ./var/cache/* ./var/log/* ./var/coverage/*

load-fixtures: ## Reset migrations and load the database fixtures
@rm -f ./var/data.db
@bin/console doctrine:migrations:migrate --env=dev --no-interaction
@bin/console foundry:load-fixtures --env=dev --no-interaction


## —— Tests ✅ —————————————————————————————————————————————————————————————————
test: ## Run tests with optional suite, filter and options (to debug use "make test options=--debug")
Expand Down Expand Up @@ -69,7 +74,7 @@ test-unit: testsuite=unit
test-unit: test

coverage: ## Generate the HTML PHPUnit code coverage report (stored in var/coverage)
coverage: purge
coverage: purge load-fixtures
@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)

Expand Down Expand Up @@ -107,11 +112,14 @@ lint-container: ## Lint the Symfony DI container
lint-twig: ## Lint Twig files
@bin/console lint:twig templates/

lint-doctrine: ## Validate Doctrine schema
@bin/console doctrine:schema:validate

fix: ## Run all fixers
fix: fix-php fix-js-css

lint: ## Run all linters
lint: stan lint-php lint-js-css lint-container lint-twig
lint: stan lint-php lint-doctrine lint-js-css lint-container lint-twig

ci: ## Run CI locally
ci: coverage warmup lint
Expand Down
33 changes: 29 additions & 4 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ function purge(): void
success(exit_code('rm -rf ./var/cache/* ./var/log/* ./var/coverage/*'));
}

#[AsTask(namespace: 'app', description: 'Load the database fixtures', aliases: ['load-fixtures'])]
function loadFixtures(): void
{
title('app:load-fixtures');
io()->note('Resetting db...');
success(exit_code('rm -f ./var/data.db'));
io()->note('Running db migrations...');
success(exit_code('bin/console doctrine:migrations:migrate --no-interaction'));
io()->note('Load fixtures...');
success(exit_code('bin/console foundry:load-fixtures --env=dev --no-interaction'));
}

const PHP_UNIT_CMD = '/vendor/bin/phpunit --testsuite=%s --filter=%s %s';
const PHP_UNIT_SUITES = ['api', 'e2e', 'functional', 'integration', 'unit'];

Expand All @@ -111,6 +123,7 @@ function getParameters(): array
function test_all(): int
{
title('test:all');
loadFixtures();
[$filter, $options] = getParameters();
$ec = exit_code(__DIR__.sprintf(PHP_UNIT_CMD, implode(',', PHP_UNIT_SUITES), $filter, $options));
io()->writeln('');
Expand Down Expand Up @@ -177,6 +190,7 @@ function test_unit(
function coverage(): int
{
title('test:coverage');
loadFixtures();
$ec = exit_code('php -d xdebug.enable=1 -d memory_limit=-1 vendor/bin/phpunit --coverage-html=var/coverage --coverage-clover=var/coverage/clover.xml',
context: context()->withEnvironment(['XDEBUG_MODE' => 'coverage'])
);
Expand Down Expand Up @@ -316,21 +330,31 @@ function lint_twig(): int
return exit_code('bin/console lint:twig templates/');
}

#[AsTask(name: 'doctrine', namespace: 'lint', description: 'Validate Doctrine schema', aliases: ['lint-doctrine'])]
function lint_doctrine(): int
{
title('lint:doctrine');

return exit_code('@bin/console doctrine:schema:validate');
}

#[AsTask(name: 'all', namespace: 'lint', description: 'Run all lints', aliases: ['lint'])]
function lint_all(): int
{
title('lint:all');
$ec1 = stan();
$ec2 = lint_php();
$ec3 = lint_js_css();
$ec4 = lint_container();
$ec5 = lint_twig();
$ec3 = lint_doctrine();
$ec4 = lint_js_css();
$ec5 = lint_container();
$ec6 = lint_twig();

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

// if you want to speed up the process, you can run these commands in parallel
// parallel(
// fn() => lint_php(),
// fn() => lint_doctrine(),
// fn() => lint_container(),
// fn() => lint_twig(),
// );
Expand All @@ -341,6 +365,7 @@ function ci(): void
{
title('ci:all');
purge();
loadFixtures();
io()->section('Coverage');
coverage();
io()->section('Lints');
Expand Down
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"doctrine/dbal": "^4.0",
"doctrine/doctrine-bundle": "^3.0",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.3",
"league/commonmark": "^2.4",
"symfony/asset": "~8.0.0",
"symfony/asset-mapper": "~8.0.0",
Expand Down Expand Up @@ -61,7 +65,8 @@
"symfony/maker-bundle": "^1.61",
"symfony/requirements-checker": "^2.0",
"symfony/stopwatch": "~8.0.0",
"symfony/web-profiler-bundle": "~8.0.0"
"symfony/web-profiler-bundle": "~8.0.0",
"zenstruck/foundry": "^2.4"
},
"replace": {
"symfony/polyfill-ctype": "*",
Expand Down Expand Up @@ -97,7 +102,10 @@
},
"platform": {
},
"sort-packages": true
"sort-packages": true,
"audit": {
"block-insecure": false
}
},
"extra": {
"bamarni-bin": {
Expand Down
Loading