-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild.xml
More file actions
218 lines (199 loc) · 7.89 KB
/
build.xml
File metadata and controls
218 lines (199 loc) · 7.89 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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="MLInvoice" basedir="." default="main">
<property name="tmp" value="/tmp" />
<property name="package" value="${phing.project.name}" override="true" />
<property name="php-cs-fixer-extra-params" value=""/>
<property name="basedir" value="${project.basedir}" override="true" />
<!--
Continuous integration test database settings.
*** N.B. Running CI will overwrite the database ***
-->
<property name="dbname" value="mlinvoice_test_987" />
<property name="dbuser" value="mlinvoicetest" />
<property name="dbpass" value="testpass" />
<property name="dbhost" value="localhost" />
<property name="dbrootuser" value="" /> <!-- not needed if using login credentials -->
<property name="dbrootpass" value="" /> <!-- not needed if using login credentials -->
<property name="overwrite-config" value="0" override="true" />
<property name="codeception_params" value="" />
<!-- We only need the credentials if the password is non-blank -->
<if>
<not>
<equals arg1="${dbrootuser}" arg2="" />
</not>
<then>
<property name="dbcredentials" value="-u ${dbrootuser}" />
</then>
<else>
<property name="dbcredentials" value="" />
</else>
</if>
<if>
<not>
<equals arg1="${dbrootpass}" arg2="" />
</not>
<then>
<property name="dbcredentials" value="${dbcredentials} -p ${dbrootpass}" />
</then>
</if>
<!-- Main Target -->
<target name="main" description="main target">
<echo>No main build target. Use qa for normal tests.</echo>
</target>
<!-- QA Checks -->
<target name="qa" description="QA checks">
<!-- Call standard tasks -->
<phingcall target="phpunit"/>
<phingcall target="eslint"/>
<phingcall target="phpcs-n"/>
<phingcall target="php-cs-fixer-dryrun"/>
</target>
<!-- CI Checks -->
<target name="ci" description="CI tests">
<phingcall target="ci-setup"/>
<phingcall target="ci-codeception"/>
<phingcall target="ci-teardown"/>
</target>
<!-- CI setup -->
<target name="ci-setup">
<!-- fail if there is existing configuration -->
<if>
<available file="${basedir}/running-ci" />
<then>
<fail>${basedir}/running-ci flag file already exists</fail>
</then>
</if>
<if>
<and>
<available file="${basedir}/config.php" />
<equals arg1="${overwrite-config}" arg2="0" />
</and>
<then>
<fail>config.php already exists</fail>
</then>
</if>
<!-- setup database -->
<exec executable="mysqladmin">
<arg line="-h ${dbhost} ${dbcredentials} -f drop ${dbname}" />
</exec>
<exec executable="mysqladmin" checkreturn="true" passthru="true">
<arg line="-h ${dbhost} ${dbcredentials} create ${dbname}" />
</exec>
<exec executable="mysql">
<arg line="-h ${dbhost} ${dbcredentials} -e "DROP USER '${dbuser}'@'${dbhost}'"" />
</exec>
<exec executable="mysql" checkreturn="true" passthru="true">
<arg line="-h ${dbhost} ${dbcredentials} -e "CREATE USER '${dbuser}'@'${dbhost}' IDENTIFIED BY '${dbpass}'"" />
</exec>
<exec executable="mysql" checkreturn="true" passthru="true">
<arg line="-h ${dbhost} ${dbcredentials} -e "GRANT SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE,LOCK TABLES ON ${dbname}.* TO '${dbuser}'@'${dbhost}' WITH GRANT OPTION"" />
</exec>
<exec executable="mysql" checkreturn="true" passthru="true">
<arg line="-h ${dbhost} ${dbcredentials} -D ${dbname} < ${basedir}/tests/fixtures/create_database_29.sql" />
</exec>
<!-- update configuration -->
<copy file="${basedir}/config.php.sample" tofile="${basedir}/config.php" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern="//define\('_UI_LANGUAGE_', 'en-US'\);" replace="define('_UI_LANGUAGE_', 'en-US');" />
<regexp pattern="define\('_DB_SERVER_', 'localhost'\)" replace="define('_DB_SERVER_', '${dbhost}')" />
<regexp pattern="define\('_DB_USERNAME_', 'mlinvoice'\)" replace="define('_DB_USERNAME_', '${dbuser}')" />
<regexp pattern="define\('_DB_PASSWORD_', ''\)" replace="define('_DB_PASSWORD_', '${dbpass}')" />
<regexp pattern="define\('_DB_NAME_', 'mlinvoice'\)" replace="define('_DB_NAME_', '${dbname}')" />
<regexp pattern="replacewithsomethingsecure" replace="thisisnotreallythatsecurebutokfortesting" />
</replaceregexp>
</filterchain>
</copy>
<append destFile="${basedir}/config.php" text="define('MLINVOICE_LOGIN_DELAY_MULTIPLIER', 0);${line.separator}" fixlastline="yes" />
<!-- create flag file -->
<touch file="${basedir}/running-ci" />
</target>
<!-- CI teardown -->
<target name="ci-teardown">
<if>
<not>
<available file="${basedir}/running-ci" />
</not>
<then>
<fail>${basedir}/running-ci flag file does not exist</fail>
</then>
</if>
<if>
<not>
<available file="${basedir}/config.php" />
</not>
<then>
<fail>config.php does not exist</fail>
</then>
</if>
<!-- drop database and user -->
<exec executable="mysqladmin" checkreturn="true" passthru="true">
<arg line="-h ${dbhost} ${dbcredentials} -f drop ${dbname}" />
</exec>
<exec executable="mysql" passthru="true">
<arg line="-h ${dbhost} ${dbcredentials} -e "DROP USER '${dbuser}'@'${dbhost}'"" />
</exec>
<!-- remove configuration -->
<delete file="${basedir}/running-ci" />
<delete file="${basedir}/config.php" />
</target>
<!-- codeception -->
<target name="ci-codeception">
<exec executable="vendor/bin/codecept" escape="false" checkreturn="true" passthru="true">
<arg line="--steps run --fail-fast ${codeception_params}" />
</exec>
</target>
<target name="ci-codeception-coverage">
<exec executable="vendor/bin/codecept" escape="false" checkreturn="true" passthru="true">
<arg line="--steps --coverage-html run" />
</exec>
</target>
<!-- phpunit -->
<target name="phpunit">
<exec executable="vendor/bin/phpunit" escape="false" checkreturn="true" passthru="true">
<arg line="tests" />
</exec>
</target>
<!-- eslint -->
<target name="eslint">
<exec executable="npx" escape="false" checkreturn="true" passthru="true">
<arg line="eslint js/mlinvoice.js js/mlinvoice-form.js" />
</exec>
</target>
<target name="eslint-fix">
<exec executable="npx" escape="false" checkreturn="true" passthru="true">
<arg line="eslint js/mlinvoice.js js/mlinvoice-form.js --fix" />
</exec>
</target>
<!-- PHP CodeSniffer -->
<target name="phpcs">
<exec executable="vendor/bin/phpcs" passthru="true" escape="false" checkreturn="true">
<arg line="--standard=tests/phpcs-ruleset.xml *.php" />
</exec>
</target>
<!-- PHP CodeSniffer without warnings-->
<target name="phpcs-n">
<exec executable="vendor/bin/phpcs" passthru="true" escape="false" checkreturn="true">
<arg line="--standard=tests/phpcs-ruleset.xml -n *.php" />
</exec>
</target>
<!-- phpcbf -->
<target name="phpcbf">
<exec executable="vendor/bin/phpcbf" passthru="true" escape="false">
<arg line="--standard=tests/phpcs-ruleset.xml *.php" />
</exec>
</target>
<!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) -->
<target name="php-cs-fixer">
<mkdir dir=".php_cs_cache" />
<exec executable="vendor/bin/php-cs-fixer" passthru="true" escape="false">
<arg line="fix --config=tests/php-cs-fixer.config.php -vvv ${php-cs-fixer-extra-params}" />
</exec>
</target>
<target name="php-cs-fixer-dryrun">
<mkdir dir=".php_cs_cache" />
<exec executable="vendor/bin/php-cs-fixer" passthru="true" escape="false" checkreturn="true">
<arg line="fix --config=tests/php-cs-fixer.config.php --dry-run -vvv --diff ${php-cs-fixer-extra-params}" />
</exec>
</target>
</project>