Skip to content

Commit 07dc0a6

Browse files
committed
Code. Codecov YML implemented.
1 parent 3dd927b commit 07dc0a6

File tree

6 files changed

+71
-32
lines changed

6 files changed

+71
-32
lines changed

.github/workflows/tests.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPUnit, PHPCS, Psalm
22

33
on: # event list
4-
push: # on push to each of these branches
4+
push:
55
branches:
66
- dev
77
- fix
@@ -11,8 +11,9 @@ on: # event list
1111
branches:
1212
- dev
1313
- master
14+
- beta
1415

15-
env: # environment variables (available in any part of the action)
16+
env:
1617
PHP_VERSION: 7.4
1718

1819
jobs:
@@ -28,36 +29,52 @@ jobs:
2829
DB_PASSWORD: root
2930

3031
steps:
32+
# Checkout
33+
- name: Code Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0 #
37+
38+
# install PHP
3139
- name: Set up PHP
3240
uses: shivammathur/setup-php@v2
3341
with:
3442
php-version: ${{ env.PHP_VERSION }}
43+
extensions: mbstring, intl, mysqli, xdebug
44+
45+
# Run Composer
46+
- name: Install Dependencies
47+
run: composer install --prefer-dist --no-interaction
3548

49+
# Run MySQL
3650
- name: Run MySQL server
3751
run: sudo systemctl start mysql
3852

39-
- name: Code Checkout
40-
uses: actions/checkout@v4
41-
42-
- name: Make the script files executable
53+
# WP Run
54+
- name: Make WP setup script executable
4355
run: chmod +x ./tests/wp-test-setup.sh
4456

4557
- name: Install WP develop
4658
run: ./tests/wp-test-setup.sh wordpress_test root root localhost latest
4759

48-
- name: Install Dependencies
49-
run: composer i
50-
60+
# Run PHPUnit с coverage
5161
- name: Running tests
5262
env:
5363
CLEANTALK_TEST_API_KEY: ${{ secrets.CLEANTALK_TEST_API_KEY }}
5464
run: composer test
5565

66+
# Load coverage на Codecov
5667
- name: Upload coverage to Codecov
5768
uses: codecov/codecov-action@v5
69+
with:
70+
files: coverage.clover
71+
fail_ci_if_error: true
72+
flags: unittests
73+
verbose: true
5874
env:
5975
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6076

77+
# Matrix
6178
- name: Matrix notify on failure
6279
if: failure()
6380
uses: Glomberg/matrix-messenger-action@master

codecov.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
codecov:
2+
require_ci_to_pass: true
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "20..100"
8+
9+
status:
10+
project: true
11+
patch: true
12+
13+
comment:
14+
layout: "reach, diff, flags, files"
15+
behavior: default
16+
require_changes: false
17+
18+
ignore:
19+
- vendor/**
20+
- tests/**
21+
- node_modules/**
22+
- "**/*.md"
23+
- lib/Cleantalk/Common/ContactsEncoder/**/*.php

lib/Cleantalk/Common/Helper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ public static function httpRequest($url, $data = array(), $presets = array(), $o
614614
* @param array $urls Array of URLs to requests
615615
*
616616
* @return array|bool
617+
* @codeCoverageIgnore
617618
*/
618619
public static function httpMultiRequest($urls, $write_to = '')
619620
{
@@ -641,7 +642,13 @@ static function ($content, $url) use ($write_to) {
641642
: 'error';
642643
}
643644

645+
/**
646+
* @codeCoverageIgnoreStart
647+
*/
644648
return $content;
649+
/**
650+
* @codeCoverageIgnoreEnd
651+
*/
645652
}
646653
);
647654
}

tests/ApbctWP/ContactsEncoder/TestContactsEncoder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ public function setUp()
2626

2727
public function testPlainTextEncodeDecodeSSL()
2828
{
29+
global $apbct;
30+
/**
31+
* @var State $apbct
32+
*/
33+
$apbct->errorDeleteAll();
2934
$encoded_plain = $this->contacts_encoder->encoder->encodeString($this->plain_text);
3035
$this->assertNotEmpty($encoded_plain);
3136
$this->assertIsString($encoded_plain);
3237
$decoded_entity = $this->contacts_encoder->encoder->decodeString($encoded_plain);
3338
$this->assertNotEmpty($decoded_entity);
3439
$this->assertIsString($decoded_entity);
35-
global $apbct;
3640
$this->assertFalse($apbct->isHaveErrors());
3741
$this->assertEquals($decoded_entity, $this->plain_text);
3842
}

tests/Common/HelperTest.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/phpunit.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
bootstrap="bootstrap.php"
44
colors="true"
@@ -16,14 +16,22 @@
1616
</testsuites>
1717

1818
<filter>
19-
<whitelist>
19+
<whitelist processUncoveredFilesFromWhitelist="false">
2020
<directory suffix=".php">../</directory>
2121
<exclude>
2222
<directory>../vendor</directory>
2323
<directory>../tests</directory>
2424
<directory>../node_modules</directory>
25+
<directory>../js</directory>
26+
<directory>../css</directory>
27+
<directory>../lib/Cleantalk/Common/ContactsEncoder</directory>
2528
<file>../bootstrap.php</file>
2629
</exclude>
2730
</whitelist>
2831
</filter>
32+
33+
<logging>
34+
<log type="coverage-clover" target="coverage.clover"/>
35+
<log type="coverage-text" target="php://stdout"/>
36+
</logging>
2937
</phpunit>

0 commit comments

Comments
 (0)