1 | <?php |
||
2 | |||
3 | /** |
||
4 | * RoboFile.php |
||
5 | * |
||
6 | * PHP version 7 |
||
7 | * |
||
8 | * @author Tim Wagner <[email protected]> |
||
9 | * @copyright 2019 TechDivision GmbH <[email protected]> |
||
10 | * @license https://opensource.org/licenses/MIT |
||
11 | * @link https://github.com/techdivision/import-attribute-set |
||
12 | * @link http://www.techdivision.com |
||
13 | */ |
||
14 | |||
15 | use Lurker\Event\FilesystemEvent; |
||
0 ignored issues
–
show
|
|||
16 | use Symfony\Component\Finder\Finder; |
||
17 | |||
18 | /** |
||
19 | * Defines the available build tasks. |
||
20 | * |
||
21 | * @author Tim Wagner <[email protected]> |
||
22 | * @copyright 2019 TechDivision GmbH <[email protected]> |
||
23 | * @license https://opensource.org/licenses/MIT |
||
24 | * @link https://github.com/techdivision/import-attribute-set |
||
25 | * @link http://www.techdivision.com |
||
26 | * |
||
27 | * @SuppressWarnings(PHPMD) |
||
28 | */ |
||
29 | class RoboFile extends \Robo\Tasks |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * The build properties. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $properties = array( |
||
38 | 'base.dir' => __DIR__, |
||
39 | 'src.dir' => __DIR__ . '/src', |
||
40 | 'dist.dir' => __DIR__ . '/dist', |
||
41 | 'vendor.dir' => __DIR__ . '/vendor', |
||
42 | 'target.dir' => __DIR__ . '/target' |
||
43 | ); |
||
44 | |||
45 | /** |
||
46 | * Run's the composer install command. |
||
47 | * |
||
48 | * @return \Robo\Result The result |
||
49 | */ |
||
50 | public function composerInstall() |
||
51 | { |
||
52 | // optimize autoloader with custom path |
||
53 | return $this->taskComposerInstall() |
||
54 | ->preferDist() |
||
55 | ->optimizeAutoloader() |
||
56 | ->run(); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Run's the composer update command. |
||
61 | * |
||
62 | * @return \Robo\Result The result |
||
63 | */ |
||
64 | public function composerUpdate() |
||
65 | { |
||
66 | // optimize autoloader with custom path |
||
67 | return $this->taskComposerUpdate() |
||
68 | ->preferDist() |
||
69 | ->optimizeAutoloader() |
||
70 | ->run(); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Clean up the environment for a new build. |
||
75 | * |
||
76 | * @return \Robo\Result The result |
||
77 | */ |
||
78 | public function clean() |
||
79 | { |
||
80 | return $this->taskDeleteDir($this->properties['target.dir'])->run(); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Prepare's the environment for a new build. |
||
85 | * |
||
86 | * @return \Robo\Result The result |
||
87 | */ |
||
88 | public function prepare() |
||
89 | { |
||
90 | return $this->taskFileSystemStack() |
||
91 | ->mkdir($this->properties['dist.dir']) |
||
92 | ->mkdir($this->properties['target.dir']) |
||
93 | ->mkdir(sprintf('%s/reports', $this->properties['target.dir'])) |
||
94 | ->run(); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Run's the PHPMD. |
||
99 | * |
||
100 | * @return \Robo\Result The result |
||
101 | */ |
||
102 | public function runMd() |
||
103 | { |
||
104 | |||
105 | // run the mess detector |
||
106 | return $this->_exec( |
||
107 | sprintf( |
||
108 | '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit', |
||
109 | $this->properties['vendor.dir'], |
||
110 | $this->properties['src.dir'], |
||
111 | $this->properties['target.dir'] |
||
112 | ) |
||
113 | ); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Run's the PHPCPD. |
||
118 | * |
||
119 | * @return \Robo\Result The result |
||
120 | */ |
||
121 | public function runCpd() |
||
122 | { |
||
123 | // prepare the patterns for the files that has to be ignored |
||
124 | $ignore = array( |
||
125 | $this->properties['src.dir'].'/Utils', |
||
126 | ); |
||
127 | |||
128 | // run the copy past detector |
||
129 | return $this->_exec( |
||
130 | sprintf( |
||
131 | '%s/bin/phpcpd %s --exclude %s --log-pmd %s/reports/pmd-cpd.xml', |
||
132 | $this->properties['vendor.dir'], |
||
133 | $this->properties['src.dir'], |
||
134 | implode(' --exclude ', $ignore), |
||
135 | $this->properties['target.dir'] |
||
136 | ) |
||
137 | ); |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * Run's the PHPCodeSniffer. |
||
142 | * |
||
143 | * @return \Robo\Result The result |
||
144 | */ |
||
145 | public function runCs() |
||
146 | { |
||
147 | |||
148 | // run the code sniffer |
||
149 | return $this->_exec( |
||
150 | sprintf( |
||
151 | '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s', |
||
152 | $this->properties['vendor.dir'], |
||
153 | $this->properties['target.dir'], |
||
154 | $this->properties['src.dir'] |
||
155 | ) |
||
156 | ); |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Run's the PHPUnit tests. |
||
161 | * |
||
162 | * @return \Robo\Result The result |
||
163 | */ |
||
164 | public function runTests() |
||
165 | { |
||
166 | |||
167 | // run PHPUnit |
||
168 | return $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->properties['vendor.dir'])) |
||
169 | ->configFile('phpunit.xml') |
||
170 | ->run(); |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * The complete build process. |
||
175 | * |
||
176 | * @return void |
||
177 | */ |
||
178 | public function build() |
||
179 | { |
||
180 | |||
181 | // stop the build on first failure of a task |
||
182 | $this->stopOnFail(true); |
||
183 | |||
184 | // process the build |
||
185 | $this->clean(); |
||
186 | $this->prepare(); |
||
187 | $this->runCs(); |
||
188 | $this->runCpd(); |
||
189 | $this->runMd(); |
||
190 | $this->runTests(); |
||
191 | } |
||
192 | } |
||
193 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths