-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathbuild.xml
More file actions
157 lines (145 loc) · 6.47 KB
/
build.xml
File metadata and controls
157 lines (145 loc) · 6.47 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?xml version="1.0" encoding="UTF-8"?>
<project name="RecordManager" basedir="." default="main">
<property name="tmp" value="/tmp" />
<property name="package" value="${phing.project.name}" override="true" />
<property name="builddir" value="${tmp}/build/${phing.project.name}" override="true" />
<property name="srcdir" value="${project.basedir}" override="true" />
<property name="phpunit_extra_params" value="" />
<!-- Main Target -->
<target name="main" description="main target">
<echo>No main build target. Use qa-tasks for normal tests.</echo>
</target>
<!-- Quality Assurance Tasks -->
<target name="qa-tasks" description="Quality assurance tasks">
<phingcall target="phpunitfast"/>
<phingcall target="phpcs"/>
<phingcall target="php-cs-fixer-dryrun"/>
<phingcall target="psalm"/>
<phingcall target="phpstan-console"/>
<phingcall target="rector-console"/>
</target>
<!-- Fix PHP Tasks -->
<target name="fix-php" description="quality assurance php tasks">
<!-- Rector may introduce style issues, so run it first -->
<phingcall target="rector"/>
<phingcall target="php-cs-fixer"/>
<phingcall target="phpcbf"/>
</target>
<!-- PHPUnit -->
<target name="phpunit" description="Run tests with coverage reports">
<if>
<not><available type="dir" file="${builddir}/reports"/></not>
<then>
<mkdir dir="${builddir}/reports"/>
</then>
</if>
<if>
<not><available type="dir" file="${builddir}/reports/coverage"/></not>
<then>
<mkdir dir="${builddir}/reports/coverage"/>
</then>
</if>
<exec executable="${srcdir}/vendor/bin/phpunit" passthru="true" checkreturn="true">
<arg line="-c ${srcdir}/tests/phpunit.xml --display-all-issues --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${srcdir}/tests ${phpunit_extra_params}" />
<env name="XDEBUG_MODE" value="coverage" />
</exec>
</target>
<target name="phpunitfast" description="Run tests">
<exec executable="${srcdir}/vendor/bin/phpunit" passthru="true" checkreturn="true" >
<arg line="-c ${srcdir}/tests/phpunit.xml --display-all-issues ${srcdir}/tests ${phpunit_extra_params}" />
</exec>
</target>
<target name="phpunitfaster" description="Run tests until first failure">
<exec executable="${srcdir}/vendor/bin/phpunit" passthru="true" checkreturn="true" >
<arg line="-c ${srcdir}/tests/phpunit.xml --stop-on-defect --display-all-issues ${srcdir}/tests ${phpunit_extra_params}" />
</exec>
</target>
<!-- PHP CodeSniffer -->
<target name="phpcbf">
<!-- Run phpcs first to find any problems (faster than phpcbf): -->
<exec executable="${srcdir}/vendor/bin/phpcs" escape="false" returnProperty="phpcs_retval" outputProperty="phpcs_output">
<arg line="--cache=${srcdir}/tests/phpcs.cache.json --standard=${srcdir}/tests/phpcs.xml" />
</exec>
<if>
<not><equals arg1="${phpcs_retval}" arg2="0" /></not>
<then>
<echo msg="Trying to fix the following issues: " />
<echo msg="${phpcs_output}" />
<!-- Extract file names from phpcs output: -->
<property name="phpcbf_filelist" value="${phpcs_output}">
<filterchain>
<linecontainsregexp>
<regexp pattern="^FILE: (.*)" />
</linecontainsregexp>
<striplinebreaks />
<replaceregexp>
<regexp pattern="FILE: " replace=" " />
</replaceregexp>
</filterchain>
</property>
<!-- Finally, run phpcbf: -->
<exec executable="${srcdir}/vendor/bin/phpcbf" escape="false" passthru="true">
<arg line="--standard=${srcdir}/tests/phpcs.xml ${phpcbf_filelist}" />
</exec>
</then>
</if>
</target>
<target name="phpcbf">
<exec executable="${srcdir}/vendor/bin/phpcbf" escape="false" passthru="true" checkreturn="true">
<arg line="--standard=${srcdir}/tests/phpcs.xml" />
</exec>
</target>
<target name="phpcs">
<exec executable="${srcdir}/vendor/bin/phpcs" escape="false" passthru="true" checkreturn="true">
<arg line="-s --standard=${srcdir}/tests/phpcs.xml" />
</exec>
</target>
<!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) -->
<target name="php-cs-fixer">
<exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false">
<arg line="fix --config=${srcdir}/tests/recordmanager.php-cs-fixer.php -vvv" />
</exec>
</target>
<target name="php-cs-fixer-dryrun">
<exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false" checkreturn="true">
<arg line="fix --config=${srcdir}/tests/recordmanager.php-cs-fixer.php --dry-run -vvv --diff" />
</exec>
</target>
<!-- Rector -->
<target name="rector-console">
<exec executable="${srcdir}/vendor/bin/rector" escape="false" passthru="true" checkreturn="true">
<arg line="--config=${srcdir}/tests/rector.php --dry-run" />
</exec>
</target>
<target name="rector">
<exec executable="${srcdir}/vendor/bin/rector" escape="false" passthru="true" checkreturn="true">
<arg line="--config=${srcdir}/tests/rector.php" />
</exec>
</target>
<!-- Report rule violations with PHPMD (mess detector) -->
<target name="phpmd">
<echo>Make sure you have phpmd installed in path. It's not installed by default due to its dependencies.</echo>
<exec executable="phpmd">
<arg line="${srcdir}/src html ${srcdir}/tests/phpmd.xml --reportfile ${srcdir}/reports/phpmd.html" />
</exec>
</target>
<!-- Psalm -->
<target name="psalm">
<exec executable="${srcdir}/vendor/bin/psalm" escape="false" passthru="true" checkreturn="true">
<!-- threads=1 is a workaround for "Fatal error: Maximum execution time of 0 seconds exceeded" with macOS-->
<arg line="--threads=1 --diff" />
</exec>
</target>
<target name="psalm-info">
<exec executable="${srcdir}/vendor/bin/psalm" escape="false" passthru="true" checkreturn="true">
<!-- threads=1 is a workaround for "Fatal error: Maximum execution time of 0 seconds exceeded" with macOS-->
<arg line="--threads=1 --diff --show-info=true" />
</exec>
</target>
<!-- Phpstan -->
<target name="phpstan-console">
<exec executable="${srcdir}/vendor/bin/phpstan.phar" escape="false" passthru="true" checkreturn="true">
<arg line="--configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G analyse" />
</exec>
</target>
</project>