Exemple #1
0
    $idx->local('cd ~/docs && git config user.name "ideatobot"');
    $idx->local('cd ~/docs && git config user.email "*****@*****.**"');
    // copy new phar & commit
    $idx->local('cp -f idephix.phar ~/docs');
    $idx->local("cp -f .git/refs/heads/master ~/docs/version");
    $idx->local('cd ~/docs && git status');
    $idx->local('cd ~/docs && git add -A .');
    $idx->local("cd ~/docs && git commit -m 'deploy phar version {$new_version}'");
    $idx->local('cd ~/docs && git push -q origin gh-pages');
};
$createPhar = function () use($idx) {
    $idx->output->writeln('Creating phar...');
    $idx->local('rm -rf /tmp/Idephix && mkdir -p /tmp/Idephix');
    $idx->local("cp -R . /tmp/Idephix");
    $idx->local("cd /tmp/Idephix && rm -rf vendor");
    $idx->local("cd /tmp/Idephix && git checkout -- .");
    $idx->local('cd /tmp/Idephix && composer install --prefer-source --no-dev -o');
    $idx->local('bin/box build -c /tmp/Idephix/box.json ');
    $idx->output->writeln('Smoke testing...');
    $out = $idx->local('php idephix.phar');
    if (false === strpos($out, 'Idephix version')) {
        echo "Error!\n";
        exit(-1);
    }
    $idx->output->writeln('All good!');
};
$idx->add('deployPhar', $deployPhar);
$idx->add('createPhar', $createPhar);
$idx->add('buildTravis', $buildTravis);
$idx->add('build', $build);
$idx->run();
Exemple #2
0
$localBaseDir = __DIR__;
$sshParams = array('user' => 'ideato');
$targets = array('prod' => array('hosts' => array('127.0.0.1'), 'ssh_params' => $sshParams, 'deploy' => array('local_base_dir' => $localBaseDir, 'remote_base_dir' => "/var/www/myfantasticserver/", 'rsync_exclude_file' => 'rsync_exclude.txt')), 'stage' => array('hosts' => array('127.0.0.1'), 'ssh_params' => $sshParams, 'deploy' => array('local_base_dir' => $localBaseDir, 'remote_base_dir' => "/var/www/myfantasticserver/", 'rsync_exclude_file' => 'rsync_exclude.txt')), 'dev' => array('hosts' => array('127.0.0.1'), 'ssh_params' => array('user' => 'vagrant'), 'deploy' => array('local_base_dir' => $localBaseDir, 'remote_base_dir' => "/var/www/myfantasticserver/", 'rsync_exclude_file' => 'rsync_exclude.txt')));
$idx = new Idephix($targets);
$idx->add('project:deploy', function ($go = false) use($idx) {
    $env = $idx->getCurrentTargetName();
    if (!$go) {
        echo "\nDry Run\n";
    }
    $idx->setDryRun(!$go);
    $idx->setUpEnvironment();
    if (!$idx->isRemoteReady()) {
        $idx->bootstrap();
    }
    $idx->remotePrepare();
    $idx->getStrategy()->deploy();
    $idx->remoteLinkSharedFolders();
    if ($idx->hasToMigrate()) {
        $idx->doctrineMigrate();
    }
    $idx->remote('cd ' . $idx->getNextReleaseFolder() . '/app/config && rm -f parameters.yml', !$go);
    $idx->remote('cd ' . $idx->getNextReleaseFolder() . '/app/config && ln -s parameters.' . $env . '.yml parameters.yml', !$go);
    $idx->cacheClear();
    $idx->switchToTheNextRelease();
    $idx->assetic();
    $idx->deleteOldReleases(6);
    $idx->remote('cd ' . $idx->getNextReleaseFolder() . ' && rm -Rf app/cache/*', !$go);
})->add('test:run', function ($filter = '') use($idx) {
    $idx->runTask('test:run-group', 'unit', $filter);
    $idx->runTask('test:run-group', 'integration', $filter);
    $idx->runTask('test:run-group', 'command', $filter);
    $idx->runTask('test:run-group', 'functional', $filter);
Exemple #3
0
<?php

use Idephix\Idephix;
use Idephix\Extension\Deploy\Deploy;
use Idephix\Extension\PHPUnit\PHPUnit;
use Idephix\SSH\SshClient;
$sshParams = array('user' => 'ideato');
$targets = array('prod' => array('hosts' => array('127.0.0.1', '33.33.33.10'), 'ssh_params' => $sshParams, 'deploy' => array('local_base_dir' => __DIR__, 'remote_base_dir' => "/var/www/my-project/", 'rsync_exclude_file' => 'rsync_exclude.txt', 'shared_folders' => array('app/logs', 'web/uploads'))), 'stage' => array('hosts' => array('192.168.169.170'), 'ssh_params' => $sshParams, 'deploy' => array('local_base_dir' => __DIR__, 'remote_base_dir' => "/var/www/my-project.ideato.it/", 'rsync_exclude_file' => 'rsync_exclude.txt', 'shared_folders' => array('app/logs', 'web/uploads'))), 'test' => array('hosts' => array('127.0.0.1'), 'ssh_params' => array('user' => 'kea'), 'deploy' => array('local_base_dir' => __DIR__, 'remote_base_dir' => "/tmp/my-project.test/", 'shared_folders' => array('app/logs', 'web/uploads'))));
$idx = new Idephix($targets, new SshClient());
$idx->add('hello', function () {
    echo 'Output by custom idx file!';
})->add('idephix:test-params', function ($param1, $param2, $param3 = 'default') {
    echo "{$param1} {$param2} {$param3}";
});
$idx->addLibrary('deploy', new Deploy());
$idx->addLibrary('phpunit', new PHPUnit());
$idx->run();
Exemple #4
0
 /**
  * @dataProvider getTaskAndReturnCode
  */
 public function testReturnCode($task, $expected)
 {
     $_SERVER['argv'] = array('idx', $task);
     $output = fopen("php://memory", 'r+');
     $idx = new Idephix(array(), new SSH\SshClient(new SSH\FakeSsh2Proxy($this)), new StreamOutput($output));
     $idx->getApplication()->setAutoExit(false);
     $idx->add('fooOk', function () use($idx) {
         $idx->local("echo 'God save the Queen'");
     });
     $idx->add('fooKo', function () use($idx) {
         $idx->local("God save the Queen but this command will fail!");
     });
     $this->assertEquals($expected, $idx->run());
 }