Example #1
0
 public function execute()
 {
     $config = $this->getRunConfig();
     foreach ($this->profile->getCommands() as $command) {
         $this->executor->execute($command, $config);
     }
 }
Example #2
0
 /**
  * @param Commit $commit
  * @throws \Exception
  */
 public function check(\App\Models\Commit $commit, HandlerInterface $customLogHandler = null)
 {
     $logger = LoggerFactory::createLogger($commit);
     if ($customLogHandler !== null) {
         $logger->pushHandler($customLogHandler);
     }
     $commit->setStartValues();
     $logger->debug('start time:' . $commit->start_time);
     $commandExecutor = new CommandExecutor();
     try {
         $repositoryPath = config('ci.repo');
         if (empty($repositoryPath)) {
             throw new \Exception('Empty repository path');
         }
         if (!is_dir($repositoryPath)) {
             throw new \Exception('Repository directory does not exist: ' . $repositoryPath);
         }
         $runConfiguration = new RunConfig($commit, $logger, $repositoryPath);
         $commandExecutor->execute(new GitCheckoutSpecificVersionCommand(), $runConfiguration);
         $commandExecutor->execute(new GitFetchCommitInfo(), $runConfiguration);
         $config = $this->createConfig($runConfiguration);
         foreach ($config->getLogHandlers() as $handler) {
             $logger->pushHandler($handler);
         }
         $profile = $this->getProfile($commit, $config);
         $command = new CheckProfileCommand($profile, $commandExecutor);
         $commandExecutor->execute($command, $runConfiguration);
         $commit->status = Commit::STATUS_OK;
         $logger->info('status: ok');
     } catch (\Exception $ex) {
         $commit->status = Commit::STATUS_FAILURE;
         $logger->emergency('exception:' . $ex->getMessage());
         $logger->emergency('status: failure');
         throw $ex;
     } finally {
         $logger->info('end time:' . $commit->end_time);
         $commit->end_time = time();
         $commit->save();
     }
 }