<commit_before><?php
class Vps_Controller_Action_Cli_GoOnlineController extends Vps_Controller_Action_Cli_Abstract
{
    public static function getHelp()
    {
        if (!Vps_Controller_Action_Cli_TagController::getProjectName()) return null;
        if (Vps_Registry::get('config')->server->host != 'vivid') return null;
        return "go online";
    }

    public static function getHelpOptions()
    {
        $ret = Vps_Controller_Action_Cli_TagController::getHelpOptions();
        $ret['vpsVersion']['allowBlank'] = false;
        $ret['webVersion']['allowBlank'] = false;
        $ret[] = array('param' => 'skip-test');
        $ret[] = array('param' => 'skip-prod');
        return $ret;
    }

    private function _systemSshVps($cmd, $config)
    {
        $sshHost = $config->server->user.'@'.$config->server->host;
        $sshDir = $config->server->dir;
        $cmd = "sshvps $sshHost $sshDir $cmd";
        $cmd = "sudo -u www-data $cmd";
        return $this->_systemCheckRet($cmd);
    }

    public function indexAction()
    {
        Zend_Session::start(); //wegen tests

        $prodConfig = new Zend_Config_Ini('application/config.ini', 'production');
        if (!$prodConfig || !$prodConfig->server->host || !$prodConfig->server->dir) {
            throw new Vps_ClientException("Prod-Server not configured");
        }

        $testConfig = new Zend_Config_Ini('application/config.ini', 'test');
        if (!$testConfig || !$testConfig->server->host || !$testConfig->server->dir) {
            throw new Vps_ClientException("Test-Server not configured");
        }
        if ($testConfig->server->dir == $prodConfig->server->dir) {
            throw new Vps_ClientException("Test-Server not configured, same dir as production");
        }
        $vpsVersion = $this->_getParam('vps-version');
        $webVersion = $this->_getParam('web-version');


        echo "\n\n*** [00/13] ueberpruefe auf nicht eingecheckte dateien\n";
        echo "lokaler-server:\n";
        Vps_Controller_Action_Cli_SvnUpController::checkForModifiedFiles();
        echo "test-server:\n";
        $this->_systemSshVps("svn-up check-for-modified-files", $testConfig);
        echo "prod-server:\n";
        $this->_systemSshVps("svn-up check-for-modified-files", $prodConfig);

        echo "\n\n*** [01/13] vps-tag erstellen\n";
        Vps_Controller_Action_Cli_TagController::createVpsTag($this->_getParam('vps-branch'), $vpsVersion);

        echo "\n\n*** [02/13] web-tag erstellen\n";
        Vps_Controller_Action_Cli_TagController::createWebTag($this->_getParam('web-branch'), $webVersion);

        echo "\n\n*** [03/13] vps tag auschecken\n";
        $this->_systemSshVps("tag-checkout vps-checkout --version=$vpsVersion", $testConfig);

        echo "\n\n*** [04/13] test: vps-version anpassen\n";
        $this->_systemSshVps("tag-checkout vps-use --version=$vpsVersion", $testConfig);

        echo "\n\n*** [05/13] test: web tag switchen\n";
        $this->_systemSshVps("tag-checkout web-switch --version=$webVersion", $testConfig);

        echo "\n\n*** [06/13] prod daten auf test uebernehmen\n";
        $this->_systemSshVps("import", $testConfig);

        echo "\n\n*** [07/13] test: unit-tests laufen lassen\n";
        if ($this->_getParam('skip-test')) {
            echo "(uebersprungen)\n";
        } else {
            Vps_Controller_Action_Cli_TestController::initForTests();
            $suite = new Vps_Test_TestSuite();
            $runner = new PHPUnit_TextUI_TestRunner;

            Vps_Registry::set('testDomain', $testConfig->server->domain);
            Vps_Registry::set('testServerConfig', $testConfig);

            $arguments = array();
            $arguments['colors'] = true;
            $arguments['stopOnFailure'] = true;
            $result = $runner->doRun($suite, $arguments);
            if (!$result->wasSuccessful()) {
                $this->_systemSshVps("tag-checkout web-switch --version=trunk", $testConfig);
                $this->_systemSshVps("tag-checkout vps-use --version=trunk", $testConfig);
                throw new Vps_ClientException("Tests failed");
            }
        }

        echo "\n\n*** [08/13] test: web zurueck auf trunk switchen\n";
        $this->_systemSshVps("tag-checkout web-switch --version=trunk", $testConfig);<commit_msg>möglichkeit eingebaut um check zu ignorieren<commit_after><?php
class Vps_Controller_Action_Cli_GoOnlineController extends Vps_Controller_Action_Cli_Abstract
{
    public static function getHelp()
    {
        if (!Vps_Controller_Action_Cli_TagController::getProjectName()) return null;
        if (Vps_Registry::get('config')->server->host != 'vivid') return null;
        return "go online";
    }

    public static function getHelpOptions()
    {
        $ret = Vps_Controller_Action_Cli_TagController::getHelpOptions();
        $ret['vpsVersion']['allowBlank'] = false;
        $ret['webVersion']['allowBlank'] = false;
        $ret[] = array('param' => 'skip-test');
        $ret[] = array('param' => 'skip-prod');
        $ret[] = array('param' => 'skip-check');
        return $ret;
    }

    private function _systemSshVps($cmd, $config)
    {
        $sshHost = $config->server->user.'@'.$config->server->host;
        $sshDir = $config->server->dir;
        $cmd = "sshvps $sshHost $sshDir $cmd";
        $cmd = "sudo -u www-data $cmd";
        return $this->_systemCheckRet($cmd);
    }

    public function indexAction()
    {
        Zend_Session::start(); //wegen tests

        $prodConfig = new Zend_Config_Ini('application/config.ini', 'production');
        if (!$prodConfig || !$prodConfig->server->host || !$prodConfig->server->dir) {
            throw new Vps_ClientException("Prod-Server not configured");
        }

        $testConfig = new Zend_Config_Ini('application/config.ini', 'test');
        if (!$testConfig || !$testConfig->server->host || !$testConfig->server->dir) {
            throw new Vps_ClientException("Test-Server not configured");
        }
        if ($testConfig->server->dir == $prodConfig->server->dir) {
            throw new Vps_ClientException("Test-Server not configured, same dir as production");
        }
        $vpsVersion = $this->_getParam('vps-version');
        $webVersion = $this->_getParam('web-version');


        echo "\n\n*** [00/13] ueberpruefe auf nicht eingecheckte dateien\n";
        if ($this->_getParam('skip-check')) {
            echo "(uebersprungen)\n";
        } else {
            echo "lokaler-server:\n";
            Vps_Controller_Action_Cli_SvnUpController::checkForModifiedFiles();
            echo "test-server:\n";
            $this->_systemSshVps("svn-up check-for-modified-files", $testConfig);
            echo "prod-server:\n";
            $this->_systemSshVps("svn-up check-for-modified-files", $prodConfig);
        }

        echo "\n\n*** [01/13] vps-tag erstellen\n";
        Vps_Controller_Action_Cli_TagController::createVpsTag($this->_getParam('vps-branch'), $vpsVersion);

        echo "\n\n*** [02/13] web-tag erstellen\n";
        Vps_Controller_Action_Cli_TagController::createWebTag($this->_getParam('web-branch'), $webVersion);

        echo "\n\n*** [03/13] vps tag auschecken\n";
        $this->_systemSshVps("tag-checkout vps-checkout --version=$vpsVersion", $testConfig);

        echo "\n\n*** [04/13] test: vps-version anpassen\n";
        $this->_systemSshVps("tag-checkout vps-use --version=$vpsVersion", $testConfig);

        echo "\n\n*** [05/13] test: web tag switchen\n";
        $this->_systemSshVps("tag-checkout web-switch --version=$webVersion", $testConfig);

        echo "\n\n*** [06/13] prod daten auf test uebernehmen\n";
        $this->_systemSshVps("import", $testConfig);

        echo "\n\n*** [07/13] test: unit-tests laufen lassen\n";
        if ($this->_getParam('skip-test') || $this->_getParam('skip-tests')) {
            echo "(uebersprungen)\n";
        } else {
            Vps_Controller_Action_Cli_TestController::initForTests();
            $suite = new Vps_Test_TestSuite();
            $runner = new PHPUnit_TextUI_TestRunner;

            Vps_Registry::set('testDomain', $testConfig->server->domain);
            Vps_Registry::set('testServerConfig', $testConfig);

            $arguments = array();
            $arguments['colors'] = true;
            $arguments['stopOnFailure'] = true;
            $result = $runner->doRun($suite, $arguments);
            if (!$result->wasSuccessful()) {
                $this->_systemSshVps("tag-checkout web-switch --version=trunk", $testConfig);
                $this->_systemSshVps("tag-checkout vps-use --version=trunk", $testConfig);
                throw new Vps_ClientException("Tests failed");
            }
        }

        echo "\n\n*** [08/13] test: web zurueck auf trunk switchen\n";
        $this->_systemSshVps("tag-checkout web-switch --version=trunk", $testConfig);
{'fraction_non_alphanumeric': 0.16053962900505903, 'fraction_numerical': 0.008094435075885328, 'mean_word_length': 2.824591573516767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 88, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5209628', 'n_tokens_mistral': 2824, 'n_tokens_neox': 2730, 'n_words': 497}