From 33e6f1fec499554cd9c5336c83d28435db395ad2 Mon Sep 17 00:00:00 2001 From: pattonwebz Date: Thu, 21 Mar 2024 16:24:54 +0000 Subject: [PATCH 1/4] Add coverage locations to phpunit config --- phpunit.dev.xml | 10 ++++++++++ phpunit.xml.dist | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/phpunit.dev.xml b/phpunit.dev.xml index 8708070b..4e58c547 100644 --- a/phpunit.dev.xml +++ b/phpunit.dev.xml @@ -12,4 +12,14 @@ ./tests/ + + + ./ + + + ./tests/ + ./vendor/ + ./node_modules/ + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e8e85609..907e701f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,4 +12,14 @@ ./tests/ + + + ./ + + + ./tests/ + ./vendor/ + ./node_modules/ + + From ab5732156e41664170037028134febde96056c9b Mon Sep 17 00:00:00 2001 From: pattonwebz Date: Fri, 29 Mar 2024 19:56:32 +0000 Subject: [PATCH 2/4] Ignore the dist directory when doing coverage reports This directory won't always exist but it sometimes does in local envs --- phpunit.dev.xml | 1 + phpunit.xml.dist | 1 + 2 files changed, 2 insertions(+) diff --git a/phpunit.dev.xml b/phpunit.dev.xml index 4e58c547..76a92067 100644 --- a/phpunit.dev.xml +++ b/phpunit.dev.xml @@ -20,6 +20,7 @@ ./tests/ ./vendor/ ./node_modules/ + ./dist/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 907e701f..bf65d8e2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,6 +20,7 @@ ./tests/ ./vendor/ ./node_modules/ + ./dist/ From 94178182b3cfe614672d077818223de26833efa4 Mon Sep 17 00:00:00 2001 From: pattonwebz Date: Fri, 29 Mar 2024 19:57:10 +0000 Subject: [PATCH 3/4] Add a workflow to generate coverage reports and push them into coveralls --- .../workflows/code-coverage-and-coveralls.yml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/code-coverage-and-coveralls.yml diff --git a/.github/workflows/code-coverage-and-coveralls.yml b/.github/workflows/code-coverage-and-coveralls.yml new file mode 100644 index 00000000..da22dae9 --- /dev/null +++ b/.github/workflows/code-coverage-and-coveralls.yml @@ -0,0 +1,50 @@ +name: Coverage Report + +on: + push: + branches: [ develop ] + pull_request: + branches: [ main ] + pull_request_target: # this is added just to test this workflow on the PR that adds it + branches: [ develop ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: xdebug + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Run PHPUnit and generate reports in clover and html format + run: ./vendor/bin/phpunit --coverage-clover=./coverage/clover.xml --coverage-html=./coverage/html + + - name: Zip html coverage report + run: | + zip -r ./coverage/coverage-html.zip ./coverage/html + + - name : Attach zipped coverage report as workflow artifact + uses: actions/upload-artifact@v2 + with: + name: coverage-html + path: ./coverage/coverage-html.zip + + - name: Convert coverage clover format to Coveralls format + run: | + composer global require php-coveralls/php-coveralls + ~/.composer/vendor/bin/php-coveralls -v -x ./coverage/clover.xml -o ./coverage/coveralls.json + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ./coverage/coveralls.json From 43d87df3e1151b7ccf04e9a94e422c8bf819990d Mon Sep 17 00:00:00 2001 From: pattonwebz Date: Fri, 29 Mar 2024 20:53:13 +0000 Subject: [PATCH 4/4] Remove the pull_request_target trigger in workflow for coverage tests --- .github/workflows/code-coverage-and-coveralls.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/code-coverage-and-coveralls.yml b/.github/workflows/code-coverage-and-coveralls.yml index da22dae9..b2406c9f 100644 --- a/.github/workflows/code-coverage-and-coveralls.yml +++ b/.github/workflows/code-coverage-and-coveralls.yml @@ -5,8 +5,6 @@ on: branches: [ develop ] pull_request: branches: [ main ] - pull_request_target: # this is added just to test this workflow on the PR that adds it - branches: [ develop ] jobs: test: