Skip to content

Commit 1c5dabf

Browse files
committed
Add build.
1 parent 67bc854 commit 1c5dabf

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor
2-
composer.lock
2+
composer.lock
3+
reports

build.xml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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>

src/phpunit.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<phpunit backupGlobals="false"
2+
colors="true"
3+
bootstrap="vendor/autoload.php"
4+
processIsolation="false"
5+
stopOnError="false"
6+
stopOnFailure="false"
7+
stopOnIncomplete="false"
8+
stopOnSkipped="false"
9+
stopOnRisky="false"
10+
convertErrorsToExceptions="true"
11+
convertNoticesToExceptions="true"
12+
convertWarningsToExceptions="true">
13+
<php>
14+
<ini name="error_reporting" value="-1" />
15+
</php>
16+
17+
<testsuites>
18+
<testsuite name="PhpBCC Test Suite">
19+
<directory>./tests</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<whitelist processUncoveredFilesFromWhitelist="true">
24+
<directory suffix=".php">src</directory>
25+
</whitelist>
26+
27+
</phpunit>

0 commit comments

Comments
 (0)