-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoboFile.php
More file actions
67 lines (58 loc) · 1.86 KB
/
RoboFile.php
File metadata and controls
67 lines (58 loc) · 1.86 KB
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
67
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
public function __construct()
{
$this->stopOnFail();
}
public function testCi()
{
$this->taskFilesystemStack()
->copy('.env.example', '.env')
->run();
$this->_exec('php artisan key:generate');
$this->taskComposerInstall()->run();
$this->test(true);
}
public function test($checkStyle = false)
{
$this->stopOnFail(false);
$resultStatic = $this->testStatic($checkStyle);
$resultPhpunit = $this->testPhpunit($checkStyle);
if (!($resultStatic && $resultPhpunit)) {
throw new \Exception('At least one test failed');
}
}
public function testStatic($checkStyle = false)
{
$this->stopOnFail(false);
$resultLint = $this->testLint($checkStyle);
$resultPhpstan = $this->testPhpstan($checkStyle);
if (!($resultLint && $resultPhpstan)) {
$this->say('<error>At least one static test failed</error>');
return false;
}
return true;
}
public function testLint($checkStyle = false)
{
$result = $this->taskExec('vendor/bin/phpcs -s'. ($checkStyle ? ' --report-full --report-checkstyle=./phpcs-report.xml' : ''))->run()->wasSuccessful();
if ($checkStyle) {
$this->_exec('vendor/bin/cs2pr ./phpcs-report.xml');
}
return $result;
}
public function testPhpstan($checkStyle = false)
{
return $this->taskExec('vendor/bin/phpstan' . ($checkStyle ? ' --error-format=checkstyle | vendor/bin/cs2pr' : ''))->run()->wasSuccessful();
}
public function testPhpunit()
{
return $this->taskExec('vendor/bin/phpunit')->run()->wasSuccessful();
}
}