Executes build for specified RoboCI environment

@param $environment
@param string $args additional arguments
@return int
359307
public function ciRun($environment, $args = '')
    {
        $runner = new Runner($environment);
        $runner->buildImage();
        $runner->runServices();
        $res = $runner->getContainerRunner()
            ->exec($runner->getRunCommand())
            ->args($args)
            ->run();

        $runner->stopServices();

        !$res->getExitCode()
            ? $this->yell('BUILD SUCCESSFUL')
            : $this->say("<error> BUILD FAILED </error>");

        $data = $res->getData();
        $this->say("To enter this container, save it with <info>docker commit {$data['cid']} travis_build_failed<info>");
        $this->say('Then you can run it: <info>docker run -i -t travis_build_failed bash</info>');
    }
1190583
protected function process(EnvironmentInterface $environment)
    {
        $inputProvider = $environment->getInputProvider();
        $modelId       = ModelId::fromSerialized($inputProvider->getParameter('id'));
        $dataProvider  = $environment->getDataProvider($modelId->getDataProviderName());

        $view = $environment->getView();
        if (!$view instanceof BaseView) {
            return false;
        }

        $this->checkRestoreVersion($environment, $modelId);

        if (!($model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())))) {
            throw new DcGeneralRuntimeException('Could not retrieve model with id ' . $modelId->getSerialized());
        }

        $clone = clone $model;
        $clone->setId($model->getId());

        if ('select' !== $inputProvider->getParameter('act')) {
            $this->handleGlobalCommands($environment);
        }

        return (new EditMask($view, $model, $clone, null, null, $view->breadcrumb()))->execute();
    }
737015
public function run($args)
    {
        list($action, $options, $args) = $this->resolveRequest($args);

        foreach ($options as $key => $value) {
            if (property_exists($this, $key)) {
                $this->$key = $value;
            }
        }

        $binPath = $this->resolveBinPath();
        $options = $this->normalizeOptions($this->options);
        $database = $this->resolveDatabaseName();
        $dumpPath = $this->resolveDumpPath();

        return $this->process(
            "$binPath $options $database",
            array(
                self::DESCRIPTOR_STDIN  => array('pipe', 'r'),
                self::DESCRIPTOR_STDOUT => array('file', $dumpPath, 'w'),
                self::DESCRIPTOR_STDERR => array('pipe', 'w'),
            )
        );
    }
400814
public function execute(array $args, array $options = [])
    {
        $rootDir = null;
        if (isset($options['root-dir']) && !empty($options['root-dir'])) {
            $rootDir = $options['root-dir'];
        }
        StaticResource::createSymbolicLink($rootDir);
    }
457743
public static function detectEnv(array $environments, $uri)
        {
            foreach ($environments as $environment => $patterns) {
                // Essentially we just want to loop through each environment pattern
                // and determine if the current URI matches the pattern and if so
                // we will simply return the environment for that URI pattern.
                foreach ($patterns as $pattern) {
                    if (Inflector::is($pattern, $uri) or $pattern == gethostname()) {
                        return $environment;
                    }
                }
            }
        }
1293056
public function setEnvironment($environment)
    {
        switch ($environment) {
            // Environnement de production
            case self::API_ENV_PROD:
                $this->setUrlIframe(self::IFRAME_URL_PROD);
                $this->setUrlApi(self::API_URL_PROD);

                return $this;

            // Par défaut, environnement de démo
            case self::API_URL_DEMO:
            default:
                $this->setUrlIframe(self::IFRAME_URL_DEMO);
                $this->setUrlApi(self::API_URL_DEMO);

                return $this;
        }
    }
1122557
public static function factory(?Enviroment $environment = null): Parser
    {
        $environment = $environment ?? Enviroment::getFromSapi(PHP_SAPI);

        return self::evaluate($environment)->isInstanceOf(Parser::class)->getValue();
    }
1196254
final public function run(int $argc, array $argv)
    {
        $ar = new ArgsManager();
        $ar->getArgs($argc, $argv);
    }
327644
public function executeAll(...$args)
    {
        if ($this->isEmpty()) {
            return 0;
        }
        $n = 0;
        do {
            $cb = $this->extract();
            if ($cb) {
                $cb(...$args);
                ++$n;
            }
        } while (!$this->isEmpty());
        return $n;
    }
972016
public function execute($path, array $args = [], array $envs = [])
    {
        if (false === @pcntl_exec($path, $args, $envs)) {
            throw new RuntimeException('Error when executing command');
        }
    }
1171010
public function build(MapperInterface $mapper, Environment $environment, array $args = [], array $blocks = [])
    {
        $context = [];

        foreach ($this->arguments as $index => list($name, $argument)) {
            $provided = array_key_exists($index, $args) ? true : false;

            $context[$name] = $argument->toPg($mapper, $provided, $args[$index] ?? null);
        }

        $query = call_user_func_array($this->body, [$environment, $context, $blocks]);

        return $query;
    }
903382
public function detectEnvironment($environments)
    {
        $r = Request::getInstance();
        $pos = stripos($r->server->get('SCRIPT_NAME'), DISPATCHER_FILENAME);
        if ($pos > 0) {
            //we do this because in CLI circumstances (and some random ones) we would end up with index.ph instead of index.php
            $pos = $pos - 1;
        }
        $home = substr($r->server->get('SCRIPT_NAME'), 0, $pos);
        $this['app_relative_path'] = rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $home), '/');

        $args = $this->isRunThroughCommandLineInterface() && isset($_SERVER['argv']) ? $_SERVER['argv'] : null;

        $detector = new EnvironmentDetector();

        return $this->environment = $detector->detect($environments, $args);
    }
1233730
public function usage(array $args = [], $command = '')
    {
        if (empty($args)) {
            global $argv;

            $command or $command = isset($argv[1]) ? $argv[1] : '[command]';
            array_unshift($args, $argv[0], $command);
        }

        return $this->climate->arguments->usage($this->climate, $args);
    }
306916
private function buildInternal(array $arguments)
    {
        $builder = ProcessBuilder::create($this->config->getPhpCliBinary());

        if (null !== ($cliArguments = $this->config->getPhpCliArguments())) {
            $builder->addArguments($cliArguments);
        }
        $builder->addArguments($arguments);

        if (null !== ($environment = $this->config->getPhpCliEnvironment())) {
            foreach ($environment as $name => $value) {
                $builder->setEnv($name, $value);
            }
        }
        // MUST be kept last.
        $builder->setEnv('COMPOSER', $this->homePath . DIRECTORY_SEPARATOR . 'composer.json');

        return $builder;
    }
861335
protected function execute(array $arguments)
    {
        \array_unshift($arguments, $this->path);
        
        $builder = ProcessBuilder::create($arguments);
        $process = $builder->getProcess();
        $process->run();
        
        if (!$process->isSuccessful()) {
            throw CommandException::factory($process);
        }
        
        // E.g. tesseract --version returns output as error output
        return $process->getOutput() ? $process->getOutput() : $process->getErrorOutput();
    }
1119180
protected function process(EnvironmentInterface $environment)
    {
        $modelId = ModelId::fromSerialized($environment->getInputProvider()->getParameter('source'));

        $dataDefinition = $environment->getDataDefinition();
        $this->guardValidEnvironment($dataDefinition, $modelId);
        // We want a redirect here if not creatable.
        $this->guardIsCreatable($environment, $modelId, true);

        if ($dataDefinition->getBasicDefinition()->isEditOnlyMode()) {
            return $this->callAction($environment, 'edit');
        }

        // Manual sorting mode. The ClipboardController should pick it up.
        $manualSortingProperty = ViewHelpers::getManualSortingProperty($environment);
        if ($manualSortingProperty && $environment->getDataProvider()->fieldExists($manualSortingProperty)) {
            return false;
        }

        $copiedModel = $this->copy($environment, $modelId);

        // If edit several don´t redirect do home.
        if ('select' === $environment->getInputProvider()->getParameter('act')) {
            return false;
        }

        $this->redirect($environment, ModelId::fromModel($copiedModel));

        return null;
    }
657504
public function run($args)
    {
        if(!file_exists($this->cwd . '/bootstrap.php')) {
            Index::error('This command requires ' . $this->cwd . '/bootstrap.php to be present.');
        }

        //expecting cradle install cradle/address
        if(count($args) < 3) {
            Index::error('Not enough arguments. Usage: cradle package vendor/package command');
        }

        $cradle = cradle();
        if(file_exists($this->cwd . '/bootstrap.php')) {
            include($this->cwd . '/bootstrap.php');
        }

        try {
            $cradle->package($args[1]);
        } catch(Exception $e) {
            //it means that the package wasn't registered
            $cradle->register($args[1]);
        }

        //Setup a default error handler
        $cradle->error(function($request, $response, $error) {
            Index::error($error->getMessage() . PHP_EOL . $error->getTraceAsString());
        });

        //prepare data
        $data = Index::parseArgs(array_slice($args, 3));

        //case for root packages
        if(strpos($args[1], '/') === 0) {
            $args[1] = substr($args[1], 1);
        }

        list($author, $package) = explode('/', $args[1], 2);

        $event = $author . '-' . $package . '-' . $args[2];

        //set the the request and response
        $request = $cradle->getRequest();
        $response = $cradle->getResponse();

        $request->setStage($data);

        //see HttpTrait->render() for similar implementation
        //if prepared returned false
        if (!$cradle->prepare()) {
            //dont do anything else
            return $this;
        }

        if ($response->getStatus() == 200) {
            $continue = $cradle
                ->trigger($event, $request, $response)
                ->getEventHandler()
                ->getMeta();

            if(!$continue) {
                return $this;
            }
        }

        if (!$response->hasContent() && $response->hasJson()) {
            $json = json_encode($response->get('json'));
            $response->setContent($json);
        }

        if ($response->hasContent()) {
            echo $response->getContent();
        } else {
            Index::info($args[2] .' has successfully completed.');
        }

        //the connection is already closed
        //also remember there are no more sessions
        $cradle->shutdown();
    }