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

feat: better coverage threshold handling #73

Merged
merged 2 commits into from
Oct 6, 2024
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
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ help: ## Outputs this help screen
.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: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements

# You can modify the coverage threshold here
COVERAGE_THRESHOLD = 100

## —— Symfony binary 💻 ————————————————————————————————————————————————————————
start: ## Serve the application with the Symfony binary
@symfony serve --daemon
Expand Down Expand Up @@ -41,7 +44,7 @@ test: ## Run all PHPUnit tests
coverage: ## Generate the HTML PHPUnit code coverage report (stored in var/coverage)
coverage: 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 100
@php bin/coverage-checker.php var/coverage/clover.xml $(COVERAGE_THRESHOLD)

cov-report: var/coverage/index.html ## Open the PHPUnit code coverage report (var/coverage/index.html)
@open var/coverage/index.html
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ to fix some issues as the project is not maintained anymore.
* Functional test [example](https://github.com/strangebuzz/MicroSymfony/blob/main/tests/Functional/Controller/HelloWorldTest.php)
* API test [example](https://github.com/strangebuzz/MicroSymfony/blob/main/tests/Api/Controller/SlugifyActionTest.php)
* E2E test [example](https://github.com/strangebuzz/MicroSymfony/blob/main/tests/E2E/Controller/AppControllerTest.php)
* Code coverage at 100%
* Code coverage at 100% (configurable threshold)
* [Output on CI](https://github.com/strangebuzz/MicroSymfony/actions/runs/8070913583/job/22049355015)
* GitHub CI ([actions](https://github.com/strangebuzz/MicroSymfony/actions))
* [Tests job output](https://github.com/strangebuzz/MicroSymfony/actions/runs/8070913583/job/22049355015)
Expand Down
5 changes: 4 additions & 1 deletion castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

// use function Castor\parallel;

// You can modify the coverage threshold here
const COVERAGE_THRESHOLD = 100;

function title(string $name): void
{
$task = task();
Expand Down Expand Up @@ -113,7 +116,7 @@ function coverage(): int
return $ec;
}

return success(exit_code('php bin/coverage-checker.php var/coverage/clover.xml 100', quiet: false));
return success(exit_code(sprintf('php bin/coverage-checker.php var/coverage/clover.xml %d', COVERAGE_THRESHOLD), quiet: false));
}

#[AsTask(namespace: 'test', description: 'Open the PHPUnit code coverage report (var/coverage/index.html)', aliases: ['cov-report'])]
Expand Down
Loading