mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Phing > update configuration
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
Common and useful classes, methods, exceptions etc.
|
||||
|
||||
# 0.1.4
|
||||
|
||||
1. Phing > update configuration
|
||||
|
||||
# 0.1.3
|
||||
|
||||
1. Tests > refactoring & minor improvements
|
||||
|
||||
20
build.xml
20
build.xml
@@ -14,7 +14,7 @@
|
||||
<!-- Default / main target -->
|
||||
<target name="build:main"
|
||||
depends="build:app, build:tests"
|
||||
description="Builds everything and runs all tests" />
|
||||
description="Builds everything and runs all tests"/>
|
||||
|
||||
<!-- Build app -->
|
||||
<target name="build:app" description="Prepares app to build and tests">
|
||||
@@ -24,23 +24,5 @@
|
||||
<!-- Build tests -->
|
||||
<target name="build:tests" description="Runs all tests, checks and creates docs">
|
||||
<phing phingfile="phing/tests.xml" haltonfailure="true"/>
|
||||
|
||||
<!--
|
||||
Conditional running of tests.
|
||||
Disabled, because not required.
|
||||
|
||||
Meritoo <github@meritoo.pl>
|
||||
2017-02-22
|
||||
|
||||
<if>
|
||||
<equals arg1="${env}" arg2="test" />
|
||||
<then>
|
||||
<phing phingfile="phing/tests.xml" haltonfailure="true" />
|
||||
</then>
|
||||
<else>
|
||||
<echo message="[Skipped] Running tests, checks and creating docs, because it's a not 'test' environment..." />
|
||||
</else>
|
||||
</if>
|
||||
-->
|
||||
</target>
|
||||
</project>
|
||||
|
||||
173
phing/app.xml
173
phing/app.xml
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
|
||||
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.16.0">
|
||||
<!-- Properties -->
|
||||
<if>
|
||||
<available file="phing/properties" property="custom.properties.available"/>
|
||||
@@ -11,50 +11,119 @@
|
||||
</else>
|
||||
</if>
|
||||
|
||||
<!-- Filesets -->
|
||||
<import file="phing/filesets.xml"/>
|
||||
|
||||
<!-- Default / main target -->
|
||||
<target name="build:main"
|
||||
depends="build:app"
|
||||
description="Builds the application" />
|
||||
description="Builds the application"/>
|
||||
|
||||
<!-- App target -->
|
||||
<target name="build:app"
|
||||
depends="app:composer, app:vendors, app:checkout"
|
||||
description="Prepares app to build." />
|
||||
depends="app:clean, app:composer, app:vendors, app:composer-validate, app:checkout"
|
||||
description="Prepares app to build."/>
|
||||
|
||||
<!-- Updates Composer and validates composer.* files -->
|
||||
<target name="app:composer" description="Updates Composer and validates composer.* files">
|
||||
<echo msg="Updating Composer and validating composer.* files..." />
|
||||
<!-- Updates Composer -->
|
||||
<target name="app:composer" description="Updates Composer">
|
||||
<echo msg="Updating Composer..."/>
|
||||
|
||||
<if>
|
||||
<available file="composer.phar" />
|
||||
<available file="composer.phar"/>
|
||||
<then>
|
||||
<echo msg="[Skipped] Downloading of Composer skipped, because exist in the project..." />
|
||||
<echo msg="[Skipped] Downloading of Composer skipped, because exist in the project..."/>
|
||||
</then>
|
||||
<else>
|
||||
<if>
|
||||
<os family="windows" />
|
||||
<os family="windows"/>
|
||||
<then>
|
||||
<fail message="Composer not found! Go to http://getcomposer.org/download and download the Composer." />
|
||||
<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"/>
|
||||
</else>
|
||||
</if>
|
||||
</else>
|
||||
</if>
|
||||
|
||||
<!-- Update Composer -->
|
||||
<composer command="selfupdate" />
|
||||
<composer command="selfupdate"/>
|
||||
</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" />
|
||||
<arg line="--no-check-all --strict"/>
|
||||
</composer>
|
||||
</target>
|
||||
|
||||
<!-- Project clean -->
|
||||
<target name="app:clean" description="Clears app's directories">
|
||||
<echo msg="Cleaning project..."/>
|
||||
<if>
|
||||
<equals arg1="${env}" arg2="prod"/>
|
||||
<then>
|
||||
<echo message="[Skipped] Cleaning project (and directories cleanup) skipped, because of '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">
|
||||
<if>
|
||||
<available file="${directory}" type="dir"/>
|
||||
<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">
|
||||
<if>
|
||||
<not>
|
||||
<available file="${directory}" type="dir"/>
|
||||
</not>
|
||||
<then>
|
||||
<if>
|
||||
<or>
|
||||
<contains string="${directory}" substring="cache"/>
|
||||
<contains string="${directory}" substring="logs"/>
|
||||
<contains string="${directory}" substring="sessions"/>
|
||||
</or>
|
||||
<then>
|
||||
<mkdir dir="${directory}" mode="0777"/>
|
||||
</then>
|
||||
<else>
|
||||
<mkdir dir="${directory}" mode="0775"/>
|
||||
</else>
|
||||
</if>
|
||||
</then>
|
||||
</if>
|
||||
</target>
|
||||
|
||||
<!-- Project Install/update vendors -->
|
||||
<target name="app:vendors" description="Installs / updates vendors">
|
||||
<echo msg="Installing / updating vendors..." />
|
||||
<echo msg="Installing / updating vendors..."/>
|
||||
|
||||
<if>
|
||||
<istrue value="${composer.self-update}"/>
|
||||
@@ -63,36 +132,76 @@
|
||||
</then>
|
||||
</if>
|
||||
|
||||
<if>
|
||||
<istrue value="${composer.validate}"/>
|
||||
<then>
|
||||
<composer php="${composer.php}" composer="${composer.path}" command="validate"/>
|
||||
</then>
|
||||
</if>
|
||||
<composer php="${composer.php}" composer="${composer.path}" command="install">
|
||||
<arg value="--optimize-autoloader"/>
|
||||
<arg value="--prefer-dist"/>
|
||||
<arg value="--classmap-authoritative"/>
|
||||
</composer>
|
||||
</target>
|
||||
|
||||
<!-- Clearing cache -->
|
||||
<target name="app:cache" description="Clears project cache and logs">
|
||||
<echo msg="Clearing cache..."/>
|
||||
|
||||
<if>
|
||||
<equals arg1="${env}" arg2="prod" />
|
||||
<istrue value="${cache.clearWithWarmup}"/>
|
||||
<then>
|
||||
<composer php="${composer.php}" composer="${composer.path}" command="install">
|
||||
<arg value="--optimize-autoloader" />
|
||||
<arg value="--prefer-dist" />
|
||||
<arg value="--classmap-authoritative" />
|
||||
</composer>
|
||||
<echo message="...with warm up"/>
|
||||
|
||||
<SymfonyConsole console="bin/console" command="cache:clear">
|
||||
<arg name="env" value="${env}"/>
|
||||
</SymfonyConsole>
|
||||
</then>
|
||||
<else>
|
||||
<composer php="${composer.php}" composer="${composer.path}" command="install" />
|
||||
<echo message="...without warm up"/>
|
||||
|
||||
<SymfonyConsole console="bin/console" command="cache:clear">
|
||||
<arg name="env" value="${env}"/>
|
||||
<arg name="no-warmup"/>
|
||||
</SymfonyConsole>
|
||||
</else>
|
||||
</if>
|
||||
</target>
|
||||
|
||||
<!-- Clearing cache (faster) -->
|
||||
<target name="app:cache:faster" description="Clears project cache and logs (faster)">
|
||||
<echo msg="Clearing cache (faster)..."/>
|
||||
|
||||
<SymfonyConsole console="bin/console" command="cache:clear">
|
||||
<arg name="env" value="${env}"/>
|
||||
<arg name="no-optional-warmers"/>
|
||||
</SymfonyConsole>
|
||||
</target>
|
||||
|
||||
<!-- Warming up cache -->
|
||||
<target name="app:cache:warmup" description="Warms up project cache">
|
||||
<echo msg="Warming up cache..."/>
|
||||
|
||||
<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">
|
||||
<if>
|
||||
<not>
|
||||
<os family="windows"/>
|
||||
</not>
|
||||
<then>
|
||||
<exec command="chmod -R 777 ${directory}/*"/>
|
||||
</then>
|
||||
</if>
|
||||
</target>
|
||||
|
||||
<!-- Checkout and finalization -->
|
||||
<target name="app:checkout">
|
||||
<tstamp>
|
||||
<format property="date_end" pattern="%Y-%m-%d %H:%M" />
|
||||
<format property="date_end" pattern="%Y-%m-%d %H:%M"/>
|
||||
</tstamp>
|
||||
|
||||
<echo msg="------------------------------------" />
|
||||
<echo msg="Build finished at: ${date_end}" />
|
||||
<echo msg="------------------------------------" />
|
||||
<echo msg="------------------------------------"/>
|
||||
<echo msg="Build finished at: ${date_end}"/>
|
||||
<echo msg="------------------------------------"/>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
35
phing/filesets.xml
Normal file
35
phing/filesets.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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}">
|
||||
<include name="**/*"/>
|
||||
<exclude name=".gitkeep"/>
|
||||
</fileset>
|
||||
<fileset id="logs" dir="${dir.logs}">
|
||||
<include name="**/*"/>
|
||||
<exclude name=".gitkeep"/>
|
||||
</fileset>
|
||||
<fileset id="sessions" dir="${dir.sessions}">
|
||||
<include name="**/*"/>
|
||||
<exclude name=".gitkeep"/>
|
||||
</fileset>
|
||||
|
||||
<!-- Directories to check -->
|
||||
<property name="directoriesToCheck" value="
|
||||
${dir.cache},
|
||||
${dir.logs},
|
||||
${dir.sessions},
|
||||
${dir.data.tests},
|
||||
${dir.data.temporary},
|
||||
${dir.docker.data},
|
||||
${dir.docker.logs}"
|
||||
/>
|
||||
|
||||
<!-- Directories to empty -->
|
||||
<property name="directoriesToEmpty" value="
|
||||
${dir.cache},
|
||||
${dir.logs},
|
||||
${dir.sessions},
|
||||
${dir.data.temporary}"
|
||||
/>
|
||||
</project>
|
||||
@@ -9,7 +9,7 @@
|
||||
# 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.web}/js
|
||||
# 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}
|
||||
@@ -22,10 +22,6 @@
|
||||
#
|
||||
env = dev
|
||||
|
||||
# Install assets using symlinks
|
||||
#
|
||||
assets.installWithSymlink = true
|
||||
|
||||
# Clear cache with the "warmup" option
|
||||
#
|
||||
# The cache:clear command should always be called with the --no-warmup option. Warmup should be done via the cache:warmup command.
|
||||
@@ -45,7 +41,6 @@ composer.download_command = php -r "eval('?>'.file_get_contents('https://getcomp
|
||||
# Path to composer executable or composer.phar file
|
||||
#
|
||||
composer.path = composer.phar
|
||||
#composer.path = /usr/local/bin/composer
|
||||
|
||||
# Path to php executable used by composer
|
||||
#
|
||||
@@ -55,52 +50,49 @@ composer.php = php
|
||||
#
|
||||
composer.self-update = false
|
||||
|
||||
# Validate the composer.json file
|
||||
#
|
||||
composer.validate = false
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Directories
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
# System directories
|
||||
#
|
||||
dir.data = ${project.basedir}/data
|
||||
dir.src = ${project.basedir}/src
|
||||
dir.var = ${project.basedir}/tests/Resources/var
|
||||
dir.cache = ${dir.var}/cache
|
||||
dir.logs = ${dir.var}/log
|
||||
dir.sessions = ${dir.var}/sessions
|
||||
dir.data = ${project.basedir}/data
|
||||
dir.tests = ${project.basedir}/tests
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Build directories
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
dir.build = ${project.basedir}/build
|
||||
dir.reports = ${dir.build}/logs
|
||||
dir.reports.pdepend = ${dir.reports}/pdepend
|
||||
dir.reports.coverage = ${dir.reports}/phpunit_coverage
|
||||
#
|
||||
# Disabled, because unnecessary right now
|
||||
# phpdocumentor/phpdocumentor cannot be installed via Composer
|
||||
#
|
||||
# Meritoo <github@meritoo.pl>
|
||||
# 2017-02-22
|
||||
#
|
||||
#dir.docs = ${dir.build}/docs
|
||||
#dir.docs.phpdoc2 = ${dir.docs}/phpdoc2
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Data directories
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
dir.data.tests = ${dir.data}/tests
|
||||
dir.data.temporary = ${dir.data}/tmp
|
||||
|
||||
# Docker directories
|
||||
#
|
||||
dir.docker = ${project.basedir}/docker
|
||||
dir.docker.data = ${dir.docker}/data/db
|
||||
dir.docker.logs = ${dir.docker}/logs/nginx
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Testing
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
# Path of the PHP Coding Standards Fixer (http://cs.sensiolabs.org)
|
||||
#
|
||||
tests.cs_fixer.path = ./vendor/bin/php-cs-fixer
|
||||
|
||||
# Test database path
|
||||
#
|
||||
tests.database = ${dir.data.temporary}/database.sqlite
|
||||
|
||||
# Path of the framework used to run unit tests
|
||||
#
|
||||
tests.framework.path = ./vendor/bin/phpunit --verbose --no-coverage --testdox
|
||||
|
||||
# Path of the PHP Coding Standards Fixer (http://cs.sensiolabs.org)
|
||||
#
|
||||
phpCsFixer.path = ./vendor/bin/php-cs-fixer
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
<exec
|
||||
passthru="true"
|
||||
command="${phpCsFixer.path} fix --verbose"
|
||||
command="${tests.cs_fixer.path} fix --verbose"
|
||||
/>
|
||||
</target>
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
</target>
|
||||
|
||||
<!-- Unit tests -->
|
||||
<target name="test:unit" description="Executes unit tests">
|
||||
<target name="test:unit" description="Runs unit tests">
|
||||
<echo msg="Running unit tests..." />
|
||||
<exec command="${tests.framework.path}" passthru="true"/>
|
||||
</target>
|
||||
|
||||
0
tests/Resources/var/cache/.gitkeep
vendored
Normal file
0
tests/Resources/var/cache/.gitkeep
vendored
Normal file
0
tests/Resources/var/log/.gitkeep
Normal file
0
tests/Resources/var/log/.gitkeep
Normal file
0
tests/Resources/var/sessions/.gitkeep
Normal file
0
tests/Resources/var/sessions/.gitkeep
Normal file
Reference in New Issue
Block a user