1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project name =" laravel-nomadic" default =" build" basedir =" ." >
3
+ <target name =" build" depends =" prepare,phpcs,phpunit,assert" />
4
+ <autoloader autoloaderpath =" ${ project.basedir } /vendor/autoload.php" />
5
+ <property name =" reports.dir" value =" ${ project.basedir } /reports" override =" true" />
6
+
7
+ <!-- Prepare the build by cleaning up the artifacts. -->
8
+ <target name =" prepare" description =" Cleanup build artifacts" >
9
+ <delete dir =" ${ reports.dir } " />
10
+ <mkdir dir =" ${ reports.dir } " />
11
+ </target >
12
+
13
+ <!-- Detect coding standard violations and print to screen if error occurs. -->
14
+ <target name =" phpcs" description =" Detect coding standard violations" >
15
+ <phpcodesniffer standard =" ./vendor/chadicus/coding-standard/Chadicus" haltonerror =" true" file =" src" >
16
+ <formatter type =" checkstyle" outfile =" ${ reports.dir } /phpcs.log" />
17
+ <formatter type =" full" usefile =" false" />
18
+ </phpcodesniffer >
19
+ </target >
20
+
21
+ <!-- Run phpunit with code coverage and generate reports -->
22
+ <target name =" phpunit" description =" Run phpunit tests" >
23
+ <!-- Specify coverage and path to save coverage stats -->
24
+ <coverage-setup database =" ${ reports.dir } /coverage.db" >
25
+ <fileset dir =" src" >
26
+ <include name =" **/*.php" />
27
+ </fileset >
28
+ </coverage-setup >
29
+
30
+ <!-- Run phpunit saving data -->
31
+ <phpunit printsummary =" true" codecoverage =" true" errorproperty =" phpuniterror" failureproperty =" phpunitfailure" >
32
+ <formatter type =" xml" todir =" ${ reports.dir } " outfile =" phpunit.log" />
33
+ <formatter type =" clover" todir =" ${ reports.dir } " />
34
+ <batchtest >
35
+ <fileset dir =" ${ project.basedir } /tests" >
36
+ <include name =" **/*Test.php" />
37
+ </fileset >
38
+ </batchtest >
39
+ </phpunit >
40
+
41
+ <!-- Generate the reports using phing -->
42
+ <phpunitreport infile =" ${ project.basedir } /phpunit.xml" format =" frames" todir =" ${ reports.dir } " />
43
+ <coverage-report outfile =" ${ reports.dir } /coverage.xml" >
44
+ <report toDir =" ${ reports.dir } " />
45
+ </coverage-report >
46
+ </target >
47
+
48
+ <!-- Make sure tests didnt fail and code coverage standards are met -->
49
+ <target name =" assert" description =" Assert project standards met." >
50
+ <!-- Verify that phpunit error or fail -->
51
+ <exec command =" cat ${ reports.dir } /phpunit.log" outputProperty =" phpunitoutput" />
52
+ <if >
53
+ <or >
54
+ <equals arg1=" ${ phpuniterror } " arg2=" true" />
55
+ <equals arg1=" ${ phpunitfailure } " arg2=" true" />
56
+ </or >
57
+ <then >
58
+ <fail msg =" !${ line.separator } ${ line.separator } ${ phpunitoutput } " />
59
+
60
+ </then >
61
+ </if >
62
+
63
+ <!-- Verify 100% Code Coverage -->
64
+ <xmlproperty file =" ${ reports.dir } /coverage.xml" collapseAttributes =" true" />
65
+ <if >
66
+ <equals arg1=" ${ snapshot.totalcount } /${ snapshot.totalcovered } *100" arg2=" 90" />
67
+ <then >
68
+ <fail msg =" !${ line.separator } ${ line.separator } Code Coverage needs to be increased 90% still: file://${ reports.dir } /index.html" />
69
+ </then >
70
+ </if >
71
+ </target >
72
+ </project >
0 commit comments