Phing > update configuration

This commit is contained in:
Meritoo
2018-10-25 10:27:48 +02:00
parent 38c68b0952
commit 7e4b14a92f
6 changed files with 150 additions and 259 deletions

View File

@@ -1,28 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
<!-- Properties -->
<if>
<available file="phing/properties" property="custom.properties.available"/>
<available file="${project.basedir}/phing/properties" property="custom.properties.available"/>
<then>
<property file="phing/properties"/>
<property file="${project.basedir}/phing/properties"/>
</then>
<else>
<property file="phing/properties.dist"/>
<property file="${project.basedir}/phing/properties.dist"/>
</else>
</if>
<!-- Default / main target -->
<target name="build:main"
depends="build:app, build:tests"
description="Builds everything and runs all tests"/>
depends="build:app,
build:tests"
/>
<!-- Build app -->
<target name="build:app" description="Prepares app to build and tests">
<phing phingfile="phing/app.xml" haltonfailure="true"/>
<target name="build:app">
<phing phingfile="${project.basedir}/phing/app.xml" haltonfailure="true"/>
</target>
<!-- Build tests -->
<target name="build:tests" description="Runs all tests, checks and creates docs">
<phing phingfile="phing/tests.xml" haltonfailure="true"/>
<target name="build:tests">
<phing phingfile="${project.basedir}/phing/tests.xml" haltonfailure="true"/>
</target>
</project>

View File

@@ -1,107 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.16.0">
<!-- Properties -->
<if>
<available file="phing/properties" property="custom.properties.available"/>
<available file="${project.basedir}/phing/properties" property="custom.properties.available"/>
<then>
<property file="phing/properties"/>
<property file="${project.basedir}/phing/properties"/>
</then>
<else>
<property file="phing/properties.dist"/>
<property file="${project.basedir}/phing/properties.dist"/>
</else>
</if>
<!-- Filesets -->
<import file="phing/filesets.xml"/>
<import file="${project.basedir}/phing/filesets.xml"/>
<!-- Default / main target -->
<target name="build:main"
depends="build:app"
description="Builds the application"/>
/>
<!-- App target -->
<target name="build:app"
depends="app:clean, app:composer, app:vendors, app:composer-validate, app:checkout"
description="Prepares app to build."/>
depends="app:clean,
app:composer:self-update,
app:composer:install,
app:composer:validate,
app:checkout"
/>
<!-- Updates Composer -->
<target name="app:composer" description="Updates Composer">
<echo msg="Updating Composer..."/>
<target name="app:composer:self-update">
<if>
<available file="composer.phar"/>
<not>
<available file="${composer.path}" property="composer.local.unavailable"/>
</not>
<then>
<echo msg="[Skipped] Downloading of Composer skipped, because exist in the project..."/>
</then>
<else>
<if>
<os family="windows"/>
<then>
<fail message="Composer not found! Go to http://getcomposer.org/download and download the Composer."/>
</then>
<else>
<exec command="${composer.download_command}" checkreturn="true"/>
<exec command="${composer.download_command}" checkreturn="true" passthru="true"/>
</else>
</if>
</else>
</then>
</if>
<!-- Update Composer -->
<composer command="selfupdate"/>
<composer php="${composer.php}" composer="${composer.path}" command="selfupdate">
<arg value="--ansi"/>
</composer>
</target>
<!-- Validates composer.* files -->
<target name="app:composer-validate" description="Validates composer.* files">
<echo msg="Validating composer.* files..."/>
<!-- Validate Composer -->
<composer command="validate">
<arg line="--no-check-all --strict"/>
<target name="app:composer:validate" depends="app:composer:install">
<composer php="${composer.php}" composer="${composer.path}" command="validate">
<arg value="--no-check-all"/>
<arg value="--strict"/>
<arg value="--ansi"/>
</composer>
</target>
<!-- Project clean -->
<target name="app:clean" description="Clears app's directories">
<echo msg="Cleaning project..."/>
<target name="app:clean">
<if>
<equals arg1="${env}" arg2="prod"/>
<then>
<echo message="[Skipped] Cleaning project (and directories cleanup) skipped, because of 'prod' environment..."/>
<echo message="[Skipped] Cleaning project (and directories cleanup) -> 'prod' environment"/>
</then>
<else>
<echo msg="Cleaning directories (making them empty)..."/>
<foreach list="${directoriesToEmpty}" param="directory" target="app:clean:empty"/>
</else>
</if>
<echo msg="Preparing directories structure..."/>
<foreach list="${directoriesToCheck}" param="directory" target="app:clean:check"/>
<echo msg="Creating .gitkeep files..."/>
<touch file="${dir.cache}/.gitkeep"/>
<touch file="${dir.logs}/.gitkeep"/>
<touch file="${dir.sessions}/.gitkeep"/>
<echo msg="Setting permissions of directories..."/>
<foreach list="${directoriesToEmpty}" param="directory" target="app:permissions"/>
</target>
<!-- Cleaning directory (making empty) directory -->
<target name="app:clean:empty" description="Empties directory">
<target name="app:clean:empty">
<if>
<available file="${directory}" type="dir"/>
<available file="${directory}" type="dir" property="dir_is_available"/>
<then>
<echo message="Cleaning directory (making empty) ${directory}..."/>
<delete includeemptydirs="true" dir="${directory}"/>
</then>
</if>
</target>
<!-- Checking if directory exists -->
<target name="app:clean:check" description="Checks if directories exist">
<target name="app:clean:check">
<if>
<not>
<available file="${directory}" type="dir"/>
<available file="${directory}" type="dir" property="dir_is_available"/>
</not>
<then>
<if>
@@ -121,40 +118,24 @@
</if>
</target>
<!-- Project Install/update vendors -->
<target name="app:vendors" description="Installs / updates vendors">
<echo msg="Installing / updating vendors..."/>
<if>
<istrue value="${composer.self-update}"/>
<then>
<composer php="${composer.php}" composer="${composer.path}" command="self-update"/>
</then>
</if>
<!-- Installs vendors -->
<target name="app:composer:install" depends="app:composer:self-update">
<composer php="${composer.php}" composer="${composer.path}" command="install">
<arg value="--optimize-autoloader"/>
<arg value="--prefer-dist"/>
<arg value="--classmap-authoritative"/>
<arg value="--ansi"/>
</composer>
</target>
<!-- Clearing cache -->
<target name="app:cache" description="Clears project cache and logs">
<echo msg="Clearing cache..."/>
<target name="app:cache">
<if>
<istrue value="${cache.clearWithWarmup}"/>
<then>
<echo message="...with warm up"/>
<SymfonyConsole console="bin/console" command="cache:clear">
<arg name="env" value="${env}"/>
</SymfonyConsole>
</then>
<else>
<echo message="...without warm up"/>
<SymfonyConsole console="bin/console" command="cache:clear">
<arg name="env" value="${env}"/>
<arg name="no-warmup"/>
@@ -164,9 +145,7 @@
</target>
<!-- Clearing cache (faster) -->
<target name="app:cache:faster" description="Clears project cache and logs (faster)">
<echo msg="Clearing cache (faster)..."/>
<target name="app:cache:faster">
<SymfonyConsole console="bin/console" command="cache:clear">
<arg name="env" value="${env}"/>
<arg name="no-optional-warmers"/>
@@ -174,16 +153,14 @@
</target>
<!-- Warming up cache -->
<target name="app:cache:warmup" description="Warms up project cache">
<echo msg="Warming up cache..."/>
<target name="app:cache:warmup">
<SymfonyConsole console="bin/console" command="cache:warmup">
<arg name="env" value="${env}"/>
</SymfonyConsole>
</target>
<!-- Setting permissions of given directory -->
<target name="app:permissions" description="Sets permissions of one of the core directories">
<target name="app:permissions">
<if>
<not>
<os family="windows"/>

20
phing/composer-install.sh Normal file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
EXPECTED_SIGNATURE="$(curl -L https://composer.github.io/installer.sig)"
# Original line (with wget):
# EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
exit $RESULT

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.16.0">
<!-- Filesets -->
<fileset id="cache" dir="${dir.cache}">

View File

@@ -1,19 +1,3 @@
# --------------------------------------------------------------------------------
# Information
# --------------------------------------------------------------------------------
# Property files contain key/value pairs
# key = value
#
# Property keys may contain alphanumeric chars and colons, but
# not special chars. This way you can create pseudo-namespaces
#
# You can refer to values of other properties by enclosing their keys in "${}".
# Example: dir.js = ${dir.public}/js
#
# Everything behind the equal sign is the value, you do
# not have to enclose strings: text=This is some text, Your OS is ${php.os}
# --------------------------------------------------------------------------------
# Common, e.g. default environment
# --------------------------------------------------------------------------------
@@ -36,20 +20,18 @@ cache.clearWithWarmup = false
# Composer
# --------------------------------------------------------------------------------
composer.download_command = php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
# Path to composer executable or composer.phar file
# Command used to download Composer
#
composer.path = composer.phar
composer.download_command = bash ${project.basedir}/phing/composer-install.sh
# Path to composer executable or downloaded composer.phar file
#
composer.path = ${project.basedir}/composer.phar
# Path to php executable used by composer
#
composer.php = php
# Self update of the composer
#
composer.self-update = false
# --------------------------------------------------------------------------------
# Directories
# --------------------------------------------------------------------------------
@@ -67,7 +49,7 @@ dir.tests = ${project.basedir}/tests
# Build directories
#
dir.build = ${project.basedir}/build
dir.reports = ${dir.build}/logs
dir.reports = ${dir.build}/reports
dir.reports.pdepend = ${dir.reports}/pdepend
dir.reports.coverage = ${dir.reports}/phpunit_coverage
@@ -88,12 +70,15 @@ dir.docker.logs = ${dir.docker}/logs/nginx
# Path of the PHP Coding Standards Fixer (http://cs.sensiolabs.org)
#
tests.cs_fixer.path = ./vendor/bin/php-cs-fixer
tests.cs_fixer.command = ./vendor/bin/php-cs-fixer fix --verbose
# Test database path
#
tests.database = ${dir.data.temporary}/database.sqlite
# Path of the framework used to run unit tests
# Paths of frameworks used to run tests:
# - PHPUnit (unit tests)
# - Infection (mutation tests)
#
tests.framework.path = ./vendor/bin/phpunit --verbose --no-coverage
tests.phpunit.command = ./vendor/bin/phpunit --verbose --no-coverage
tests.mutation.command = ./vendor/bin/infection --threads=5

View File

@@ -1,22 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
<!--
The AutoloaderTask is required to load binaries installed by Composer.
The "autoloaderpath" attribute of this task is not required, because it's default value is: vendor/autoload.php.
Meritoo <github@meritoo.pl>
2017-02-23
-->
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.16.0">
<autoloader/>
<!-- Properties -->
<if>
<available file="phing/properties" property="custom.properties.available"/>
<available file="${project.basedir}/phing/properties" property="custom.properties.available"/>
<then>
<property file="phing/properties"/>
<property file="${project.basedir}/phing/properties"/>
</then>
<else>
<property file="phing/properties.dist"/>
<property file="${project.basedir}/phing/properties.dist"/>
</else>
</if>
@@ -35,118 +29,48 @@
<!-- Default / main target -->
<target name="build:main"
depends="build:fix-coding-standards, build:clean, build:prepare, build:check, build:test, app:checkout"
description="Runs all tests and builds everything" />
<!--
Before:
depends="build:fix-coding-standards, build:clean, build:prepare, build:check, build:test, build:doc, app:checkout"
After:
depends="build:fix-coding-standards, build:clean, build:prepare, build:check, build:test, app:checkout"
The "build:doc" task is disabled, because it cannot be installed via Composer:
a) phpdocumentor/phpdocumentor v2.9.0 requires symfony/validator ~2.2
b) symfony/validator ~2.2 causes to remove symfony/symfony 3.*
Meritoo <github@meritoo.pl>
2017-02-22
-->
depends="build:fix-coding-standards,
build:clean,
build:prepare,
build:check,
build:test,
app:checkout"
/>
<!-- Fixing coding standards using the PHP Coding Standards Fixer (http://cs.sensiolabs.org) -->
<target name="build:fix-coding-standards" description="Fixes coding standards using the PHP Coding Standards Fixer">
<echo msg="Fixing coding standards using the PHP Coding Standards Fixer (http://cs.sensiolabs.org)..." />
<!--
Attention.
Rules for formatting are defined in /.php_cs.dist file.
-->
<exec
passthru="true"
command="${tests.cs_fixer.path} fix --verbose"
/>
<target name="build:fix-coding-standards">
<exec command="${tests.cs_fixer.command}" passthru="true"/>
</target>
<!-- Doc target -->
<!--
Disabled, because it cannot be installed via Composer:
a) phpdocumentor/phpdocumentor v2.9.0 requires symfony/validator ~2.2
b) symfony/validator ~2.2 causes to remove symfony/symfony 3.*
Meritoo <github@meritoo.pl>
2017-02-22
-->
<!--<target name="build:doc"-->
<!--depends="build:prepare, doc:phpdoc2"-->
<!--description="Generates API documentation" />-->
<!-- Check target -->
<target name="build:check"
depends="check:cs, check:md, check:cpd, check:depend, check:loc"
description="Analyzes code" />
depends="check:cs,
check:md,
check:cpd,
check:depend,
check:loc"
/>
<!-- Test target -->
<target name="build:test"
depends="test:unit"
description="Executes all tests" />
depends="test:phpunit,
test:infection"
/>
<!-- Project build clean -->
<target name="build:clean" description="Cleans up build directories">
<echo msg="Cleaning docs and reports directories..." />
<!--<delete dir="${dir.docs}" />-->
<target name="build:clean">
<delete dir="${dir.reports}"/>
</target>
<!-- Project build prepare -->
<target name="build:prepare" description="Create build directories">
<echo msg="Creating build directories..." />
<!--<mkdir dir="${dir.docs}" />-->
<!--<mkdir dir="${dir.docs.phpdoc2}" />-->
<target name="build:prepare">
<mkdir dir="${dir.reports}"/>
<mkdir dir="${dir.reports.pdepend}"/>
<mkdir dir="${dir.reports.coverage}"/>
</target>
<!-- PHPDocumentor2 API documentation target -->
<!--
Disabled, because it cannot be installed via Composer:
a) phpdocumentor/phpdocumentor v2.9.0 requires symfony/validator ~2.2
b) symfony/validator ~2.2 causes to remove symfony/symfony 3.*
Meritoo <github@meritoo.pl>
2017-02-22
<target name="doc:phpdoc2" description="Generates API documentations">
<echo msg="Generating API Documentation with phpDocumentor 2..." />
<phpdoc2 title="${phing.project.name}"
destdir="${dir.docs.phpdoc2}"
template="responsive">
<fileset refid="sourcecode" />
</phpdoc2>
</target>
-->
<!-- Symfony2 code sniffer -->
<!--
Attention 1.
To use Symfony2 standards to check coding you have to:
copy, symlink or check out repo to a folder called Symfony2 inside the phpcs Standards directory.
Example:
$ pear config-show | grep php_dir
$ cd /path/to/pear/PHP/CodeSniffer/Standards
$ git clone git://github.com/opensky/Symfony2-coding-standard.git Symfony2
Attention 2.
PSR2 standard is used instead of Symfony2 standard, because after installation squizlabs/php_codesniffer package
via Composer the Symfony2 standard is not included / available in this package. In this case the PHP Coding
Standards Fixer (http://cs.sensiolabs.org) is used.
Meritoo <github@meritoo.pl>
2017-02-22
-->
<target name="check:cs" description="Checks coding standard">
<echo msg="Checking coding standard..." />
<target name="check:cs">
<phpcodesniffer standard="PSR2" showWarnings="true">
<fileset refid="sourcecode"/>
<formatter type="checkstyle" outfile="${dir.reports}/checkstyle.xml"/>
@@ -156,26 +80,15 @@
</target>
<!-- copy/paste detector -->
<target name="check:cpd" description="Checks similar code blocks.">
<echo msg="Checking similar code blocks..." />
<target name="check:cpd">
<phpcpd>
<fileset refid="sourcecode"/>
<formatter type="pmd" outfile="${dir.reports}/pmd-cpd.xml"/>
</phpcpd>
<!--
Previous / old version
Meritoo <github@meritoo.pl>
2017-02-22
<exec command="phpcpd \-\-log-pmd=${dir.reports}/pmd-cpd.xml ${dir.src}" />
-->
</target>
<!-- Mess detector -->
<target name="check:md" description="Generate code metrics">
<echo msg="Generating code metrics..." />
<target name="check:md">
<phpmd rulesets="codesize,controversial,design,naming,unusedcode">
<fileset refid="sourcecode"/>
<formatter type="html" outfile="${dir.reports}/phpmd.html"/>
@@ -184,8 +97,7 @@
</target>
<!-- Code dependency -->
<target name="check:depend" description="Checks coupling and dependency">
<echo msg="Checking coupling and dependency..." />
<target name="check:depend">
<phpdepend>
<fileset refid="sourcecode"/>
<logger type="jdepend-xml" outfile="${dir.reports.pdepend}/jdepend.xml"/>
@@ -195,26 +107,20 @@
</target>
<!-- Measure the size and analyzing the structure of a project -->
<target name="check:loc" description="Measures the size and analyzes the structure of a project">
<echo msg="Measuring the size and analyzing the structure of a project..." />
<target name="check:loc">
<phploc reportType="txt" reportName="phploc" reportDirectory="${dir.reports}">
<fileset refid="sourcecode"/>
</phploc>
<!--
Previous / old version
Meritoo <github@meritoo.pl>
2017-02-22
<exec command="phploc \-\-log-csv=${dir.reports}/phploc.csv ${dir.src}" />
-->
</target>
<!-- Unit tests -->
<target name="test:unit" description="Runs unit tests">
<echo msg="Running unit tests..." />
<exec command="${tests.framework.path}" passthru="true"/>
<!-- PHPUnit tests -->
<target name="test:phpunit">
<exec command="${tests.phpunit.command}" passthru="true"/>
</target>
<!-- Run mutation testing -->
<target name="test:infection">
<exec command="${tests.mutation.command}" passthru="true"/>
</target>
<!-- Checkout and finalization -->