-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
208 lines (167 loc) · 10.8 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="PolylangStringExtractor" default="build">
<property name="plugin" value="polylang-string-extractor" override="true" />
<!-- ============================================ -->
<!-- Target: dotenv -->
<!-- ============================================ -->
<target name="dotenv" description="Load environmental variables from system and .env file.">
<echo msg="Load environmental variables" />
<!-- Loads properties from the environment with the specified value as prefix. -->
<property environment="env" override="true" />
<!-- Loads properties from the .env file if exits. -->
<property file=".env" prefix="env" />
<resolvepath propertyName="env.WP_PATH" file="${env.WP_PATH}"/>
</target>
<!-- ============================================ -->
<!-- Target: setup:symlink -->
<!-- ============================================ -->
<target name="setup:symlink" description="Symlink proper directories.">
<echo msg="Symlink proper directories" />
<!-- ============================================ -->
<!-- Symlink plugin itself to wp plugins dir -->
<!-- ============================================ -->
<symlink target="${project.basedir}" link="${project.basedir}/wordpress/wp-content/plugins/${plugin}" overwrite="true" />
</target>
<!-- ============================================ -->
<!-- Target: setup:githook -->
<!-- ============================================ -->
<target name="setup:githook" description="Create git pre-commit hook to execute inspect task before commit.">
<echo msg="Create pre-commit githook" />
<exec command="mkdir -p .git/hooks; touch .git/hooks/pre-commit; echo '' > .git/hooks/pre-commit; echo '#!/bin/sh' >> .git/hooks/pre-commit; echo './vendor/bin/phing inspect' >> .git/hooks/pre-commit; chmod +x .git/hooks/pre-commit;"/>
</target>
<!-- ============================================ -->
<!-- Target: setup -->
<!-- ============================================ -->
<target name="setup" description="Setup project. Execute setup:symlink, setup:githook.">
<echo msg="Setup project" />
<phingcall target="setup:symlink" />
<phingcall target="setup:githook" />
</target>
<!-- ============================================ -->
<!-- Target: wp:db:create -->
<!-- ============================================ -->
<target name="wp:db:create" depends="dotenv" description="Create WordPress database.">
<echo msg="Create WordPress database" />
<exec command="./vendor/bin/wp db create --path=${env.WP_PATH} --allow-root" passthru="true" checkreturn="false" />
</target>
<!-- ============================================ -->
<!-- Target: wpremovedatabase -->
<!-- ============================================ -->
<target name="wp:db:drop" depends="dotenv" description="Drop WordPress database.">
<echo msg="Drop WordPress database" />
<exec command="./vendor/bin/wp db drop --yes --path=${env.WP_PATH} --allow-root" passthru="true" checkreturn="false" />
</target>
<!-- ============================================ -->
<!-- Target: wp:download -->
<!-- ============================================ -->
<target name="wp:download" depends="dotenv" description="Download WordPress.">
<echo msg="Download WordPress ${env.WP_VERSION}" />
<!-- Enviroment variables are loaded by dotenv target -->
<exec command="./vendor/bin/wp core download --version=${env.WP_VERSION} --path=${env.WP_PATH} --locale=${env.WP_LOCALE} --skip-content --allow-root --force" passthru="true" />
<!-- Create required directories -->
<echo msg="Create required directories" />
<exec command="mkdir -p ${env.WP_PATH}/wp-content/plugins; mkdir -p ${env.WP_PATH}/wp-content/themes"/>
</target>
<!-- ============================================ -->
<!-- Target: wpconfig -->
<!-- ============================================ -->
<target name="wp:config" depends="dotenv" description="Generate WordPress wp-config.php.">
<echo msg="Generate WordPress wp-config.php" />
<!-- Enviroment variables are loaded by dotenv target -->
<exec command="./vendor/bin/wp core config --dbname=${env.WP_CONFIG_DB_NAME} --dbuser=${env.WP_CONFIG_DB_USER} --dbpass=${env.WP_CONFIG_DB_PASS} --dbhost=${env.WP_CONFIG_DB_HOST} --extra-php=${env.WP_CONFIG_EXTRA} --path=${env.WP_PATH} --allow-root --skip-check --force" passthru="true" />
</target>
<!-- ============================================ -->
<!-- Target: wpinstall -->
<!-- ============================================ -->
<target name="wp:install" depends="dotenv" description="Generate WordPress wp-config.php.">
<echo msg="Install WordPress" />
<exec command="./vendor/bin/wp core install --url=${env.WP_URL} --title=${env.WP_TITLE} --admin_user=${env.WP_ADMIN_USER} --admin_password=${env.WP_ADMIN_PASS} --admin_email=${env.WP_ADMIN_EMAIL} --path=${env.WP_PATH} --allow-root" passthru="true" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: wpplugins -->
<!-- ============================================ -->
<target name="wp:plugins" depends="dotenv" description="Activate installed plugins..">
<echo msg="Activate plugins" />
<exec command="./vendor/bin/wp plugin activate `./vendor/bin/wp plugin list --status=inactive --format=csv --path=${env.WP_PATH} --allow-root | cut -d',' -f1 | tail -n +2 | tr '\n' ' '` --path=${env.WP_PATH} --allow-root" passthru="true" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: wp:init -->
<!-- ============================================ -->
<target name="wp:init" description="Initialize WordPress. Execute wp:download, wp:config, wp:install, wp:plugins.">
<echo msg="Init WordPress" />
<phingcall target="wp:config" />
<phingcall target="wp:install" />
<phingcall target="wp:plugins" />
</target>
<!-- ============================================ -->
<!-- Target: wp:reset -->
<!-- ============================================ -->
<target name="wp:reset" description="Reset WordPress. Execute wp:config, wp:db:drop, wp:db:create, wp:install, wp:plugins.">
<echo msg="Reset WordPress" />
<phingcall target="wp:config" />
<phingcall target="wp:db:drop" />
<phingcall target="wp:db:create" />
<phingcall target="wp:install" />
<phingcall target="wp:plugins" />
</target>
<!-- ============================================ -->
<!-- Target: lint -->
<!-- ============================================ -->
<target name="inspect:lint" description="Check possible syntax errors in php files using php -l command." depends="setup:symlink">
<echo msg="Check possible syntax errors" />
<exec command="for i in $(find . \( -path ./vendor -o -path ./wordpress \) -prune -o -name '*.php' -print); do php -l $i; done" passthru="true" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: phpcs -->
<!-- ============================================ -->
<target name="inspect:phpcs" description="Check posible code styling errors in php files using phpcs comamnd." depends="setup:symlink">
<echo msg="Check posible code styling errors" />
<exec command="./vendor/bin/phpcs ./ --extensions=php --ignore=${project.basedir}/vendor,${project.basedir}/wordpress --standard=./rules/phpcs.xml" passthru="true" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: phpmd -->
<!-- ============================================ -->
<!-- @TODO: phpmd don't want to work with self symlinks. Scan only inc directory for now. -->
<target name="inspect:phpmd" description="Check posible mess in php files using phpmd comamnd." depends="setup:symlink">
<echo msg="Check posible mess" />
<exec command="./vendor/bin/phpmd ./inc text ./rules/phpmd.xml" passthru="true" checkreturn="false" />
</target>
<!-- ============================================ -->
<!-- Target: phpcpd -->
<!-- ============================================ -->
<target name="inspect:phpcpd" description="Check posible duplicates in php files using phpcpd comamnd." depends="setup:symlink">
<echo msg="Check posible duplicates" />
<exec command="./vendor/bin/phpcpd ./ --exclude vendor --exclude wordpress" passthru="true" checkreturn="false" />
</target>
<!-- ============================================ -->
<!-- Target: phpcbf -->
<!-- ============================================ -->
<target name="inspect:fix" description="Auto fix code styling errors in php files using phpcbf comamnd." depends="setup:symlink">
<echo msg="Auto fix code styling errors" />
<exec command="./vendor/bin/phpcbf ./ --extensions=php --ignore=${project.basedir}/vendor,${project.basedir}/wordpress --standard=./rules/phpcs.xml" passthru="true" checkreturn="true" />
</target>
<target name="inspect" description="Inspect php code. Execute inspect:lint, inspect:phpcs, inspect:phpcpd, inspect:phpmd." depends="inspect:lint, inspect:phpcs, inspect:phpcpd, inspect:phpmd">
</target>
<!-- ============================================ -->
<!-- Target: tests:phpunit -->
<!-- ============================================ -->
<target name="tests:phpunit" depends="dotenv" description="Execute tests using phpunit">
<echo msg="Execute tests" />
<exec command="./vendor/bin/phpunit --configuration phpunit.xml --coverage-html ./coverage" passthru="true" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: tests:phpunit -->
<!-- ============================================ -->
<target name="tests:phpunit:coverage" depends="dotenv" description="Execute tests using phpunit">
<echo msg="Execute tests" />
<exec command="./vendor/bin/phpunit --configuration phpunit.xml --coverage-clover ./clover.xml" passthru="true" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: tests -->
<!-- ============================================ -->
<target name="tests" depends="dotenv, tests:phpunit" description="Execute unit tests. Execute tests:phpunit." />
<!-- ============================================ -->
<!-- Target: tests:coverage -->
<!-- ============================================ -->
<target name="tests:coverage" depends="dotenv, tests:phpunit:coverage" description="Execute unit tests. Execute tests:phpunit:coverage." />
</project>