Skip to content

Commit

Permalink
docs: publish code coverage (#422)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Oct 17, 2023
1 parent aeccfe6 commit 9001dad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
38 changes: 29 additions & 9 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ env:
PHP_VERSION_LATEST: "8.2"
PHP_PROJECT_EXT: dom,json,libxml # via `composer info -pt`
REPORTS_DIR: CI_reports
TESTS_REPORTS_ARTIFACT: tests-reports
TYPES_REPORTS_ARTIFACT: types-reports

jobs:
composer-validate:
Expand All @@ -43,8 +45,6 @@ jobs:
phpunit:
name: PHPUnit (${{ matrix.os}}, ${{ matrix.php }}, ${{ matrix.dependencies }})
runs-on: ${{ matrix.os }}
env:
REPORTS_ARTIFACT: tests-reports
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -117,22 +117,41 @@ jobs:
-d memory_limit=-1
tools/phpunit/vendor/phpunit/phpunit/phpunit
--no-progress
--log-junit=${{ env.REPORTS_DIR }}/tests.${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml
--coverage-clover=${{ env.REPORTS_DIR }}/coverage.${{ matrix.os}}_php${{ matrix.php }}_${{ matrix.dependencies }}.clover.xml
--log-junit='${{ env.REPORTS_DIR }}/tests/${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml'
--coverage-clover='${{ env.REPORTS_DIR }}/coverage/${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}.clover.xml'
- name: Artifact reports
if: ${{ ! cancelled() }}
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.REPORTS_ARTIFACT }}
name: ${{ env.TESTS_REPORTS_ARTIFACT }}
path: ${{ env.REPORTS_DIR }}
if-no-files-found: error
report-coverage:
name: Publish test coverage
needs: [ "phpunit" ]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: fetch test artifacts
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.TESTS_REPORTS_ARTIFACT }}
path: ${{ env.REPORTS_DIR }}
- name: Run codacy-coverage-reporter
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: ${{ env.CODACY_PROJECT_TOKEN != '' }} ## see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets
# see https://github.com/codacy/codacy-coverage-reporter-action
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ env.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ env.REPORTS_DIR }}/coverage/*.clover.xml
code-checker:
name: Code Analysis p${{ matrix.php }} c${{ matrix.composer }} ${{ matrix.dependencies }}
runs-on: ubuntu-latest
timeout-minutes: 30
env:
REPORTS_ARTIFACT: types-reports
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -198,14 +217,14 @@ jobs:
--no-cache
--long-progress
--php-version='${{ matrix.php }}'
--report='${{ env.REPORTS_DIR }}/psalm.php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml'
--report='${{ env.REPORTS_DIR }}/psalm/php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml'
--stats
- name: Artifact reports
if: ${{ ! cancelled() }}
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.REPORTS_ARTIFACT }}
name: ${{ env.TYPES_REPORTS_ARTIFACT }}
path: ${{ env.REPORTS_DIR }}
if-no-files-found: error
composer-unused:
Expand Down Expand Up @@ -364,3 +383,4 @@ jobs:
--no-update-lock
--no-interaction
$PWD/composer.json
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![shield_packagist-version]][link_packagist]
[![shield_gh-workflow-test]][link_gh-workflow-test]
[![shield_coverage]][link_codacy]
[![shield_ossf-best-practices]][link_ossf-best-practices]
[![shield_license]][license_file]
[![shield_website]][link_website]
Expand Down Expand Up @@ -121,13 +122,15 @@ See the [LICENSE][license_file] file for the full license.

[shield_gh-workflow-test]: https://img.shields.io/github/actions/workflow/status/CycloneDX/cyclonedx-php-composer/php.yml?branch=master&logo=GitHub&logoColor=white "build"
[shield_packagist-version]: https://img.shields.io/packagist/v/cyclonedx/cyclonedx-php-composer?logo=Packagist&logoColor=white "packagist"
[shield_coverage]: https://img.shields.io/codacy/coverage/30d812e89a8e429695ba1e4fc7969958?logo=Codacy&logoColor=white "test coverage"
[shield_ossf-best-practices]: https://img.shields.io/cii/level/7953?label=OpenSSF%20best%20practices "OpenSSF best practices"
[shield_license]: https://img.shields.io/github/license/CycloneDX/cyclonedx-php-composer?logo=open%20source%20initiative&logoColor=white "license"
[shield_website]: https://img.shields.io/badge/https://-cyclonedx.org-blue.svg "homepage"
[shield_slack]: https://img.shields.io/badge/slack-join-blue?logo=Slack&logoColor=white "slack join"
[shield_groups]: https://img.shields.io/badge/discussion-groups.io-blue.svg "groups discussion"
[shield_twitter-follow]: https://img.shields.io/badge/Twitter-follow-blue?logo=Twitter&logoColor=white "twitter follow"
[link_gh-workflow-test]: https://github.com/CycloneDX/cyclonedx-php-composer/actions/workflows/php.yml?query=branch%3Amaster
[link_codacy]: https://app.codacy.com/gh/CycloneDX/cyclonedx-php-composer
[link_ossf-best-practices]: https://www.bestpractices.dev/projects/7953
[link_packagist]: https://packagist.org/packages/cyclonedx/cyclonedx-php-composer
[link_website]: https://cyclonedx.org/
Expand Down

0 comments on commit 9001dad

Please sign in to comment.