Skip to content

Commit

Permalink
Added test coverage support to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Mar 14, 2024
1 parent b8bd724 commit 19bab9b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
25 changes: 20 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,30 @@ jobs:
name: Lint code
command: docker compose exec phpserver composer lint
- run:
name: Run tests
command: docker compose exec phpserver composer test
name: Run tests with PHPUnit
command: |
XDEBUG_ENABLE=true docker compose up -d phpserver
docker compose exec -T -e XDEBUG_MODE=coverage phpserver vendor/bin/phpunit
docker compose up -d phpserver
- run:
name: Run tests with Behat
command: docker compose exec phpserver vendor/bin/behat
- run:
name: Copy artifacts
name: Process test logs and artifacts
command: |
mkdir -p "/tmp/test_results" && docker compose cp phpserver:/app/.logs/test_results/. "/tmp/test_results/"
mkdir -p "/tmp/artifacts" && docker compose cp phpserver:/app/.logs/. "/tmp/artifacts/"
mkdir -p /tmp/test_results
mkdir -p /tmp/artifacts
if docker compose ps --services --filter "status=running" | grep -q phpserver && docker compose exec phpserver test -d /app/.logs; then
docker compose cp phpserver:/app/.logs/. "/tmp/artifacts/"
if docker compose exec -T phpserver sh -c 'test -d /app/.logs/test_results'; then
docker compose cp phpserver:/app/.logs/test_results/. "/tmp/test_results/"
fi
fi
when: always
- store_test_results:
path: /tmp/test_results
- store_artifacts:
path: /tmp/artifacts
- run:
name: Upload code coverage reports to Codecov
command: if [ -d /tmp/artifacts/coverage ]; then codecov -Z -s /tmp/artifacts/coverage; fi
28 changes: 16 additions & 12 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Ignore files for distribution archives.

/.circleci export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/behat.yml export-ignore
/docker-compose.yml export-ignore
/docs export-ignore
/phpcs.xml export-ignore
/phpmd.xml export-ignore
/phpstan.neon export-ignore
/tests export-ignore
/.circleci export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/behat.yml export-ignore
/docker-compose.override.default.yml export-ignore
/docker-compose.yml export-ignore
/docs export-ignore
/phpcs.xml export-ignore
/phpmd.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/rector.php export-ignore
/renovate.json export-ignore
/tests export-ignore
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# To ignore OS temporary files use global .gitignore
# https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer

/.build
/.coverage-html
/.logs
/.phpunit.cache
/cobertura.xml
/composer.lock
/docker-compose.override.yml
/screenshots
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![GitHub Issues](https://img.shields.io/github/issues/drevops/behat-screenshot.svg)](https://github.com/drevops/behat-screenshot/issues)
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/drevops/behat-screenshot.svg)](https://github.com/drevops/behat-screenshot/pulls)
[![CircleCI](https://circleci.com/gh/drevops/behat-screenshot.svg?style=shield)](https://circleci.com/gh/drevops/behat-screenshot)
[![codecov](https://codecov.io/gh/drevops/behat-screenshot/graph/badge.svg?token=UN930S8FGC)](https://codecov.io/gh/drevops/behat-screenshot)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/drevops/behat-screenshot)
![LICENSE](https://img.shields.io/github/license/drevops/behat-screenshot)
![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot)
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="false">
<report>
<html outputDirectory=".coverage-html" lowUpperBound="50" highLowerBound="90"/>
<cobertura outputFile="cobertura.xml"/>
<html outputDirectory=".logs/coverage/phpunit/.coverage-html" lowUpperBound="50" highLowerBound="90"/>
<cobertura outputFile=".logs/coverage/phpunit/cobertura.xml"/>
</report>
</coverage>
</phpunit>

0 comments on commit 19bab9b

Please sign in to comment.