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

🐛 Fix the PR cover checker when there is no test #189

Merged
merged 25 commits into from
Nov 10, 2021
Merged
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
03dc723
fix: :bug: Fix the PR cover checker when there is no test
DouglasCorreiaMeli Nov 3, 2021
66d86e7
fix: :bug: Fix the PR cover checker when the file is not testable
DouglasCorreiaMeli Nov 3, 2021
505c9c3
fix return type for is_testable function
DouglasCorreiaMeli Nov 3, 2021
f3e9cf1
fix: :bug: Add a verification for fail workflow
DouglasCorreiaMeli Nov 3, 2021
6931673
check is PR has untestable files or few tests
DouglasCorreiaMeli Nov 3, 2021
e09bc34
Remove test log
DouglasCorreiaMeli Nov 3, 2021
2178fb6
invert count
DouglasCorreiaMeli Nov 4, 2021
e0308ce
invert count
DouglasCorreiaMeli Nov 4, 2021
3ea2fb1
test CI adding testable file
DouglasCorreiaMeli Nov 4, 2021
dff084c
test CI
DouglasCorreiaMeli Nov 4, 2021
dd17ff8
Merge branch 'develop' of github.com:PluginAndPartners/cart-magento2 …
DouglasCorreiaMeli Nov 5, 2021
9e259ad
test CI
DouglasCorreiaMeli Nov 5, 2021
3270f13
test CI
DouglasCorreiaMeli Nov 5, 2021
4fd4bb3
test CI
DouglasCorreiaMeli Nov 5, 2021
16ea6e2
test CI
DouglasCorreiaMeli Nov 5, 2021
4886b55
test CI
DouglasCorreiaMeli Nov 5, 2021
bb416c8
test CI
DouglasCorreiaMeli Nov 5, 2021
75a7f72
test CI
DouglasCorreiaMeli Nov 5, 2021
8b3bf9c
test CI
DouglasCorreiaMeli Nov 5, 2021
92c0cae
test CI
DouglasCorreiaMeli Nov 5, 2021
fcd7ead
Added hotfix branch filter to check tests
GiovanniCavallari Nov 9, 2021
5c77c3f
Added hotfix branch filter to check tests
GiovanniCavallari Nov 9, 2021
4a52a23
Added hotfix branch filter to check tests
GiovanniCavallari Nov 9, 2021
17d1c27
Added hotfix branch filter to check tests
GiovanniCavallari Nov 9, 2021
cfd5c50
Added hotfix branch filter to check tests
GiovanniCavallari Nov 9, 2021
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
26 changes: 19 additions & 7 deletions src/MercadoPago/Test/pull-request-coverage-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@
$filename = str_replace('/', '\\', $filename);
$filename = str_replace('.php', '', $filename);

$pullRequestFiles[] = $filename;
if (is_testable($filename)) {
$pullRequestFiles[] = $filename;
}
}

function is_testable($filename): bool {

$whitelist = [
0 => 'pull-request-coverage-checker',
1 => 'coverage-checker',
2 => 'registration',
//TODO: add all untestable php files
];

return in_array($filename, $whitelist) ? false : true;
}

if (!file_exists($cloverFile)) {
Expand All @@ -20,11 +34,6 @@
throw new InvalidArgumentException('An integer checked percentage must be given as second parameter');
}

if (count($pullRequestFiles) == 0) {
print_r('Pull Request does not contain any php file to check code coverage');
return;
}

$xml = new SimpleXMLElement(file_get_contents($cloverFile));
$classes = $xml->xpath('//class');
$totalElements = 0;
Expand All @@ -38,7 +47,10 @@
}

if ($totalElements == 0 || $checkedElements == 0) {
print_r('Pull Request does not contain tested php files to check code coverage');
if (count($pullRequestFiles) === 0) {
throw new Exception('Pull Request does not contain tested php files to check code coverage');
}
print_r('Pull Request does not contain any php file to check code coverage');
return;
}

Expand Down