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

Added test coverage support to CI. #100

Merged
merged 1 commit into from
Mar 14, 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
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>