Jenkins alternative : Buildbot

from this website : https://www.blazemeter.com/blog/jenkins-vs-other-open-source-continuous-integration-servers

Buildbot is another software development continuous integration tool which is trusted by the Mozilla Foundation for bringing excellence into their products, and is now used at Mozilla, Chromium, WebKit and many other projects.

Buildbot started as a lightweight alternative to Mozilla Tinderbox and currently it’s a fully functional continuous development and build server supporting a lot of integrations, distributed builds, custom (and often unique) build steps, notifications via multiple channels and many more.

Buildbot is a Python-based tool, and as such, it runs everywhere Python runs. You can deploy it onto any POSIX-compliant operating system. Moreover, Buildbot config files are basically Python scripts, meaning that the configuration is version-control friendly and you have all the power of the Python language while defining your build plan. It means extreme and unbeatable flexibility and capabilities.

As for July 2016, Buildbot supports out of the box:

Version Control Systems:
Mercurial
Subversion
Git
CVS
Perforce
Bzr
Repo
Gerrit
Monotone
Darcs
Builders:
Command-line
Configure (autoconf-style projects)
Compile (C projects)
VC++ (Microsoft compilers)
Robocopy
Test (analogue of make test)
TreeSize – check repo size
Perl Module Test
Mysql-test-run
Notifications
Email Notification
IRC Bot
PBListener
HTTP Status Push
Gerrit Status Push
Github Status Push
Stash Status Push

Buildbot installation and configuration is a separate large topic as the instructions may differ depending on each operating system and architecture, so it is better to refer to Buildbot documentation. However if you’re looking for quick and dirty way to get it running and see if it fits your needs, here are minimal instructions:

Install Python. Most Linux and MacOSX distributions come with Python, on Windows you’ll have to install it manually. Make sure you have at least the 2.7.X version.

Make sure you have the following binaries in your PATH (on Windows they should be located under the “Scripts” folder of your Python installation):

Python itself
pip – a Python package management system
Easy install – a script which simplifies installation of Python packages
Run the following commands:
pip install buildbot – installs the Buildbot master (or server)
buildbot create-master /path/to/buildbot/working/folder – sets up some of the initial configuration for the buildbot server

pip install buildbot-worker – installs the Buildbot worker
buildbot-worker create-worker worker localhost:9989 example-worker pass – creates the Buildbot agent with default parameters

Start the Buildbot server: buildbot start /path/to/buildbot/working/folder .
Start the Buildbot slave: buildbot-worker start worker .
Open the following url in your browser: http://localhost:8010 (unless you changed it to something different in the master.cfg file).
If you plan to run a JMeter test, add a Builder such as:

factory.addStep(steps.ShellCommand(command=[« c:/jmeter/bin/jmeter.bat -n -t c:/buildbot/Test.jmx -l C:/buildbot/test.jtl »]))

to your master.cfg file.

Here is the Buildbot dashboard with one build currently running along with the history of several previous test executions:

Increase image

Symfony and Co mposer

A little reminder for the current development.

With this test project : https://github.com/brunomartin/symfony-test

For using SQLite, need to modify conifig/config.yml :

doctrine:
dbal:
pdo_mysql -> pdo_sqlite
path: %kernel.cache_dir%/test.db

>symfony new comptes
>cd comptes/
>php bin/console server:run # to test
>php bin/console generate:controller # to create a controller
>php bin/console doctrine:generate:entity # to create entity
>php bin/console doctrine:database:create
>php bin/console doctrine:schema:update --force
>php bin/console doctrine:schema:validate

Si il y a eu mise à jour des entités :
php bin/console doctrine:generate:entities AppBundle
générera tous les getter et setter pour les champs.

Pour créer des entités à partir de la ligne de commande
bin/console doctrine:generate:entity -n --entity AppBundle:User --fields="name:string(100) age:int sexe:string(1)"

Pour créer des controller à partir de la ligne de commande
bin/console generate:controller -n --controller=AppBundle:User --actions="addUserAction:/add_user:AppBundle:User:add_user.html.twig"

Pour définir des relations entre entités:

class Operation
{
...
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="operations")
**/
private $user;
...
}

class User
{

/**
* @ORM\OneToMany(targetEntity= »Operation », mappedBy= »user »)
* @var Operation[] An ArrayCollection of Operation objects.
**/
private $operations = null;

}

Pour générer un form
php bin/console doctrine:generate:form AppBundle:User
Puis dans un action d’un controller
...
use AppBundle\Entity\User;
use AppBundle\Form\UserType;
use Symfony\Component\HttpFoundation\Request;
...
public function addUserAction(Request $request)
{
$em = $this->getDoctrine()->getManager();

$user = new User();
$user->setName(« Bruno »);

$form = $this->createForm(UserType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$user = $form->getData();
$em->persist($user);
$em->flush();
return $this->redirectToRoute(‘homepage’);
}

return $this->render(‘AppBundle:User:add_user.html.twig’, array(
‘form’ => $form->createView(),
));
}

And in the corresponding twig template :
{{ form_start(form) }}
{{ form_widget(form) }}
<input type="submit" value="Create" class="btn btn-default pull-right" />
{{ form_end(form) }}

Pour l’environnement de production :

php bin/console cache:clear --no-warmup --env=prod
php bin/console doctrine:schema:update --force --env=prod

Pour servir le site avec apache, installer libapach2-mod-php, installer le site dans /usr/share, donner les droits suffisants au user www-data, créer une configuration dans site-avaible symfony.conf

<VirtualHost *:80>
    ServerName home.brunocsmartin.fr
    ServerAlias www.home.brunocsmartin.fr

    DocumentRoot /usr/share/symfony/web
    <Directory /usr/share/symfony/web>
        AllowOverride All
        Order Allow,Deny
  Allow from all

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
    </Directory>

    Alias /symfony /usr/share/symfony/web/

    <Directory /usr/share/symfony/web/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
        </IfModule>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/project_error.log
    CustomLog ${APACHE_LOG_DIR}/project_access.log combined    

</VirtualHost>

<IfModule mod_ssl.c>

<VirtualHost *:443>
    ServerName home.brunocsmartin.fr
    ServerAlias www.home.brunocsmartin.fr

    DocumentRoot /usr/share/symfony/web

    Alias /symfony /usr/share/symfony/web/
    <Directory /usr/share/symfony/web>
  Options All
        AllowOverride All
        Order Allow,Deny
  Allow from all

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
    </Directory>

    <Directory /usr/share/symfony/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
        </IfModule>
    </Directory>

    SSLEngine on
    SSLCertificateFile	/etc/letsencrypt/live/home.brunocsmartin.fr/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/home.brunocsmartin.fr/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/home.brunocsmartin.fr/chain.pem

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
        SSLOptions +StdEnvVars
    </Directory>


</VirtualHost>

</IfModule>

et appliquer les bonnes permissions :

sudo setfacl -R -m u:www-data:rX /usr/share/symfony/
sudo setfacl -R -m u:www-data:rwX /usr/share/symfony/
sudo setfacl -dR -m u:www-data:rwX /usr/share/symfony/