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

Set up code coverage for unit tests #321

Merged
merged 51 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0ea42ec
Set up code coverage for unit tests
swissspidy Nov 8, 2023
fa98055
Update job name
swissspidy Nov 8, 2023
5da9e41
Fix condition
swissspidy Nov 8, 2023
d0cfe8f
test
swissspidy Nov 8, 2023
413a350
Remove step
swissspidy Nov 8, 2023
258a9eb
Remove space
swissspidy Nov 8, 2023
123c17c
Fix expression
swissspidy Nov 8, 2023
30d6da1
fix condition
swissspidy Nov 8, 2023
52d8df5
Merge steps
swissspidy Nov 8, 2023
aea7f93
Add pre script
swissspidy Nov 8, 2023
fa13109
Set xdebug mode
swissspidy Nov 8, 2023
a76bebb
Update wp-env
swissspidy Nov 8, 2023
dae7bce
Update commands
swissspidy Nov 8, 2023
1b576ab
Add `run`
swissspidy Nov 8, 2023
dabee69
Another one
swissspidy Nov 8, 2023
ed8d933
Fix wp-env and scripts
swissspidy Nov 9, 2023
627fb06
Update phpunit config
swissspidy Nov 9, 2023
1226382
Further update phpunit config
swissspidy Nov 9, 2023
20c1782
Undo exclude
swissspidy Nov 9, 2023
0c9e4af
Fix multisite config
swissspidy Nov 9, 2023
b88df7e
Update lock file
swissspidy Nov 9, 2023
af49877
Fix relative paths
swissspidy Nov 9, 2023
53fc7f1
Update phpunit if needed
swissspidy Nov 9, 2023
355860b
Do nothing on PHP 7.0
swissspidy Nov 9, 2023
6d88d5e
Move to build-cs
swissspidy Nov 10, 2023
b568cdd
Fix config file paths
swissspidy Nov 10, 2023
ebb86af
Undo exclude
swissspidy Nov 10, 2023
111b572
Fix behat script path
swissspidy Nov 10, 2023
eb49dcf
partial revert
swissspidy Nov 10, 2023
eb4216f
Undo path change
swissspidy Nov 13, 2023
82477bb
Install in container
swissspidy Nov 13, 2023
f10b8c7
Fix path
swissspidy Nov 13, 2023
e0c9b02
Need dev autoloader
swissspidy Nov 13, 2023
79aeb17
Only dump autoloader
swissspidy Nov 14, 2023
207b022
Require other autoloader
swissspidy Nov 14, 2023
225b0ff
Ignore reqs
swissspidy Nov 14, 2023
dad96e0
prefer lowest
swissspidy Nov 14, 2023
fccbf2c
use separate dir for phpunit
swissspidy Nov 14, 2023
7435ad0
Update autoload
swissspidy Nov 14, 2023
5679b6a
Install no-dev
swissspidy Nov 14, 2023
87ee235
Make error message more obvious
swissspidy Nov 14, 2023
c24cad2
Add codecov config file
swissspidy Nov 14, 2023
61e8b11
Improve phpunit folder structure
swissspidy Nov 14, 2023
9c8e884
Undo testdata move
swissspidy Nov 14, 2023
af20298
Update autoload path again
swissspidy Nov 14, 2023
3f883db
Add whitespace
swissspidy Nov 14, 2023
847a09a
Undo change
swissspidy Nov 14, 2023
d1c21c3
Update another path
swissspidy Nov 14, 2023
d5f5a55
Move other tests too
swissspidy Nov 14, 2023
d417e87
Fix some paths
swissspidy Nov 14, 2023
9222e1a
Address some dynamic property creation warnings
swissspidy Nov 14, 2023
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
36 changes: 27 additions & 9 deletions .github/workflows/php-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ concurrency:

jobs:
php-test:
name: PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}${{ matrix.experimental && ' (experimental)' || '' }}
name: PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}${{ matrix.experimental && ' (experimental)' || '' }}${{ matrix.coverage && ' (with coverage)' || '' }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
Expand All @@ -55,9 +55,11 @@ jobs:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
wordpress: [ 'latest' ]
include:
- php: '8.2'
wordpress: 'latest'
coverage: true
- php: '8.2'
wordpress: 'trunk'
experimental: true
Expand All @@ -70,7 +72,7 @@ jobs:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v3
with:
Expand All @@ -80,11 +82,27 @@ jobs:
- name: npm install
run: npm ci

- name: Install WordPress
run: npm run wp-env start
- name: Start WordPress
run: |
if [[ ${{ matrix.coverage == true }} == true ]]; then
npm run wp-env start -- --xdebug=coverage
else
npm run wp-env start
fi

- name: Running php unit tests
run: npm run test-php
- name: Run tests
run: |
if [[ ${{ matrix.coverage == true }} == true ]]; then
npm run test-php-coverage
npm run test-php-multisite-coverage
else
npm run test-php
npm run test-php-multisite
fi

- name: Running multisite unit tests
run: npm run test-php-multisite
- name: Upload code coverage report
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
with:
file: build/logs/*.xml
flags: unit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ build
node_modules/
vendor/
build-cs/vendor/
build-cs/composer.lock
build-phpunit/vendor/
build-phpunit/composer.lock

############
## OSes
Expand Down
5 changes: 1 addition & 4 deletions build-cs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "^2.9",
"phpstan/phpstan": "^1.10",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.10",
"slevomat/coding-standard": "^8.9",
"szepeviktor/phpstan-wordpress": "^1.1",
"wp-coding-standards/wpcs": "^3.0.0"
Expand All @@ -13,9 +13,6 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
},
"platform": {
"php": "8.0"
}
}
}
Loading