summaryrefslogtreecommitdiff
path: root/lib/ci/status.rb
blob: c02b3b8f3e4c6666051edbacae4e0a7620de187e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Ci
  class Status
    def self.get_status(statuses)
      statuses.reject! { |status| status.try(&:allow_failure?) }

      if statuses.none?
        'skipped'
      elsif statuses.all?(&:success?)
        'success'
      elsif statuses.all?(&:pending?)
        'pending'
      elsif statuses.any?(&:running?) || statuses.any?(&:pending?)
        'running'
      elsif statuses.all?(&:canceled?)
        'canceled'
      else
        'failed'
      end
    end
  end
end