示例#1
0
 /**
  * Handle the analysis has completed event.
  *
  * We have a 1 in 8 chance of performing a cleanup.
  *
  * @param \StyleCI\StyleCI\Events\Analysis\AnalysisHasCompletedEvent $event
  *
  * @return void
  */
 public function handle(AnalysisHasCompletedEvent $event)
 {
     if (random_int(0, 7) > 0) {
         return;
     }
     foreach (Analysis::old()->pending()->orderBy('created_at', 'asc')->get() as $analysis) {
         $this->dispatch(new CleanupAnalysisJob($analysis));
     }
 }
 /**
  * Handle the analyze branch command.
  *
  * @param \StyleCI\StyleCI\Commands\Analysis\AnalyzeBranchCommand $command
  *
  * @return void
  */
 public function handle(AnalyzeBranchCommand $command)
 {
     $repo = $command->repo;
     $branch = $command->branch;
     $commit = $this->branches->getCommit($repo, $branch);
     $message = Str::commit($this->commits->get($repo, $commit)['commit']['message']);
     $analysis = Analysis::create(['repo_id' => $repo->id, 'branch' => $branch, 'commit' => $commit, 'message' => $message, 'status' => Analysis::PENDING, 'hidden' => false]);
     $this->dispatch(new RunAnalysisJob($analysis));
 }
 /**
  * Define the route model bindings, pattern filters, etc.
  *
  * @param \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('analysis', function ($value) {
         $decoded = Hashids::connection('analyses')->decode($value);
         if (isset($decoded[0]) && is_numeric($decoded[0]) && ($analysis = Analysis::find($decoded[0]))) {
             return $analysis;
         }
         throw new NotFoundHttpException('Analysis not found.');
     });
     $router->bind('repo', function ($value) {
         if (is_numeric($value) && ($repo = Repo::find($value))) {
             return $repo;
         }
         throw new NotFoundHttpException('Repo not found.');
     });
 }
示例#4
0
 public function testPresentation()
 {
     $analysis = Analysis::create(['repo_id' => 12345, 'branch' => 'test', 'commit' => str_repeat('a', 40), 'message' => 'Test 123!', 'status' => 2, 'hidden' => 1]);
     $presented = AutoPresenter::decorate($analysis);
     $this->assertInstanceOf(AnalysisPresenter::class, $presented);
     $this->assertSame('xkXG8Z', $presented->id);
     $this->assertSame('PASSED', $presented->summary);
     $this->assertSame('The StyleCI analysis has passed', $presented->description);
     $this->assertSame('fa fa-check-circle', $presented->icon);
     $this->assertSame('green', $presented->color);
     $this->assertFalse($presented->has_diff);
 }
 /**
  * Handle the analyze commit command.
  *
  * @param \StyleCI\StyleCI\Commands\Analysis\AnalyzeCommitCommand $command
  *
  * @return void
  */
 public function handle(AnalyzeCommitCommand $command)
 {
     $analysis = Analysis::create(['repo_id' => $command->repo->id, 'branch' => $command->branch, 'commit' => $command->commit, 'message' => $command->message, 'status' => Analysis::PENDING, 'hidden' => false]);
     dispatch(new RunAnalysisJob($analysis));
 }
 /**
  * Handle the analyze pull request command.
  *
  * @param \StyleCI\StyleCI\Commands\Analysis\AnalyzePullRequestCommand $command
  *
  * @return void
  */
 public function handle(AnalyzePullRequestCommand $command)
 {
     $analysis = Analysis::create(['repo_id' => $command->repo->id, 'pr' => $command->pr, 'commit' => $command->commit, 'message' => $command->message, 'status' => Analysis::PENDING, 'hidden' => false]);
     $this->dispatch(new RunAnalysisJob($analysis));
 }