build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="Case Converter" description="Case Converter class" default="help" phingVersion="3">
<defaultexcludes default="true"/><!--Initializing default excludes-->
<defaultexcludes add="**/.idea"/>
<defaultexcludes add="**/.idea/**"/>
<target name="help">
<visualizer format="svg"/>
<open path="build.svg"/>
</target>
<target name="setup" description="Install dependencies" depends="composer:install, cc:get"/>
<target name="qa" description="Run quality tests"
depends="php:lint, composer:validate, phpunit:run, behat:run, phpstan:analyse, psalm:run"/>
<target name="docs:refresh-images" description="Update and regenerate docs images"
depends="phing:visualize, plantuml:puml-to-png"/>
<target name="composer:validate" description="Check composer.json syntax">
<composer command="validate">
<arg value="--strict"/>
<arg value="--no-check-lock"/>
</composer>
</target>
<target name="composer:install">
<composer command="install">
<arg value="--no-interaction"/>
<arg value="--profile"/>
<arg value="--ansi"/>
<arg value="--prefer-dist"/>
</composer>
</target>
<target name="phpunit:open-coverage" description="Open coverage site" depends="phpunit:run">
<exec executable="xdg-open">
<arg file="resources/coverage-html/index.html"/>
</exec>
</target>
<target name="php:lint" description="Check syntax on PHP files">
<phplint haltonfailure="true">
<fileset dir="${project.basedir}">
<include name="**/*.php"/>
<exclude name="vendor/"/>
</fileset>
</phplint>
</target>
<target name="behat:run" description="Run behat tests">
<exec executable="vendor/bin/behat" passthru="true" checkreturn="true">
<arg value="--colors"/>
<arg value="--no-interaction"/>
<arg value="--stop-on-failure"/>
<arg value="--rerun"/>
<arg value="--strict"/>
</exec>
</target>
<target name="phpunit:run" description="Run unit tests">
<mkdir dir="resources/coverage-html/"/>
<exec executable="vendor/bin/phpunit" passthru="true" checkreturn="true">
<env key="XDEBUG_MODE" value="coverage"/>
<arg line="--configuration=config/phpunit.xml"/>
<arg value="--testdox"/>
</exec>
</target>
<target name="changelog:links" description="Update links in composer.json">
<composer command="require">
<arg value="symplify/changelog-linker:^v6"/>
</composer>
<exec executable="vendor/bin/changelog-linker">
<arg value="link"/>
</exec>
<composer command="remove">
<arg value="symplify/changelog-linker"/>
</composer>
</target>
<target name="cc:get" description="Download Code Climate">
<property name="cc.dir" value="bin"/>
<property name="cc.filename" value="cc-test-reporter"/>
<if>
<not>
<available file="${cc.dir}/${cc.filename}"/>
</not>
<then>
<mkdir dir="${cc.dir}"/>
<httpget dir="${cc.dir}" filename="${cc.filename}" followRedirects="true"
url="https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64"/>
</then>
</if>
<chmod file="${cc.dir}/${cc.filename}" mode="0775"/>
<exec executable="${cc.dir}/${cc.filename}" passthru="true" checkreturn="true">
<arg value="--version"/>
</exec>
</target>
<target name="cc:before-build" description="To run before a build">
<fail unless="env.CC_TEST_REPORTER_ID" message="you must supply a CC_TEST_REPORTER_ID ENV variable"/>
<exec executable="bin/cc-test-reporter" passthru="true" checkreturn="true">
<arg value="before-build"/>
</exec>
</target>
<target name="cc:after-build" description="Handle & upload coverage payload">
<fail unless="env.CC_TEST_REPORTER_ID" message="you must supply a CC_TEST_REPORTER_ID ENV variable"/>
<exec executable="bin/cc-test-reporter" passthru="true" checkreturn="true">
<arg value="after-build"/>
<arg line="--coverage-input-type clover"/>
</exec>
</target>
<target name="plantuml:puml-to-png" description="Parse PlantUML files to image from docs dir">
<composer command="require">
<arg value="jawira/plantuml"/>
</composer>
<exec executable="vendor/bin/plantuml" passthru="true" checkreturn="true">
<arg value="-checkmetadata"/>
<arg path="docs/**.puml"/>
</exec>
<composer command="remove">
<arg value="jawira/plantuml"/>
</composer>
</target>
<target name="git:tags-listing" description="List all git tags">
<!-- https://stackoverflow.com/a/34239190/4345061 -->
<exec executable="git" passthru="true">
<arg value="log"/>
<arg line="--graph --all --decorate --oneline --simplify-by-decoration"/>
</exec>
</target>
<target name="phing:visualize" description="Update build.png">
<visualizer format="puml" destination="docs/images"/>
</target>
<target name="docs:serve" description="Generate and open static site" depends="docs:build">
<parallel threadCount="2">
<exec executable="mkdocs" passthru="true" checkreturn="true">
<arg value="serve"/>
</exec>
<exec executable="xdg-open" passthru="true" checkreturn="true">
<!--Please F5 after some seconds-->
<arg value="http://127.0.0.1:8000/"/>
</exec>
</parallel>
</target>
<target name="docs:build" description="Builds static site" depends="docs:refresh-images">
<exec executable="mkdocs" passthru="true" checkreturn="true">
<arg value="build"/>
</exec>
</target>
<target name="psalm:run" description="Check code with Psalm">
<exec executable="vendor/bin/psalm" checkreturn="true" passthru="true">
<arg line="--no-cache --long-progress"/>
</exec>
</target>
<target name="phpstan:analyse" description="Analyse at max level">
<exec executable="vendor/bin/phpstan" passthru="true" checkreturn="true">
<arg value="analyse"/>
<arg line="--level=max"/>
<arg value="--no-progress"/>
<arg value="--no-interaction"/>
<arg value="--ansi"/>
<arg path="src"/>
</exec>
</target>
</project>