Skip to content

Commit

Permalink
feature: add a condition to make code coverage necessary to be over 8…
Browse files Browse the repository at this point in the history
…0% threshold
  • Loading branch information
jordimorillo committed May 8, 2024
1 parent 0907665 commit 1a68efd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/pull_request_phpunit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@ jobs:
- name: Ejecutar migraciones y seeds
run: php artisan migrate --seed

- name: Ejecutar pruebas unitarias
run: php artisan test
- name: Ejecutar pruebas unitarias y verificar cobertura
run: |
base_branch=develop
files_changed=$(git diff --name-only $base_branch)
phpunit --coverage-text --coverage-clover=coverage.xml --coverage-diff=coverage.diff ${files_changed[@]}
coverage=$(php -r '$xml = simplexml_load_file("coverage.xml"); echo $xml->project->metrics["coveredelements"];')
coverage_threshold=80
if [ "$coverage" -lt "$coverage_threshold" ]; then
echo "Error: Coverage over new and updated code should be over 80% (now $coverage%)."
exit 1
fi

0 comments on commit 1a68efd

Please sign in to comment.