forked from sspooky13/yaml-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
213 lines (190 loc) · 9.77 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?xml version="1.0" encoding="UTF-8"?>
<project name="Yaml standards" default="list">
<property name="path.bin" value="${path.root}/vendor/bin"/>
<property name="path.composer.executable" value="composer"/>
<property name="path.ecs.executable" value="${path.bin}/ecs"/>
<property name="path.php.executable" value="php"/>
<property name="path.phplint.executable" value="${path.bin}/parallel-lint"/>
<property name="path.phpstan.executable" value="${path.bin}/phpstan"/>
<property name="path.phpunit.executable" value="${path.bin}/phpunit"/>
<property name="path.root" value="."/>
<property name="path.src" value="${path.root}/src"/>
<property name="path.tests" value="${path.root}/tests"/>
<property name="path.vendor" value="${path.root}/vendor"/>
<property name="phpstan.level" value="5"/>
<target name="build-ci" depends="standards, tests-unit" description="Run build commands on CI."/>
<target name="standards" depends="phplint,ecs,phpstan" description="Checks coding standards."/>
<target name="standards-diff" depends="phplint-diff,ecs-diff,phpstan" description="Checks coding standards in changed files."/>
<target name="standards-fix" depends="ecs-fix" description="Automatically fixes *some* coding standards violations in all files. Always run 'standards' to be sure there are no further violations."/>
<target name="standards-fix-diff" depends="ecs-fix-diff" description="Automatically fixes *some* coding standards violations in changed files. Always run 'standards' to be sure there are no further violations."/>
<target name="diff-files" description="Finds changed files (against origin/master) and saves them into properties." hidden="true">
<exec executable="git" outputProperty="git.status.output" returnProperty="git.status.returnCode">
<arg value="status"/>
</exec>
<if>
<not>
<equals arg1="${git.status.returnCode}" arg2="0"/>
</not>
<then>
<echo level="error" message="Searching for changed files requires Git to be installed and the .git directory to be available."/>
<echo level="info" message="By default, the .git directory is excluded from synchronization of files using docker-sync on Windows and Mac in order to deliver better performance and stability."/>
<echo level="info" message="If that's your case, either remove '.git' from 'sync_excludes' in your 'docker-sync.yml' or use the target without the '-diff' suffix."/>
<fail message="${git.status.output}"/>
</then>
</if>
<exec executable="git" outputProperty="git.merge.base">
<arg value="merge-base"/>
<arg value="origin/master"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputProperty="git.files.changed">
<arg value="diff"/>
<arg value="--name-only"/>
<arg value="--diff-filter=ACMR"/>
<arg value="${git.merge.base}"/>
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
</exec>
<exec executable="git" outputProperty="git.files.unstaged">
<arg value="ls-files"/>
<arg value="--others"/>
<arg value="--exclude-standard"/>
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
</exec>
<property name="diff.files.all" value="${git.files.changed}${line.separator}${git.files.unstaged}">
<filterchain>
<linecontainsregexp>
<regexp pattern="^.+$" />
</linecontainsregexp>
</filterchain>
</property>
<property name="diff.files.php" value="${diff.files.all}">
<filterchain>
<linecontainsregexp>
<!-- linecontainsregexp splits lines using \n, so string can end with whitespace -->
<regexp pattern="\.php\s*$"/>
</linecontainsregexp>
</filterchain>
</property>
<property name="diff.files.all.spaces" value="${diff.files.all}">
<filterchain>
<replaceregexp>
<regexp pattern="[\r\n]+" replace=" "/>
</replaceregexp>
</filterchain>
</property>
<property name="diff.files.php.spaces" value="${diff.files.php}">
<filterchain>
<replaceregexp>
<regexp pattern="[\r\n]+" replace=" "/>
</replaceregexp>
</filterchain>
</property>
<property name="diff.files.php.commas" value="${diff.files.php}">
<filterchain>
<replaceregexp>
<regexp pattern="[\r\n]+" replace=","/>
<regexp pattern="^,|,$" replace=""/>
</replaceregexp>
</filterchain>
</property>
</target>
<target name="ecs" description="Checks coding standards in all files by PHP easy coding standards." hidden="true">
<exec executable="${path.ecs.executable}" logoutput="true" passthru="true" checkreturn="true">
<arg value="check"/>
<arg value="--clear-cache"/>
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
<arg path="${path.root}/CHANGELOG.md"/>
<arg path="${path.root}/README.md"/>
<arg path="${path.root}/.github/PULL_REQUEST_TEMPLATE.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/1_Bug_report.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/2_Feature_request.md"/>
</exec>
</target>
<target name="ecs-diff" description="Checks coding standards in changed files by PHP easy coding standards." hidden="true">
<exec executable="${path.ecs.executable}" logoutput="true" passthru="true" checkreturn="true">
<arg value="check"/>
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
<arg path="${path.root}/CHANGELOG.md"/>
<arg path="${path.root}/README.md"/>
<arg path="${path.root}/.github/PULL_REQUEST_TEMPLATE.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/1_Bug_report.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/2_Feature_request.md"/>
</exec>
</target>
<target name="ecs-fix" description="Checks and fixes automatically fixable coding standards in all files by PHP easy coding standards." hidden="true">
<exec executable="${path.ecs.executable}" logoutput="true" passthru="true" checkreturn="true">
<arg value="check"/>
<arg value="--clear-cache"/>
<arg value="--fix"/>
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
<arg path="${path.root}/CHANGELOG.md"/>
<arg path="${path.root}/README.md"/>
<arg path="${path.root}/.github/PULL_REQUEST_TEMPLATE.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/1_Bug_report.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/2_Feature_request.md"/>
</exec>
</target>
<target name="ecs-fix-diff" description="Checks and fixes automatically fixable coding standards in changed files by PHP easy coding standards." hidden="true">
<exec executable="${path.ecs.executable}" logoutput="true" passthru="true" checkreturn="true">
<arg value="check"/>
<arg value="--fix"/>
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
<arg path="${path.root}/CHANGELOG.md"/>
<arg path="${path.root}/README.md"/>
<arg path="${path.root}/.github/PULL_REQUEST_TEMPLATE.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/1_Bug_report.md"/>
<arg path="${path.root}/.github/ISSUE_TEMPLATE/2_Feature_request.md"/>
</exec>
</target>
<target name="list" description="Hidden target to make Phing list all targets when called without an argument." hidden="true">
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
<arg value="phing"/>
<arg value="-l"/>
</exec>
</target>
<target name="phpstan" description="Performs static analysis of PHP files using PHPStan." hidden="true">
<exec executable="${path.phpstan.executable}" logoutput="true" passthru="true" checkreturn="true">
<arg value="analyze"/>
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
<arg value="--level=${phpstan.level}"/>
<arg value="-vvv"/>
</exec>
</target>
<target name="phplint" description="Checks syntax of PHP files." hidden="true">
<exec executable="${path.phplint.executable}" logoutput="true" passthru="true" checkreturn="true">
<arg path="${path.src}"/>
<arg path="${path.tests}"/>
</exec>
</target>
<target name="phplint-diff" depends="diff-files" description="Checks syntax of changed PHP files." hidden="true">
<if>
<not>
<equals arg1="${diff.files.php.spaces}" arg2="" trim="true"/>
</not>
<then>
<exec executable="${path.phplint.executable}" logoutput="true" passthru="true" checkreturn="true">
<arg line="${diff.files.php.spaces}"/>
</exec>
</then>
</if>
</target>
<target name="tests-unit" description="Runs unit tests.">
<exec
executable="${path.phpunit.executable}"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="--colors=always"/>
<arg value="--testsuite"/>
<arg value="Unit"/>
</exec>
</target>
</project>