示例#1
0
 private function createReleaseName()
 {
     $releaseFolderNameFormat = $this->idx->getCurrentTarget()->get('deploy.release_folder_name_format');
     if ($this->messageIsRequested()) {
         $this->message = '-' . strtolower(str_replace(' ', '-', $this->message));
     }
     $this->timestamp = date('YmdHis');
     if ($this->releaseNameIsRequested($releaseFolderNameFormat)) {
         $this->timestamp = date($releaseFolderNameFormat);
     }
     $this->timestamp .= $this->message;
 }
示例#2
0
<?php

use Idephix\Idephix;
use Idephix\Extension\Deploy\Deploy;
use Idephix\Extension\PHPUnit\PHPUnit;
use Idephix\SSH\SshClient;
$idx = new Idephix();
$build = function () use($idx) {
    $idx->local('composer install --prefer-source');
    $idx->local('bin/phpunit -c tests');
};
$buildTravis = function () use($idx) {
    $idx->local('composer install --prefer-source');
    $idx->local('bin/phpunit -c tests --coverage-clover=clover.xml');
    $idx->runTask('createPhar');
};
$deployPhar = function () use($idx) {
    $idx->output->writeln('Releasing new phar version...');
    if (!file_exists('./idephix.phar')) {
        $idx->output->writeln('Idephix phar does not exists');
        exit(-1);
    }
    $new_version = $idx->local('cat .git/refs/heads/master');
    $commit_msg = trim($idx->local('git log -1 --pretty=%B'));
    if (false === strpos($commit_msg, '[release]')) {
        $idx->output->writeln("skipping, commit msg was '{$commit_msg}'");
        exit(0);
    }
    $current_version = file_get_contents('https://raw.githubusercontent.com/ideatosrl/getidephix.com/gh-pages/version');
    if ($new_version == $current_version) {
        $idx->output->writeln("version {$new_version} already deployed");
示例#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();
示例#4
0
文件: idxfile.php 项目: alemazz/iaac
<?php

use Idephix\Idephix;
use Idephix\Extension\Deploy\Deploy;
use Idephix\Extension\PHPUnit\PHPUnit;
$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);
示例#5
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());
 }