-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generating PHP Unit coverage reports (#3911)
* Add logging for invalid IP issue * Clean up * Add test flag * Add changelog and readme entries * Remove unintended changes * Updating PHPUnit version to 9.4.4 * Generating coverage reports * Updating workflow * Fix coverage file path * Workflow update * Test commit * Setting env variable * Setting env variable * Test commit * Test commit * Revert unnecessary changes * Revert unnecessary changes * Test commit * Test commit * Test commit * Updating PHP unit version * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Test commit * Reverting unnecessary changes * Changelog and readme entries * Removing unnecessary conditions * Improving code coverage * Adding summary line * Adding headers * Adding headers * Fix summary * Fix header * Attempt to simplify * Fix headers * Including rule for tests without PHP files changed * Adding title * Improve coverage script titles * Improve coverage script titles * Improve coverage script titles * Improve coverage script titles * Removing testing method * Adding new PHP unit configuration file for the newer versions * Skipping execution if there are no changed files * Fix condition * Reverting unnecessary changes * Using env var for PHP version in workflow * Renaming cobertura XML file * Changing trigger + adding filter + skipping if comment is identical to previous * Improving PHP filters * Fix merge issues --------- Co-authored-by: Anne Mirasol <anne.mirasol@automattic.com>
- Loading branch information
1 parent
70fc5f8
commit cee0da3
Showing
9 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: PHP code coverage | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.php' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
name: PHP=8.1, WP=6.6, WC=9.1.2 | ||
env: | ||
PHP_VERSION: '8.1' | ||
WP_VERSION: '6.6' | ||
WC_VERSION: '9.1.2' | ||
steps: | ||
- name: Get Changed Files | ||
id: get-changed-files | ||
uses: hanseltimeindustries/get-changed-files@v1 | ||
with: | ||
format: 'space-delimited' | ||
filter: '**/*.php' | ||
|
||
- name: Checking out | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up dependencies caching | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/composer/ | ||
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ env.PHP_VERSION }} | ||
coverage: xdebug | ||
|
||
- name: Set up PHPUnit 9.5 | ||
run: wget https://phar.phpunit.de/phpunit-9.5.28.phar && mv phpunit-9.5.28.phar phpunit.phar | ||
|
||
- name: Run CI checks | ||
run: bash bin/run-ci-tests.bash | ||
|
||
- name: Code Coverage Report | ||
uses: irongut/CodeCoverageSummary@v1.3.0 | ||
with: | ||
filename: php-coverage.xml | ||
format: markdown | ||
hide_branch_rate: false | ||
hide_complexity: true | ||
indicators: true | ||
output: both | ||
thresholds: '60 80' | ||
|
||
- name: Filter Changed Files in Report | ||
run: | | ||
echo "### 📈 PHP Unit Code Coverage Report" > code-coverage-results-filtered.md | ||
echo "Package | Line Rate | Health" >> code-coverage-results-filtered.md | ||
echo "-------- | --------- | ------" >> code-coverage-results-filtered.md | ||
grep -E "$(echo ${{ steps.get-changed-files.outputs.all }} | tr ' ' '|')" code-coverage-results.md >> code-coverage-results-filtered.md | ||
tail -n1 code-coverage-results.md >> code-coverage-results-filtered.md | ||
- name: Add Coverage PR Comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: code-coverage | ||
recreate: true | ||
skip_unchanged: true | ||
path: code-coverage-results-filtered.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
bootstrap="tests/phpunit/bootstrap.php" | ||
backupGlobals="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
convertDeprecationsToExceptions="false" | ||
> | ||
<testsuites> | ||
<testsuite name="WCStripe"> | ||
<directory prefix="test-" suffix=".php">./tests/phpunit</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage cacheDirectory=".phpunit.cache/code-coverage"> | ||
<include> | ||
<file>./woocommerce-gateway-stripe.php</file> | ||
<directory>./includes</directory> | ||
</include> | ||
<report> | ||
<cobertura outputFile="php-coverage.xml"/> | ||
<html outputDirectory="phpunit-html"/> | ||
</report> | ||
</coverage> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters