Class: Danger::Semaphore

Inherits:
CI
  • Object
show all
Defined in:
lib/danger/ci_source/semaphore.rb

Overview

### CI Setup

For Semaphor you will want to go to the settings page of the project. Inside “Build Settings” you should add ‘bundle exec danger` to the Setup thread.

### Token Setup

You can add your ‘DANGER_GITHUB_API_TOKEN` inside the “Environment Variables” section in the settings.

Instance Attribute Summary

Attributes inherited from CI

#pull_request_id, #repo_slug, #repo_url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CI

available_ci_sources, inherited, #supports?

Constructor Details

#initialize(env) ⇒ Semaphore

Returns a new instance of Semaphore.



26
27
28
29
30
# File 'lib/danger/ci_source/semaphore.rb', line 26

def initialize(env)
  self.repo_slug = env["SEMAPHORE_REPO_SLUG"]
  self.pull_request_id = env["PULL_REQUEST_NUMBER"]
  self.repo_url = GitRepo.new.origins # Semaphore doesn't provide a repo url env variable :/
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/danger/ci_source/semaphore.rb', line 14

def self.validates_as_ci?(env)
  env.key? "SEMAPHORE"
end

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/danger/ci_source/semaphore.rb', line 18

def self.validates_as_pr?(env)
  ["SEMAPHORE_REPO_SLUG", "PULL_REQUEST_NUMBER"].all? { |x| env[x] }
end

Instance Method Details

#supported_request_sourcesObject



22
23
24
# File 'lib/danger/ci_source/semaphore.rb', line 22

def supported_request_sources
  @supported_request_sources ||= [Danger::RequestSources::GitHub]
end