This repository has been archived by the owner on Nov 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
build.xml
156 lines (137 loc) · 6.68 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="govCMS" default="env">
<taskdef name="setxmlproperty" classpath="${project.basedir}/src/Task" classname="SetXMLPropertyTask"/>
<!-- Locations of required binaries. -->
<property name="drush" value="${project.basedir}/bin/drush"/>
<property name="composer" value="/usr/local/bin/composer"/>
<property name="npm" value="/usr/local/bin/npm"/>
<property name="rsync" value="/usr/bin/rsync"/>
<property name="bzip2" value="/usr/bin/bzip2"/>
<property name="bunzip2" value="/usr/bin/bunzip2"/>
<property name="phpunit" value="${project.basedir}/bin/phpunit"/>
<!-- Database credentials. -->
<property name="db.type" value="mysql"/>
<property name="db.host" value="localhost"/>
<property name="db.user" value="root"/>
<property name="db.password" value="root"/>
<property name="db.database" value="govcms8"/>
<property name="db.url" value="${db.type}://${db.user}:${db.password}@${db.host}/${db.database}"/>
<!-- Installation and build-specific variables. -->
<property name="url" value="http://govcms8.local"/>
<property name="docroot" value="docroot"/>
<property name="profile" value="${docroot}/profiles/govcms"/>
<property name="site" value="${docroot}/sites/default"/>
<property name="version" value="HEAD"/>
<property name="fixture" value="${project.basedir}/tests/fixtures/${version}.sql"/>
<!-- Profile rsync settings. -->
<property name="sync.push.exclude.file" value="${project.basedir}/build/config/sync.push.exclude.txt"/>
<!-- The following allows local overrides. -->
<property file="${project.basedir}/build.properties" override="true"/>
<!-- Filesets. -->
<fileset dir="${project.basedir}" id="custom.modules" expandsymboliclinks="true">
<include name="modules/custom/core/**"/>
<include name="modules/custom/optional/**"/>
<include name="modules/custom/example/**"/>
<exclude name="**/*.jpeg"/>
</fileset>
<!-- Finds required binaries. -->
<target name="env">
<if>
<not>
<available file="${drush}" property="drush.exists"/>
</not>
<then>
<exec command="which drush" outputProperty="drush"/>
</then>
</if>
<if>
<not>
<available file="${phpunit}" property="phpunit.exists"/>
</not>
<then>
<exec command="which phpunit" outputProperty="phpunit"/>
</then>
</if>
<exec command="which composer" outputProperty="composer"/>
<exec command="which npm" outputProperty="npm"/>
<exec command="which rsync" outputProperty="rsync"/>
<exec command="which bzip2" outputProperty="bzip2"/>
<exec command="which bunzip2" outputProperty="bunzip2"/>
<echo message="Found Drush: ${drush}"/>
<echo message="Found Composer: ${composer}"/>
<echo message="Found NPM: ${npm}"/>
<echo message="Found rsync: ${rsync}"/>
<echo message="Found bzip2: ${bzip2}"/>
<echo message="Found bunzip2: ${bunzip2}"/>
<echo message="Found PHPUnit: ${phpunit}"/>
</target>
<!-- Push the govcms profile into the Drupal code base. -->
<target name="push" depends="env">
<!-- Create the destination if it doesn't exist. -->
<mkdir dir="${profile}"/>
<!-- rsync the profile, excluding developer flotsam. -->
<filesync destinationDir="${profile}" rsyncPath="${rsync}" sourceDir="." verbose="false" excludefile="${sync.push.exclude.file}"/>
</target>
<!-- Pull the updated profile into govCMS distribtuion. -->
<target name="pull" depends="env">
<filesync destinationDir="." rsyncPath="${rsync}" sourceDir="${profile}/" verbose="false" exclude="libraries,modules/contrib,behat.local.yml"/>
</target>
<!-- Destroys the installed code base. -->
<target name="destroy">
<chmod file="${site}" mode="0755"/>
<delete failonerror="true" includeemptydirs="true">
<fileset dir="." defaultexcludes="false">
<include name="bin/**"/>
<include name="${docroot}/**"/>
<include name="node_modules/**"/>
<include name="vendor/**"/>
</fileset>
</delete>
</target>
<!-- Empties the database by dropping and recreating it. -->
<target name="db:reset">
<!-- pdosqlexec requires an SQL file to execute. -->
<echo message="DROP DATABASE ${db.database}; CREATE DATABASE ${db.database};" file=".reset.sql"/>
<pdosqlexec url="${db.type}:host=${db.host}" userid="${db.user}" password="${db.password}" src=".reset.sql"/>
<delete file=".reset.sql"/>
</target>
<!-- Installs govCMS and sets it up for development. -->
<target name="site:install" depends="env">
<!-- Use passthru() when executing drush site-install so that we'll know if errors occur. -->
<exec command="${drush} site-install govcms --yes --site-name=GovCMS --account-pass=admin --db-url=${db.url}" dir="${docroot}" passthru="true"/>
<chmod file="${site}" mode="0755"/>
</target>
<!-- Druplism Drupal codes standard. -->
<target name="validate:phpcs:drupal" description="Sniffs custom code to ensure it meets standards.">
<phpcodesniffer standard="${project.basedir}/vendor/drupal/coder/coder_sniffer/Drupal/" showSniffs="true" showWarnings="true" haltonerror="false" haltonwarning="false">
<fileset refid="custom.modules"/>
<formatter type="full" usefile="false"/>
</phpcodesniffer>
</target>
<!-- Druplism Drupal codes standard suggestion. -->
<target name="validate:phpcs:drupal:practice" description="Sniffs custom code to suggest Drupal Practice.">
<phpcodesniffer standard="${project.basedir}/vendor/drupal/coder/coder_sniffer/DrupalPractice/" showSniffs="true" showWarnings="true" haltonerror="false" haltonwarning="false">
<fileset refid="custom.modules"/>
<formatter type="full" usefile="false"/>
</phpcodesniffer>
</target>
<!-- PHPUnit tests. -->
<target name="test:phpunit" description="PHPUnit tests">
<!-- Prepare PHPUnit. -->
<mkdir dir="${docroot}/modules"/>
<mkdir dir="${docroot}/themes"/>
<mkdir dir="${docroot}/sites/simpletest"/>
<if>
<not>
<available property="phpunit.xml" file="${docroot}/core/phpunit.xml"/>
</not>
<then>
<copy file="${docroot}/core/phpunit.xml.dist" tofile="${docroot}/core/phpunit.xml"/>
<setxmlproperty file="${docroot}/core/phpunit.xml" element="/phpunit/php/env[@name = 'SIMPLETEST_DB']" attribute="value" value="${db.url}"/>
<setxmlproperty file="${docroot}/core/phpunit.xml" element="/phpunit/php/env[@name = 'SIMPLETEST_BASE_URL']" attribute="value" value="${url}"/>
</then>
</if>
<!-- Use passthru() when executing so that we'll know if errors occur. -->
<exec command="${phpunit} -c ${docroot}/core --testsuite unit --exclude-group Composer,DependencyInjection,PageCache" passthru="true"/>
</target>
</project>