-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.xml
229 lines (200 loc) · 7.54 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?xml version="1.0" encoding="UTF-8"?>
<project name="argilla" basedir="." default="build">
<property name="coverage.database" value="build/logs/cover.db"/>
<target name="build" description="Build project" depends="clearCache, clearLogs, phpunit, phpcs, phpmd, phpcpd, phploc"/>
<target name="createSchema" description="Create DB schema">
<phing phingfile="build/db.xml" target="createSchema"/>
</target>
<target name="applySchema" description="Apply DB schema">
<phing phingfile="build/db.xml" target="applySchema"/>
</target>
<target name="createDump" description="Create DB dump">
<phing phingfile="build/db.xml" target="createDump"/>
</target>
<target name="applyDump" description="Apply DB dump">
<phing phingfile="build/db.xml" target="applyDump"/>
</target>
<target name="migrate" description="Apply migrations">
<phing phingfile="build/db.xml" target="migrate"/>
</target>
<target name="revertSchema" description="Recover original schema">
<phing phingFile="build/db.xml" target="revertSchema"/>
</target>
<target name="clearCache" description="Clean assets and runtime cache directories">
<if>
<available property="production" file="protected/config/production.php" type="file"/>
<then>
<php expression="touch('protected/config/production.php');" returnProperty="success"/>
<if>
<equals arg1="${success}" arg2="true"/>
<then>
<echo message="Update file production last modify success"/>
</then>
<else>
<warn message="Update file production last modify failed" />
</else>
</if>
</then>
</if>
<echo message="Cleaning assets directories"/>
<delete includeemptydirs="true">
<fileset dir="assets/">
<include name="**"/>
</fileset>
<fileset dir="backend/assets/">
<include name="**"/>
</fileset>
</delete>
<echo message="Cleaning runtime cache directories"/>
<delete includeemptydirs="false">
<fileset dir="protected/runtime/cache/">
<include name="**"/>
</fileset>
</delete>
</target>
<target name="clearLogs" description="Clean Jenkins' logs and runtime directory">
<!--Удаляем логи Jenkins-->
<if>
<available property="checkDirectory" file="build/logs/" type="dir"></available>
<then>
<echo message="Cleaning Jenkins' logs"/>
<delete>
<fileset dir="build/logs/">
<include name="*.xml"/>
<include name="*.csv"/>
</fileset>
</delete>
</then>
</if>
<echo message="Cleaning runtime directory"/>
<delete>
<fileset dir="protected/runtime/">
<include name="**"/>
</fileset>
</delete>
<delete>
<fileset dir="backend/protected/runtime/">
<include name="**"/>
</fileset>
</delete>
</target>
<target name="getCheckingApp" hidden="true">
<!-- это используется для того, чтобы можно было говорить phing -Dfrontend или phing -Dbackend, указывая фингу с каким приложением мы работаем -->
<if>
<and>
<isset property="frontend"/>
<not>
<isset property="backend"/>
</not>
</and>
<then>
<property name="noBackend" value="1"/>
</then>
</if>
<if>
<and>
<isset property="backend"/>
<not>
<isset property="frontend"/>
</not>
</and>
<then>
<property name="noFrontend" value="1"/>
</then>
</if>
</target>
<target name="phpcs" description="PHP Codesniffer" depends="getCheckingApp">
<phing phingFile="build/runners/checker.xml">
<property name="whatToCheck" value="phpcs"/>
</phing>
</target>
<target name="phpmd" description="PHP Mess Detector" depends="getCheckingApp">
<phing phingFile="build/runners/checker.xml">
<property name="whatToCheck" value="phpmd"/>
</phing>
</target>
<target name="phpcpd" description="PHP Copy-Paste detector" depends="getCheckingApp">
<phing phingFile="build/runners/checker.xml">
<property name="whatToCheck" value="phpcpd"/>
</phing>
</target>
<target name="phploc" depends="getCheckingApp" description="Get phploc's metriks">
<phing phingFile="build/runners/checker.xml">
<property name="whatToCheck" value="phploc"/>
</phing>
</target>
<target name="phpunit" depends="getCheckingApp" description="Run PHPunit tests">
<phing phingFile="build/runners/checker.xml">
<property name="whatToCheck" value="phpunit"/>
</phing>
</target>
<target name="fixAccessRights" description="Set access rights to files and directories">
<php expression="@posix_getpwuid(stat('.')['uid'])['name']" returnProperty="defaultUser"></php>
<php expression="@posix_getpwuid(stat('.')['gid'])['name']" returnProperty="defaultGroup"></php>
<echo message="${defaultUser}"/>
<echo message="${defaultGroup}"/>
<input message="Enter user name for change:" propertyName="user" defaultValue="${defaultUser}"/>
<input message="Enter group name for change:" propertyName="group" defaultValue="${defaultGroup}" />
<input propertyName="confirm" defaultValue="n" validArgs="y,n" message="Are you sure that want to change owner to ${user}:${group} ?"/>
<if>
<equals arg1="${confirm}" arg2="y"/>
<then>
<phing phingFile="build/chown.xml" >
<property name="user" value="${user}" />
<property name="group" value="${group}" />
</phing>
</then>
</if>
<input propertyName="confirm" defaultValue="n" validArgs="y,n" message="Do fix rights for project?"/>
<if>
<equals arg1="${confirm}" arg2="y"/>
<then>
<phing phingFile="build/chmod.xml" />
</then>
</if>
</target>
<target name="coverage" description="Build code-coverage report">
<phing phingFile="build/coverage.xml"/>
</target>
<target name="jsPack" description="Pack JS">
<phing phingFile="build/bootstrap.xml" target="packJS"/>
</target>
<target name="jsCompile" description="Compile JS">
<phing phingFile="build/bootstrap.xml" target="compileJS"/>
</target>
<target name="bootstrap" description="Do a bootstrap process">
<phing phingFile="build/bootstrap.xml"/>
<echo message="bootstrap done"/>
</target>
<target name="deploy" description="Deploy project">
<phing phingFile="build/deploy.xml"/>
</target>
<target name="productionOn" description="Turns on production mode">
<if>
<available property="production" file="protected/config/production.php" type="file"/>
<then>
<echo message="Production mode already turns on"/>
</then>
<else>
<copy file="protected/config/production.php.sample" tofile="protected/config/production.php" haltonerror="true"/>
</else>
</if>
</target>
<target name="productionOff" description="Turns off production mode">
<if>
<available property="production" file="protected/config/production.php" type="file"/>
<then>
<input message="Do you want to turn off production mode [y/n]?" propertyName="answer" defaultValue="n"></input>
<if>
<equals arg1="${answer}" arg2="y"></equals>
<then>
<delete file="protected/config/production.php" failonerror="true"/>
</then>
</if>
</then>
<else>
<echo message="Production mode already turns off"/>
</else>
</if>
</target>
</project>