Skip to content

Commit 1d6a36a

Browse files
author
Jacob Christiansen
committed
Added build stuff
1 parent f104a6e commit 1d6a36a

9 files changed

+2241
-0
lines changed

bin/composer.phar

1 MB
Binary file not shown.

build.xml

+212
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project name="Colourbox SSP cassrver module" default="build">
4+
<target name="build"
5+
depends="prepare,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,phpunit,phpcb,securitycheck,phpdox"/>
6+
7+
<target name="build-parallel"
8+
depends="prepare,lint,tools-parallel,phpunit,phpcb,phpdox"/>
9+
10+
<target name="tools-parallel" description="Run tools in parallel">
11+
<parallel threadCount="2">
12+
<sequential>
13+
<antcall target="pdepend"/>
14+
<antcall target="phpmd-ci"/>
15+
</sequential>
16+
<antcall target="phpcpd-ci"/>
17+
<antcall target="phpcs-ci"/>
18+
<antcall target="phploc-ci"/>
19+
<antcall target="securitycheck"/>
20+
</parallel>
21+
</target>
22+
23+
<target name="clean"
24+
unless="clean.done"
25+
description="Cleanup build artifacts">
26+
<delete dir="${basedir}/build/api"/>
27+
<delete dir="${basedir}/build/code-browser"/>
28+
<delete dir="${basedir}/build/coverage"/>
29+
<delete dir="${basedir}/build/logs"/>
30+
<delete dir="${basedir}/build/pdepend"/>
31+
<delete dir="${basedir}/build/phpdox"/>
32+
<delete dir="${basedir}/build/docs"/>
33+
<property name="clean.done" value="true"/>
34+
</target>
35+
36+
<target name="prepare"
37+
unless="prepare.done"
38+
depends="clean"
39+
description="Prepare for build">
40+
<mkdir dir="${basedir}/build/api"/>
41+
<mkdir dir="${basedir}/build/code-browser"/>
42+
<mkdir dir="${basedir}/build/coverage"/>
43+
<mkdir dir="${basedir}/build/logs"/>
44+
<mkdir dir="${basedir}/build/pdepend"/>
45+
<mkdir dir="${basedir}/vendor"/>
46+
<antcall target="init"/>
47+
<property name="prepare.done" value="true"/>
48+
</target>
49+
50+
<target name="init" description="Do needed stuff before build">
51+
<antcall target="composerselfupdate" />
52+
<antcall target="composerinstall" />
53+
</target>
54+
55+
<target name="composerinstall" description="Run composer install">
56+
<exec executable="${basedir}/bin/composer.phar" failonerror="true">
57+
<arg value="install" />
58+
</exec>
59+
</target>
60+
61+
<target name="composerselfupdate" description="Run composer self-update">
62+
<exec executable="${basedir}/bin/composer.phar" failonerror="true">
63+
<arg value="self-update" />
64+
</exec>
65+
</target>
66+
67+
<target name="lint" description="Perform syntax check of sourcecode files">
68+
<apply executable="php" failonerror="true">
69+
<arg value="-l" />
70+
71+
<fileset dir="${basedir}/lib">
72+
<include name="**/*.php" />
73+
<modified />
74+
</fileset>
75+
76+
<fileset dir="${basedir}/test">
77+
<include name="**/*.php" />
78+
<modified />
79+
</fileset>
80+
</apply>
81+
</target>
82+
83+
<target name="phploc"
84+
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
85+
<exec executable="${basedir}/vendor/bin/phploc">
86+
<arg value="--count-tests" />
87+
<arg path="${basedir}/lib" />
88+
<arg path="${basedir}/test" />
89+
</exec>
90+
</target>
91+
92+
<target name="phploc-ci"
93+
depends="prepare"
94+
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
95+
<exec executable="${basedir}/vendor/bin/phploc">
96+
<arg value="--count-tests" />
97+
<arg value="--log-csv" />
98+
<arg path="${basedir}/build/logs/phploc.csv" />
99+
<arg value="--log-xml" />
100+
<arg path="${basedir}/build/logs/phploc.xml" />
101+
<arg path="${basedir}/lib" />
102+
<arg path="${basedir}/test" />
103+
</exec>
104+
</target>
105+
106+
<target name="pdepend"
107+
depends="prepare"
108+
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
109+
<exec executable="${basedir}/vendor/bin/pdepend">
110+
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
111+
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
112+
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
113+
<arg path="${basedir}/lib" />
114+
</exec>
115+
</target>
116+
117+
<target name="phpmd"
118+
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
119+
<exec executable="${basedir}/vendor/bin/phpmd">
120+
<arg path="${basedir}/lib" />
121+
<arg value="text" />
122+
<arg path="${basedir}/build/phpmd.xml" />
123+
</exec>
124+
</target>
125+
126+
<target name="phpmd-ci"
127+
depends="prepare"
128+
description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
129+
<exec executable="${basedir}/vendor/bin/phpmd">
130+
<arg path="${basedir}/lib" />
131+
<arg value="xml" />
132+
<arg path="${basedir}/build/phpmd.xml" />
133+
<arg value="--reportfile" />
134+
<arg path="${basedir}/build/logs/pmd.xml" />
135+
</exec>
136+
</target>
137+
138+
<target name="phpcs"
139+
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
140+
<exec executable="${basedir}/vendor/bin/phpcs" failonerror="true">
141+
<arg value="--standard=${basedir}/build/phpcs.xml" />
142+
<arg value="--extensions=php" />
143+
<arg value="-s" />
144+
<arg value="--ignore=autoload.php" />
145+
<arg path="${basedir}/lib" />
146+
</exec>
147+
</target>
148+
149+
<target name="phpcs-ci"
150+
depends="prepare"
151+
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
152+
<exec executable="${basedir}/vendor/bin/phpcs" failonerror="true" output="/dev/null">
153+
<arg value="--report=checkstyle" />
154+
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
155+
<arg value="--standard=${basedir}/build/phpcs.xml" />
156+
<arg value="--extensions=php" />
157+
<arg value="--ignore=autoload.php" />
158+
<arg path="${basedir}/lib" />
159+
</exec>
160+
</target>
161+
162+
<target name="phpcpd"
163+
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
164+
<exec executable="${basedir}/vendor/bin/phpcpd">
165+
<arg path="${basedir}/lib" />
166+
</exec>
167+
</target>
168+
169+
<target name="phpcpd-ci"
170+
depends="prepare"
171+
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
172+
<exec executable="${basedir}/vendor/bin/phpcpd">
173+
<arg value="--log-pmd" />
174+
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
175+
<arg path="${basedir}/lib" />
176+
</exec>
177+
</target>
178+
179+
<target name="phpunit"
180+
depends="prepare"
181+
description="Run unit tests with PHPUnit">
182+
<exec executable="${basedir}/vendor/bin/phpunit" failonerror="true" />
183+
</target>
184+
185+
<target name="phpcb"
186+
depends="prepare"
187+
description="Aggregate tool output with PHP_CodeBrowser">
188+
<exec executable="${basedir}/vendor/bin/phpcb">
189+
<arg value="--log" />
190+
<arg path="${basedir}/build/logs" />
191+
<arg value="--source" />
192+
<arg path="${basedir}/lib" />
193+
<arg value="--output" />
194+
<arg path="${basedir}/build/code-browser" />
195+
</exec>
196+
</target>
197+
198+
<target name="securitycheck"
199+
depends="prepare"
200+
description="SensioLabs Security Checker">
201+
<exec executable="${basedir}/vendor/bin/security-checker" failonerror="true">
202+
<arg value="security:check" />
203+
<arg path="${basedir}/composer.lock" />
204+
</exec>
205+
</target>
206+
207+
<target name="phpdox"
208+
depends="phpunit,phploc-ci,phpcs-ci,phpmd-ci"
209+
description="Generate project documentation using phpDox">
210+
<exec executable="${basedir}/vendor/bin/phpdox"/>
211+
</target>
212+
</project>

build/phpcs.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Colourbox API Code standard">
3+
<description>Colourbox API Code Standard is PSR-2. Might include additional sniffs in the future.</description>
4+
<rule ref="PSR2">
5+
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
6+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
7+
</rule>
8+
</ruleset>

build/phpmd.xml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Colourbox API PHPMD rule set"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
6+
http://pmd.sf.net/ruleset_xml_schema.xsd"
7+
xsi:noNamespaceSchemaLocation="
8+
http://pmd.sf.net/ruleset_xml_schema.xsd">
9+
<description>No custom rules at the moment.</description>
10+
<rule ref="rulesets/cleancode.xml">
11+
<!-- Ignore StaticAccess since it is broken in current versio of PHPMD, see https://github.com/phpmd/phpmd/pull/74 -->
12+
<exclude name="StaticAccess" />
13+
</rule>
14+
<rule ref="rulesets/codesize.xml" />
15+
<rule ref="rulesets/design.xml" />
16+
17+
<rule ref="rulesets/naming.xml/ShortVariable">
18+
<properties>
19+
<property name="exceptions" value="db" />
20+
</properties>
21+
</rule>
22+
<rule ref="rulesets/naming.xml/LongVariable">
23+
<properties>
24+
<property name="maximum" value="30" />
25+
</properties>
26+
</rule>
27+
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
28+
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
29+
<rule ref="rulesets/naming.xml/BooleanGetMethodName" />
30+
31+
<rule ref="rulesets/unusedcode.xml" />
32+
<rule ref="rulesets/controversial.xml">
33+
<exclude name="CamelCasePropertyName" />
34+
</rule>
35+
</ruleset>

composer.json

+18
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,23 @@
2020
"php": ">=5.4.0",
2121
"simplesamlphp/composer-module-installer": "~1.0",
2222
"predis/predis": "~1.0"
23+
},
24+
"require-dev": {
25+
"phpunit/phpunit": "~4.4",
26+
"nulpunkt/php-stub": "0.3.*",
27+
"covex-nn/phpcb": "1.*",
28+
"phpunit/php-invoker": "~1.1",
29+
"pdepend/pdepend": "~2.0",
30+
"phpmd/phpmd": "~2.1",
31+
"phploc/phploc": "~2.0",
32+
"sebastian/phpcpd": "~2.0",
33+
"sensiolabs/security-checker": "~2.0",
34+
"theseer/phpdox": "~0.7",
35+
"squizlabs/php_codesniffer": "~2.2"
36+
},
37+
"autoload-dev": {
38+
"classmap": [
39+
"lib/"
40+
]
2341
}
2442
}

0 commit comments

Comments
 (0)