-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
229 lines (198 loc) · 9.75 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="webapp" default="noop">
<target name="noop"/>
<property environment="env"/>
<fileset id="files.php" dir="." includes="**/*.php" excludes="**/vendor/**"/>
<condition property="is_windows">
<os family="windows"/>
</condition>
<tstamp>
<format property="now" pattern="yyyy-MM-dd HH:mm:ss" locale="en,UK"/>
<format property="now_num" pattern="yyyyMMddHHmmss" locale="en,UK"/>
<format property="now_file" pattern="yyyy-MM-dd_HHmmss" locale="en,UK"/>
<format property="timestamp" pattern="MM_dd_yyyy_HH-mm-ss" locale="de, DE"/>
</tstamp>
<!-- File variables-->
<property name="filename" value="contact_form_${timestamp}.zip"/>
<property name="build_dir" value="${basedir}/build"/>
<!-- By default, we assume all tools to be on the $PATH -->
<condition property="ext" value=".bat">
<os family="windows"/>
</condition>
<condition property="ext" value="">
<os family="Unix"/>
</condition>
<!-- DISPLAYS WINDOWS OS -->
<target name="display_windows" if="is_windows">
<echo message="OS Family is: Windows"/>
</target>
<target name="migrations" description="Generate database migrations">
<condition property="script_ext" value=".bat" else="">
<os family="windows"/>
</condition>
<input message="Migration name" addproperty="migrationName"/>
<exec executable="${basedir}/vendor/bin/phinx-migrations.bat" dir="${basedir}/config" osfamily="windows">
<arg line="generate --name ${migrationName} --overwrite"/>
</exec>
</target>
<target name="fix-style" description="Code style fixer">
<mkdir dir="${basedir}/build"/>
<get src="http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar" dest="${basedir}/build/php-cs-fixer.phar" skipexisting="true"/>
<exec executable="php" searchpath="true" resolveexecutable="true" failonerror="true">
<arg value="${basedir}/build/php-cs-fixer.phar"/>
<arg line="fix --config=.cs.php"/>
</exec>
</target>
<target name="deploy" description="get your Repository from GitHub to your build folder">
<!-- Choose, which environment you want to deploy -->
<input message="Which config should be used?"
validArgs="test,staging,prod"
addproperty="config"
/>
<property file="${basedir}/config/ant.${config}.properties"/>
<!-- Build project -->
<antcall target="build"/>
<!-- Upload deploy.php -->
<echo message="Uploading deploy.php ..."/>
<scp file="${build_dir}/deploy.php"
todir="${build.ftp.user}:${build.ftp.password}@${build.ftp.host}:${build.ftp.dir}"
trust="true"/>
<!-- Upload clean-up.php -->
<echo message="uploading clean-up.php ..."/>
<scp file="${build_dir}/clean-up.php"
todir="${build.ftp.user}:${build.ftp.password}@${build.ftp.host}:${build.ftp.dir}"
trust="true"/>
<!-- Deleting clean-up.php and deploy.php -->
<echo message="Deleting clean-up.php and deploy.php"/>
<delete file="${build_dir}/clean-up.php"/>
<delete file="${build_dir}/deploy.php"/>
<!-- Upload zip-file -->
<echo message="Uploading ${filename} ..."/>
<scp file="${build_dir}/${filename}"
todir="${build.ftp.user}:${build.ftp.password}@${build.ftp.host}:${build.ftp.dir}"
trust="true"/>
<!-- Delete old directories -->
<delete dir="${build_dir}/master"/>
<delete file="${build_dir}/master.zip"/>
<delete file="${build_dir}/${filename}"/>
<!-- Call deploy.php for zip-file -->
<sshexec host="${build.ftp.host}"
username="${build.ftp.user}"
password="${build.ftp.password}"
command="cd ${build.ftp.dir};php deploy.php ${filename}"
usepty="true"
trust="true"
/>
</target>
<target name="build">
<!-- Download newest repository master -->
<antcall target="get-repo"/>
<!-- Install composer.phar, if this file isn't already in the buildfolder -->
<get src="https://getcomposer.org/composer.phar" dest="${build_dir}" skipexisting="true"/>
<!-- Install project dependencies -->
<exec executable="php" failonerror="true">
<arg line="${build_dir}/composer.phar install --no-dev --optimize-autoloader -d ${build_dir}/master"/>
</exec>
<move file="${build_dir}/master/config/deploy.php" todir="${build_dir}"/>
<move file="${build_dir}/master/config/clean-up.php" todir="${build_dir}"/>
<!-- Clean up build -->
<antcall target="clean-build"/>
<!-- Zip master into file -->
<zip basedir="${build_dir}/master" destfile="${build_dir}/${filename}"/>
</target>
<target name="get-repo">
<delete dir="${build_dir}/master"/>
<mkdir dir="${build_dir}/master"/>
<exec executable="git" failonerror="true">
<arg line="archive --format zip --output ${build_dir}/master.zip master"/>
</exec>
<unzip src="${build_dir}/master.zip" dest="${build_dir}/master"/>
</target>
<target name="clean-build">
<delete dir="${build_dir}/master/tests"/>
<delete file="${build_dir}/master/.gitignore"/>
<delete file="${build_dir}/master/.styleci.yml"/>
<delete file="${build_dir}/master/.scrudinizer.yml"/>
<delete file="${build_dir}/master/build.xml"/>
<delete file="${build_dir}/master/phpstan.neon"/>
<delete file="${build_dir}/master/README.md"/>
<delete file="${build_dir}/master/composer.json"/>
<delete file="${build_dir}/master/composer.lock"/>
<delete file="${build_dir}/master/config/ant.example.properties"/>
<delete file="${build_dir}/master/config/env.example.php"/>
<delete file="${build_dir}/master/config/clean-up.php"/>
<delete file="${build_dir}/master/config/deploy.php"/>
<delete dir="${build_dir}/master/docs"/>
<delete dir="${build_dir}/master/vendor/phpstan"/>
<delete dir="${build_dir}/master/vendor/monolog/monolog/doc"/>
<delete dir="${build_dir}/master/vendor/monolog/monolog/tests"/>
<delete dir="${build_dir}/master/vendor/dflydev/dot-access-data/tests"/>
<delete dir="${build_dir}/master/vendor/league/plates/docs"/>
<delete dir="${build_dir}/master/vendor/league/plates/examples"/>
<delete dir="${build_dir}/master/vendor/phpmailer/phpmailer/examples"/>
<delete dir="${build_dir}/master/vendor/symfony/cache/Tests"/>
<delete dir="${build_dir}/master/vendor/symfony/http-foundation/Tests"/>
<delete dir="${build_dir}/master/vendor/symfony/routing/Tests"/>
<delete dir="${build_dir}/master/vendor/symfony/translation/Tests"/>
</target>
<target name="check-docblocks">
<exec executable="php" failonerror="true">
<arg value="${basedir}/vendor/odan/docblock-checker/bin/docblock-checker"/>
<arg value="--exclude=build/*,public/*,.idea/*,.svn/*,.git/*,resources/*,tmp/*,vendor/*"/>
</exec>
</target>
<target name="phpstan" description="DbBlockedUsersTest code for errors">
<mkdir dir="${basedir}/build"/>
<get src="https://github.com/phpstan/phpstan/releases/download/0.9/phpstan.phar"
dest="${basedir}/build/phpstan.phar"
skipexisting="true"/>
<exec executable="php" failonerror="true">
<arg line="${basedir}/build/phpstan.phar analyse --no-progress --level=5 -c phpstan.neon src"/>
</exec>
<exec executable="php" failonerror="true">
<arg line="${basedir}/build/phpstan.phar analyse --no-progress --level=1 -c phpstan.neon tests"/>
</exec>
</target>
<target name="php-lints">
<apply executable="php"
failonerror="true">
<arg value="-l"/>
<fileset dir="${basedir}">
<include name="**/*.php"/>
<include name="**/*.ctp"/>
<exclude name="**/vendor/**/*.*"/>
<!--Inspect only modified files-->
<modified/>
</fileset>
</apply>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="${basedir}/vendor/bin/phpunit${ext}" searchpath="true" resolveexecutable="true" failonerror="true" taskname="phpunit">
<arg value="-v"/>
<arg value="--configuration" />
<arg path="${basedir}/phpunit.xml" />
</exec>
</target>
<target name="phpunit-actual" description="Run unit tests with PHPUnit">
<exec executable="${basedir}/vendor/bin/phpunit${ext}" searchpath="true" resolveexecutable="true"
failonerror="true" taskname="phpunit">
<arg value="-v"/>
<arg value="--configuration"/>
<arg path="${basedir}/phpunit.xml"/>
<arg value="--group"/>
<arg value="actual"/>
</exec>
</target>
<target name="phpunit-coverage" description="Run unit tests with PHPUnit with coverage">
<delete dir="${basedir}/build/coverage" />
<mkdir dir="${basedir}/build/coverage" />
<exec executable="${basedir}/vendor/bin/phpunit${ext}" searchpath="true" resolveexecutable="true" failonerror="true" taskname="phpunit-coverage">
<arg value="--configuration" />
<arg path="${basedir}/phpunit.xml" />
<arg value="--coverage-clover" />
<arg path="${basedir}/build/logs/clover.xml" />
<arg value="--coverage-html" />
<arg path="${basedir}/build/coverage" />
</exec>
</target>
</project>