Skip to content

Commit ec683f2

Browse files
committed
CI: Add code coverage
1 parent ca94a68 commit ec683f2

File tree

5 files changed

+62
-29
lines changed

5 files changed

+62
-29
lines changed

.github/workflows/integrations.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,17 @@ jobs:
8484
run: composer prepare-ci --no-interaction
8585

8686
- name: Run integration tests
87+
if: ${{ matrix.coverage == false }}
8788
run: composer test --no-interaction
89+
90+
- name: Run integration tests with code coverage
91+
if: ${{ matrix.coverage == true }}
92+
run: composer coverage-ci --no-interaction
93+
94+
- name: Send coverage report to Codecov
95+
if: ${{ success() && matrix.coverage == true }}
96+
uses: codecov/codecov-action@v3
97+
with:
98+
files: ./clover.xml
99+
fail_ci_if_error: true
100+
verbose: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/.phpunit.result.cache
1+
/.phpunit.cache
2+
/clover.xml
23
/composer.lock
34
/package-lock.json
45
/vendor

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@php ./vendor/bin/phpcbf"
3434
],
3535
"coverage": [
36-
"@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html"
36+
"@php ./vendor/bin/phpunit --coverage-html ./.phpunit.cache/coverage-html"
3737
],
3838
"coverage-ci": [
3939
"@php ./vendor/bin/phpunit"

phpunit.xml.dist

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
5-
bootstrap="./tests/Integration/bootstrap.php"
6-
backupGlobals="false"
7-
beStrictAboutCoversAnnotation="true"
8-
beStrictAboutTestsThatDoNotTestAnything="true"
9-
colors="true"
10-
convertDeprecationsToExceptions="true"
11-
testdox="true"
12-
>
13-
<php>
14-
<server name="SERVER_PORT" value="80"/>
15-
<server name="HTTP_HOST" value="localhost"/>
16-
<server name="REMOTE_ADDR" value="127.0.0.1"/>
17-
</php>
18-
<testsuites>
19-
<testsuite name="integration">
20-
<directory>./tests/Integration</directory>
21-
</testsuite>
22-
</testsuites>
23-
<coverage>
24-
<include>
25-
<directory suffix=".php">src</directory>
26-
<file>ad-code-manager.php</file>
27-
</include>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="./tests/Integration/bootstrap.php"
5+
cacheResultFile=".phpunit.cache/test-results"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="false"
8+
beStrictAboutCoversAnnotation="true"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
colors="true"
12+
convertDeprecationsToExceptions="true"
13+
failOnRisky="true"
14+
failOnWarning="true"
15+
testdox="true"
16+
verbose="true">
17+
<testsuites>
18+
<testsuite name="integration">
19+
<directory>tests/Integration</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
24+
processUncoveredFiles="true">
25+
<include>
26+
<directory suffix=".php">src</directory>
27+
</include>
2828
<report>
2929
<text outputFile="php://stdout"/>
30+
<clover outputFile="clover.xml"/>
3031
</report>
31-
</coverage>
32+
</coverage>
3233
</phpunit>

tests/Integration/UI/PluginActionsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ final class PluginActionsTest extends TestCase {
2222
* Check that plugins screen will add a hook to change the plugin action links.
2323
*
2424
* @covers \Automattic\AdCodeManager\UI\Plugin_Actions::run
25+
* @uses ACM_Provider::__construct
26+
* @uses Ad_Code_Manager::action_init
27+
* @uses Ad_Code_Manager::action_load_providers
28+
* @uses Ad_Code_Manager::get_ad_codes
29+
* @uses Ad_Code_Manager::get_option
30+
* @uses Ad_Code_Manager::get_options
31+
* @uses Ad_Code_Manager::register_acm_post_type
32+
* @uses Ad_Code_Manager::register_ad_codes
33+
* @uses Doubleclick_For_Publishers_ACM_Provider::__construct
2534
* @group ui
2635
*/
2736
public function test_plugins_screen_has_filter_to_add_a_settings_action_link(): void {
@@ -36,6 +45,15 @@ public function test_plugins_screen_has_filter_to_add_a_settings_action_link():
3645
*
3746
* @covers Automattic\AdCodeManager\UI\Plugin_Actions::run
3847
* @covers Automattic\AdCodeManager\UI\Plugin_Actions::add_plugin_meta_links
48+
* @uses ACM_Provider::__construct
49+
* @uses Ad_Code_Manager::action_init
50+
* @uses Ad_Code_Manager::action_load_providers
51+
* @uses Ad_Code_Manager::get_ad_codes
52+
* @uses Ad_Code_Manager::get_option
53+
* @uses Ad_Code_Manager::get_options
54+
* @uses Ad_Code_Manager::register_acm_post_type
55+
* @uses Ad_Code_Manager::register_ad_codes
56+
* @uses Doubleclick_For_Publishers_ACM_Provider::__construct
3957
* @group ui
4058
*/
4159
public function test_plugins_screen_adds_a_settings_action_link(): void {

0 commit comments

Comments
 (0)