Class: Shipit::EphemeralCommitChecks

Inherits:
Object
  • Object
show all
Defined in:
app/models/shipit/ephemeral_commit_checks.rb

Direct Known Subclasses

CommitChecks

Constant Summary collapse

FINAL_STATUSES =
%w[failed error success].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commit) ⇒ EphemeralCommitChecks

Returns a new instance of EphemeralCommitChecks.



7
8
9
# File 'app/models/shipit/ephemeral_commit_checks.rb', line 7

def initialize(commit)
  @commit = commit
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



12
13
14
# File 'app/models/shipit/ephemeral_commit_checks.rb', line 12

def output
  @output
end

#statusObject

Returns the value of attribute status.



11
12
13
# File 'app/models/shipit/ephemeral_commit_checks.rb', line 11

def status
  @status
end

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/shipit/ephemeral_commit_checks.rb', line 38

def finished?
  FINAL_STATUSES.include?(status)
end

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/shipit/ephemeral_commit_checks.rb', line 14

def run
  self.status = 'running'
  commands = StackCommands.new(stack)
  commands.with_temporary_working_directory(commit:) do |directory|
    deploy_spec = DeploySpec::FileSystem.new(directory, stack)
    capture_all(build_commands(deploy_spec.dependencies_steps, chdir: directory))
    capture_all(build_commands(deploy_spec.review_checks, chdir: directory))
  end
  self
rescue Command::Error
  self.status = 'failed'
  self
rescue StandardError
  self.status = 'error'
  raise
else
  self.status = 'success'
  self
end

#success?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/shipit/ephemeral_commit_checks.rb', line 34

def success?
  status == 'success'
end

#write(output) ⇒ Object



42
43
44
45
# File 'app/models/shipit/ephemeral_commit_checks.rb', line 42

def write(output)
  @output ||= ''
  @output += output
end