forked from Codeception/Codeception
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PruneTest.php
66 lines (58 loc) · 1.7 KB
/
PruneTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* This file allows for tests to be skipped.
* For now conditions are simple.
* We check if changes in the source with respect to the configured branch are limited to framework files,
* if that is the case and the current framework isn't one with changed files then we skip it.
*/
$branch ="2.4";
function stderr($message)
{
fwrite(STDERR, $message . "\n");
}
$currentFramework = getenv('FRAMEWORK');
if ($currentFramework === 'Codeception') {
stderr('Codeception tests are always executed');
die();
}
$files = [];
exec("git diff --name-only $branch", $files);
// Regexes for frameworks:
$regexes = [
'Yii2' => '/.*Yii2.*/',
'Lumen' => '/.*(Lumen|LaravelCommon).*/',
'Laravel' => '/.*Laravel.*/',
'Phalcon' => '/.*Phalcon.*/',
'Symfony' => '/.*Symfony.*/',
'Yii1' => '/.*Yii1.*/',
'ZendExpressive' => '/.*ZendExpressive.*/',
'Zend1' => '/.*ZF1.*/',
'Zend2' => '/.*ZF2.*/',
];
// First check if changes include files that are not framework files.
$frameworkOnly = true;
$frameworks = [];
foreach ($files as $file) {
$match = false;
foreach ($regexes as $framework => $regex) {
if (preg_match($regex, $file)) {
$match = true;
$frameworks[$framework] = $framework;
break;
}
}
if (!$match) {
$frameworkOnly = false;
break;
}
}
if ($frameworkOnly) {
stderr('Changes limited to frameworks: ' . implode(', ', $frameworks));
if (!isset($frameworks[$currentFramework])) {
stderr("Skipping test for framework: $currentFramework");
echo "export FRAMEWORK=\n";
echo "export PECL=\n";
echo "export FXP=\n";
echo "export CI_USER_TOKEN=\n";
}
}