Skip to content

Commit

Permalink
chore(coverage): coverage inside phpunit xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkuncakilkaya committed Sep 3, 2024
1 parent 6fcaae0 commit 3d81684
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Clear previous coverage data
run: rm -f cov/xml/clover-pr.xml cov/xml/clover-base.xml cov/xml/clover.xml
- name: PHPUnit for PR
run: docker-compose run phpunit --coverage-clover=cov/xml/clover.xml
run: docker-compose run phpunit
- name: Create coverage report for PR
id: pr_coverage
run: |
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- name: "Create Empty env File for Docker"
run: touch .env
- name: PHPUnit for Base
run: docker-compose run phpunit --coverage-clover=cov/xml/clover.xml
run: docker-compose run phpunit
- name: Create coverage report for Base
id: base_coverage
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: "Create Empty env File for Docker"
run: touch .env
- name: PHPUnit
run: docker-compose run phpunit --coverage-xml cov/xml --coverage-html cov/html --coverage-clover=cov/xml/clover.xml
run: docker-compose run phpunit
- name: "Parse Coverage"
run: "php ./coverage.php"
- name: Create Coverage Badges
Expand Down
14 changes: 7 additions & 7 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ To download fresh OpenAPI schema run `sh ./scripts/sync.sh`

To generate a code coverage report in markdown format, follow these steps:

1. Run PHPUnit with the `--coverage-clover` option to generate a coverage report in Clover XML format:
1. Run PHPUnit to generate a coverage report in Clover XML format:
```shell
docker-compose run phpunit --coverage-clover=cov/xml/clover.xml
docker-compose run phpunit
```
2. After generating the Clover XML file, run the coverage.php script to convert it into a markdown report:
2. After PHPUnit generates the Clover XML file in `cov/xml/clover.xml`, run the coverage.php script to convert it into a markdown report:
```shell
docker-compose run php php coverage.php
```

The markdown report will be saved in the cov/markdown/coverage_report.md file. You can open this file to review the coverage details.
The markdown report will be saved in the `cov/markdown/coverage_report.md` file. You can open this file to review the coverage details.

## Creating Coverage Report (HTML)

To generate a code coverage report in HTML format, just run this command:

Run PHPUnit with the `--coverage-html` option to generate a coverage report in Clover HTML format:
Run PHPUnit to generate a coverage report in HTML format:
```shell
docker-compose run phpunit --coverage-html=cov/html
docker-compose run phpunit
```

The html report will be saved in the cov/html directory. You can open this folder to review the coverage details.
The html report will be saved in the `cov/html` directory. You can open this folder to review the coverage details.

### Testing the local source code of the SDK

Expand Down
2 changes: 2 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<directory suffix=".php">./src</directory>
</include>
<report>
<xml outputDirectory="cov/xml" />
<clover outputFile="cov/xml/clover.xml" />
<html outputDirectory="cov/html" />
</report>
</coverage>
</phpunit>

0 comments on commit 3d81684

Please sign in to comment.