From 40c360f766c7dd286cf993ece6d02235c4a99c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 13 Aug 2026 10:10:15 +0200 Subject: [PATCH] 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%. --- .gitlab-ci.yml | 4 ++-- composer.json | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3f5f83..9e243c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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" diff --git a/composer.json b/composer.json index 769733a..7fb2e59 100644 --- a/composer.json +++ b/composer.json @@ -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/*",