La fourchette 11/09/15

Simon C.

@kos_si

Phing

Simon C.

 

Architecte WEB

Travaille chez Theodo

Adepte de LEAN, SCRUM

et du devops

Qui suis je ?

Outil d'automatisation
de tâches

+

=

Comment ça marche ?

build.xml

<?xml version="1.0" encoding="utf-8"?>
<project name="lafourchette-module" basedir="." default="build">

    <import file="/usr/local/lib/phing/lafourchette-common.xml" />

    <!--
    ##################### Variables
    -->
    <property name="createBuildDir" value="true" />

    <!-- Nginx -->
    <property name="nginx.server_name.web" value="${domains.module}"/>
    <property name="nginx.log_path"        value="${project.basedir}/app/logs"/>
    <property name="nginx.root_path"       value="${project.basedir}/web"/>

    <!--
    ##################### Install
    -->
    <target name="install" description="Install" depends="check-sudo">
        <phingcall target="install:nginx" />
    </target>

    <!--
    ##################### Configure
    -->
    <target name="configure:parameters">
        <copy file="${project.basedir}/installer/parameters.ini.erb" tofile="${project.basedir}/app/config/parameters.ini" overwrite="true">
            <filterchain>
                <!-- Transform erb into dist file -->
                <replaceregexp>
                    <regexp pattern="<%=(\s+)?@?" replace="@@" ignoreCase="true" />
                    <regexp pattern="(\s+)?%>" replace="@@" ignoreCase="true" />
                    <regexp pattern="@@(.*)\['(.*)@@" replace="@@\1.\2@@" ignoreCase="true" />
                    <regexp pattern="@@(.*)'\](.*)@@" replace="@@\1\2@@" ignoreCase="true" />
                </replaceregexp>

                <!-- Project tokens -->
                <replacetokens begintoken="@@" endtoken="@@">

                    <token key="domains.myfourchette_api"     value="${domains.api.myfourchette}" />
                    <token key="domains.lafourchette_api"     value="${domains.api.lafourchette}" />
                    <token key="domains.lafourchette"         value="${domains.lafourchette}" />
                    <token key="domains.lafourchettesuisse"   value="${domains.lafourchettesuisse}" />
                    <token key="domains.thefork"              value="${domains.thefork}" />
                    <token key="domains.eltenedor"            value="${domains.eltenedor}" />

                </replacetokens>
            </filterchain>
        </copy>
    </target>

</project>

import de phing-common

création de variable

création d'une tâche

Détection des outils utilisés

<exec
    command="if [ -f '${project.basedir}/composer.lock' ]; 
                 then echo 'true';
                 else echo 'false';
             fi;"
    outputProperty="useComposer" />

Afficher dans le terminal

<echo>Use composer ${useComposer}</echo>

Faire des conditions

        <if>
            <equals arg1="${useComposer}" arg2="true" />
            <then>
                <phingcall target="composer:install" />
                <if>
                    <equals arg1="${isSymfony}" arg2="true" />
                    <then>
                        <phingcall target="symfony:cache:clear"/>
                        <phingcall target="symfony:assets:install"/>
                        <if>
                            <and>
                                <isset property="useAssetic" />
                                <istrue value="${useAssetic}" />
                            </and>
                            <then>
                                <phingcall target="symfony:assetic:dump"/>
                            </then>
                        </if>
                    </then>
                </if>
            </then>
        </if>

5

commandes

phing clean

  • phing symfony:clean
  • phing npm:clean
  • phing build:dir:clean

phing configure

  • phing configure:parameters

phing build

  • phing build:dir
  • phing composer:install
  • phing symfony:cache:clear
  • phing symfony:assets:install
  • phing symfony:assetic:dump
  • phing npm:install

sudo phing install

  • installation nginx
  • installation supervisord
  • ...

phing test

  • phing npm:test
  • phing phpunit
  • phing phpunit:ft
  • phing behat
  • phing phpspec

Mettre à jour phing-common

Ajouter son code

Attendre la fin des tests qui génère un package apt

(~15 minutes)

sudo apt-get update

sudo apt-get install phing-common

Question ?

Simon C. @kos_si

Merci !!!

Phing à la fourchette

By kosssi

Phing à la fourchette

  • 877
Loading comments...

More from kosssi