protected function execute(InputInterface $input, OutputInterface $output) { $namespace = $input->getOption('namespace'); $file = $input->getOption('file'); $command = implode(' ', $input->getArgument('commands')); // Get the travis configuration. $travis = Yaml::parse($file); $language = !empty($travis['language']) ? $travis['language'] : ''; $language_versions = !empty($travis[$language]) ? $travis[$language] : array(); $services = !empty($travis['services']) ? $travis['services'] : array(); $privileged = $input->getOption('privileged'); $output->writeln("#!/bin/bash"); $fail_fast = $input->getOption('fail-fast'); if ($fail_fast) { $output->writeln("set -e"); } // Get the permutations. foreach ($language_versions as $language_version) { $output->writeln("#### Permutation {$language}{$language_version} ####"); $permutation = new Permutation(); $permutation->setNamespace($namespace); $permutation->setLanguage($language . ':' . $language_version); $permutation->setCommand($command); if ($privileged) { $permutation->setPrivileged(true); } $permutation->addServices($services); // Print. $lines = $permutation->build(); foreach ($lines as $line) { $output->writeln($line); } } }
public function environment() { // Load and parse travis file $travis_file = $this->buildVars['DCI_TravisFile']; $this->output->writeln("<comment>Loading test build parameters from travis file: </comment><info>{$travis_file}</info>"); $build = new JobDefinition(); $directory = trim($this->workingDirectory); // Ensure directory ends in a / if ($directory[strlen($directory) - 1] != '/') { $directory = $directory . "/"; } $result = $build->load($directory . $travis_file); if ($result == -1) { // Error loading definition file. $this->output->writeln("<error>FAILED:</error> <info>Unable to parse travis file.</info>"); // TODO: Robust error handling return -1; } $travis = $build->getParameters(); // Store the parsed contents so we can reference them in later build steps $this->travis_parsed = $travis; $namespace = $this->namespace; $command = implode(' ', $this->commands); // Evaluate the parsed travis file $language = !empty($travis['language']) ? $travis['language'] : ''; $language_versions = !empty($travis[$language]) ? $travis[$language] : array(); $services = !empty($travis['services']) ? $travis['services'] : array(); // TODO: Add Fast Fail logic // Get the permutations foreach ($language_versions as $language_version) { $this->output->writeln("<info>### Building permutation <options=bold>'{$language}{$language_version}'</options=bold> ###</info>"); $permutation = new Permutation(); $permutation->setNamespace($namespace); $permutation->setLanguage($language . ':' . $language_version); $permutation->setCommand($command); if (!empty($this->buildVars['DCI_Privileged'])) { $permutation->setPrivileged(true); } $permutation->addServices($services); // Print. $lines = $permutation->build(); foreach ($lines as $line) { $this->output->writeln($line); if (!empty($this->script)) { $this->script .= " && "; } $this->script .= $line; } } }