ci: add test coverage command to composer scripts

This change introduces a new command for running tests with coverage
threshold set to a minimum of 85%.
This commit is contained in:
Jérémy Munsch 2026-08-13 10:10:15 +02:00
parent 554e4002df
commit 40c360f766
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
2 changed files with 6 additions and 2 deletions

View file

@ -115,7 +115,7 @@ tests_laravel:
- cp .env.testing .env
- php artisan key:generate
- php artisan config:clear
- php artisan test --coverage --colors=never --log-junit=coverage/junit.xml --coverage-cobertura=coverage/cobertura.xml --coverage-html=coverage/html
- php artisan test --coverage --min=85 --colors=never --log-junit=coverage/junit.xml --coverage-cobertura=coverage/cobertura.xml --coverage-html=coverage/html
after_script:
- if [ "$CI_JOB_STATUS" == "failed" ]; then cat storage/logs/laravel.log; fi
artifacts:
@ -128,7 +128,7 @@ tests_laravel:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura.xml
coverage: '/Statement coverage[A-Za-z\.*]\s*:\s*([^%]+)/'
coverage: '/^\s*Total:\s*([\d\.]+)%/'
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "trunk" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main"

View file

@ -66,6 +66,10 @@
"@php artisan config:clear --ansi @no_additional_args",
"@php artisan test"
],
"test:coverage": [
"@php artisan config:clear --ansi @no_additional_args",
"@php artisan test --coverage --min=85"
],
"lint": [
"vendor/bin/parallel-lint --exclude vendor --exclude storage --exclude bootstrap --exclude node_modules .",
"vendor/bin/phpcs --standard=phpcs.xml --extensions=php --ignore=vendor/*,storage/*,bootstrap/*,node_modules/*",