Files
phpbb_board3-portal_tlw/build.xml
2023-02-20 21:07:29 +01:00

234 lines
10 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project name="Extension Builder" description="Builds an extension.zip from a git repository" default="all">
<property name="vendor-name" value="board3" />
<property name="extension-name" value="portal" />
<!--
Only set this to "true" if you have dependencies in the composer.json,
otherwise use "false".
-->
<property name="has-dependencies" value="true" />
<target name="clean-package">
<!--
Remove some unnecessary files/directories
${dir}/ is the folder of your extension, e.g. ext/nickvergessen/newspage/
-->
<delete dir="${dir}/tests" />
<delete dir="${dir}/.github" />
<delete dir="${dir}/travis" />
<delete dir="${dir}/vendor/marc1706/phpbb-text-shortener/.github" />
<delete dir="${dir}/language/ar" />
<delete dir="${dir}/language/es" />
<delete dir="${dir}/language/fr" />
<delete dir="${dir}/language/it" />
<delete dir="${dir}/language/nl" />
<delete file="${dir}/.gitignore" />
<delete file="${dir}/.gitattributes" />
<delete file="${dir}/build.xml" />
<delete file="${dir}/composer.lock" />
<delete file="${dir}/composer.phar" />
<delete file="${dir}/phpunit.xml.dist" />
<delete file="${dir}/README.md" />
</target>
<!--
TODO: DO NOT EDIT BELOW THIS LINE!!!!
-->
<property name="version" value="HEAD" override="true" />
<property name="package.version" value="HEAD" />
<property name="build-directory" value="build" override="true" />
<property name="package-directory" value="${build-directory}/package/${vendor-name}/${extension-name}" />
<property name="phpbb-root" value="${build-directory}/../../../../../" />
<property name="clover-path" value="${build-directory}/logs/clover.xml" />
<property name="coverage-html-path" value="${build-directory}/coverage" />
<!-- These are the main targets which you will probably want to use -->
<target name="all" depends="prepare-structure,package" />
<!--
Clean up the build directory
-->
<target name="clean">
<delete dir="${build-directory}" />
<mkdir dir="${build-directory}" />
</target>
<target name="composer">
<exec dir="${build-directory}/../"
command="php composer.phar install"
passthru="true" />
</target>
<target name="prepare-tests" depends="clean,composer">
<if>
<available property="phpbb-is-available" file="${phpbb-root}/phpBB/vendor/bin/phpunit" type="file" />
<then>
<echo msg="phpBB is already set up." />
</then>
<else>
<!-- Move Board3 Portal and set up phpBB -->
<exec command="CURRENT_BUILD_REV=$(git rev-parse --abbrev-ref HEAD)" passthru="true" />
<exec command="echo $GIT_BRANCH" passthru="true" />
<exec command="git clone -v --progress https://github.com/phpbb/phpbb.git phpbb" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="git checkout 3.3.x" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB" command="php ../composer.phar install" passthru="true" />
<mkdir dir="phpbb/phpBB/ext/board3" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3" command="git clone https://github.com/board3/Board3-Portal.git portal" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="git checkout $GIT_BRANCH" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="php composer.phar install" passthru="true" />
<property name="phpbb-root" value="${build-directory}/../phpbb" override="true" />
<property name="clover-path" value="../build/logs/clover.xml" override="true" />
<property name="coverage-html-path" value="../build/coverage" override="true" />
<exec dir="${build-directory}/../phpbb" command="cp ../../test_config_22x.php tests/test_config.php" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/cache" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="mkdir phpBB/cache/test" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/cache/test" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/files" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/store" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/images/avatars/upload" passthru="true" />
</else>
</if>
<if>
<equals arg1="$JENKINS_URL" arg2="" />
<then>
<echo msg="JENKINS_URL is not set" />
</then>
<else>
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="wget https://phar.phpunit.de/phploc.phar" passthru="true" />
<if>
<available property="logs-dir-available" file="${build-directory}/logs" type="dir" />
<then>
<echo msg="Logs dir already set up." />
</then>
<else>
<mkdir dir="${build-directory}/logs" />
<exec dir="${build-directory}/logs" command="touch phploc.csv" />
</else>
</if>
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3" command="php portal/phploc.phar --exclude=vendor --exclude=travis --log-csv ../../../../build/logs/phploc.csv portal/" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="rm phploc.phar" passthru="true" />
</else>
</if>
<if>
<equals arg1="$BUILD_NUMBER" arg2="" />
<then>
<echo msg="BUILD_NUMBER is not available" />
</then>
<else>
<property environment="env" />
<echo>Build number is ${env.BUILD_NUMBER}</echo>
<property name="package.version" value="${env.BUILD_NUMBER}" override="true" />
</else>
</if>
</target>
<target name="test" depends="clean,composer,prepare-tests">
<if>
<available property="phpunit-available" file="phpbb/phpBB/vendor/bin/phpunit" type="file" />
<then>
<exec dir="${phpbb-root}"
command="phpBB/vendor/bin/phpunit
-c phpBB/ext/${vendor-name}/${extension-name}/ --coverage-clover=${clover-path} --coverage-html=${coverage-html-path}"
passthru="true" returnProperty="test.pass" />
<if>
<not>
<equals arg1="${test.pass}" arg2="0"/>
</not>
<then>
<fail msg="PHPUnit tests failed."/>
</then>
</if>
</then>
<else>
<echo msg="PHPUnit couldn't be found." />
</else>
</if>
</target>
<target name="test-slow" depends="clean,composer">
<if>
<available property="phpunit-available" file="phpbb/phpBB/vendor/bin/phpunit" type="file" />
<then>
<exec dir="${phpbb-root}"
command="phpBB/vendor/bin/phpunit
-c phpBB/ext/${vendor-name}/${extension-name}/
--group slow"
passthru="true" />
<if>
<not>
<equals arg1="${test.pass}" arg2="0"/>
</not>
<then>
<fail msg="PHPUnit slow tests failed."/>
</then>
</if>
</then>
<else>
<echo msg="PHPUnit couldn't be found." />
</else>
</if>
</target>
<!--
Recreate the necessary folders
-->
<target name="prepare-structure" depends="clean,composer,test,test-slow">
<mkdir dir="${build-directory}" />
<mkdir dir="${build-directory}/checkout" />
<mkdir dir="${build-directory}/package" />
<mkdir dir="${build-directory}/package/${vendor-name}" />
<mkdir dir="${build-directory}/package/${vendor-name}/${extension-name}" />
<mkdir dir="${build-directory}/upload" />
</target>
<!--
The real packaging
-->
<target name="package">
<echo msg="Extracting ${version}" />
<phingcall target="git-checkout">
<property name="archive-version" value="${version}" />
</phingcall>
<if>
<equals arg1="${has-dependencies}" arg2="1" />
<then>
<exec dir="${package-directory}" command="php composer.phar install --no-dev"
checkreturn="true" />
</then>
</if>
<phingcall target="clean-package">
<property name="dir" value="${package-directory}" />
</phingcall>
<phingcall target="wrap-package">
<property name="destination-filename" value="${build-directory}/upload/${vendor-name}_${extension-name}_${package.version}" />
</phingcall>
</target>
<!--
Checkout a given version and install/clean the dependencies
-->
<target name="git-checkout">
<echo msg="Getting archive for ${archive-version}" />
<exec command="git archive ${archive-version} --format zip --output ${build-directory}/checkout/${archive-version}.zip"
checkreturn="true" />
<unzip file="${build-directory}/checkout/${archive-version}.zip" todir="${package-directory}" />
</target>
<!--
Create the zip and tar ball
-->
<target name="wrap-package">
<echo msg="Creating archives (${vendor-name}/${extension-name} ${version})" />
<zip basedir="${build-directory}/package/" destfile="${destination-filename}.zip" />
</target>
</project>