-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
136 lines (119 loc) · 5.58 KB
/
build.xml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?xml version="1.0"?>
<project name="tesseract-bridge" default="build" basedir="." description="Tesseract bridge build plan">
<property name="project-resources-dir" value="Resources" />
<property name="project-resources-configs-dir" value="${project-resources-dir}/configs"/>
<property name="project-resources-configs-phpmd-dir" value="${project-resources-configs-dir}/phpmd"/>
<property name="project-file-config-phpmd" value="${project-resources-configs-phpmd-dir}/phpmd.xml"/>
<property name="project-vendor-dir" value="vendor" />
<property name="project-vendor-bin-dir" value="vendor/bin" />
<property name="project-src-dir" value="src" />
<property name="project-tests-dir" value="tests" />
<property name="php-bin" value="php" />
<property name="project-composer-phar" value="composer.phar" />
<property name="php-cs-fixer-bin" value="${project-vendor-bin-dir}/php-cs-fixer" />
<!-- Filesets -->
<fileset dir="${project-src-dir}" id="src-php">
<include name="**/*.php"/>
</fileset>
<!-- /Filesets -->
<target name="initialize-autoload" description="Initialize autoloader">
<autoloader />
</target>
<target name="composer-validate" description="Validate composer file">
<composer composer="${project-composer-phar}" command="validate" />
</target>
<target name="phplint" description="Perform syntax check of sourcecode files">
<phplint haltonfailure="true" deprecatedAsError="true">
<fileset refid="src-php"/>
</phplint>
</target>
<target name="php-cs-fixer" description="Fixes most issues in code as defined in the PSR-1 and PSR-2 documents">
<exec executable="${php-bin}" logoutput="true">
<arg path="${php-cs-fixer-bin}" />
<arg value="fix"/>
</exec>
</target>
<target name="php-cs-fixer-ci" description="Fixes most issues in code as defined in the PSR-1 and PSR-2 documents">
<exec executable="${php-bin}" logoutput="true">
<arg path="${php-cs-fixer-bin}" />
<arg value="fix"/>
<arg value="--dry-run" />
<arg value="--diff" />
</exec>
</target>
<target name="phpmd" description="Run phpmd checks" depends="initialize-autoload">
<phpmd rulesets="${project-file-config-phpmd}">
<fileset refid="src-php"/>
</phpmd>
</target>
<target name="phpcs" description="Run code style checks" depends="initialize-autoload">
<exec executable="${project-vendor-bin-dir}/phpcs" dir="." checkReturn="false" outputProperty="phpcs-results" returnProperty="phpcs-return" >
<arg value="--standard=PSR12" />
<arg value="${project-src-dir}" />
<arg value="${project-tests-dir}" />
</exec>
<echo message="${phpcs-results}" />
<if>
<istrue value="${phpcs-return}" />
<then>
<fail /> <!-- fail build in case of errors -->
</then>
</if>
</target>
<target name="phpcpd" description="Find code duplicates">
<exec executable="${php-bin}" logoutput="true" checkreturn="true">
<arg path="${project-vendor-bin-dir}/phpcpd" />
<arg value="--exclude" />
<arg value="${project-vendor-dir}" />
<arg value="." />
</exec>
</target>
<target name="psalm" description="Run static code analysis">
<exec executable="${project-vendor-bin-dir}/psalm" dir="." checkReturn="false" outputProperty="psalm-results" returnProperty="psalm-return">
<arg value="--show-info=true" />
</exec>
<echo message="${psalm-results}" />
<if>
<istrue value="${psalm-return}" />
<then>
<fail /> <!-- fail build in case of errors -->
</then>
</if>
</target>
<target name="phpunit" description="Run tests">
<!-- Using exec here because phing cannot show all info from phpunit -->
<exec executable="${php-bin}" dir="." checkReturn="false" outputProperty="phpunit-results" returnProperty="phpunit-return" >
<arg value="${project-vendor-bin-dir}/phpunit" />
</exec>
<echo message="${phpunit-results}" />
<if>
<istrue value="${phpunit-return}" />
<then>
<fail /> <!-- fail build in case of errors -->
</then>
</if>
</target>
<target name="phpunit-ci" description="Run tests">
<!-- Using exec here because phing cannot show all info from phpunit -->
<exec executable="${php-bin}" dir="." checkReturn="false" outputProperty="phpunit-results" returnProperty="phpunit-return" >
<arg value="-d=xdebug.mode=coverage" />
<arg value="${project-vendor-bin-dir}/phpunit" />
</exec>
<echo message="${phpunit-results}" />
<if>
<istrue value="${phpunit-return}" />
<then>
<fail /> <!-- fail build in case of errors -->
</then>
</if>
</target>
<target name="dependencies-list-outdated" description="Check for new versions of dependencies">
<composer composer="${project-composer-phar}" command="outdated">
<arg value="-D"/>
</composer>
</target>
<target name="build" description="Runs build locally" depends="composer-validate, phplint, php-cs-fixer, phpcs,
phpmd, phpcpd, psalm, phpunit, dependencies-list-outdated" />
<target name="build-ci" description="Run CI build" depends="phplint, php-cs-fixer-ci, phpcs, phpmd, phpcpd, psalm,
phpunit-ci" />
</project>