app/models/commit_status.rb
def github_check_status
    base_url = "repos/#{@project.repository_path}/commits/#{@commit}"
    preview_header = {Accept: 'application/vnd.github.antiope-preview+json'}

    check_suites = GITHUB.get("#{base_url}/check-suites", headers: preview_header).to_attrs.fetch(:check_suites)
    check_runs = GITHUB.get("#{base_url}/check-runs", headers: preview_header).to_attrs.fetch(:check_runs)

    # ignore pending unimportant
    check_suites.reject! do |s|
      check_state(s[:conclusion]) == "pending" &&
        (
          IGNORE_PENDING_CHECKS.include?(s.dig(:app, :name)) ||
          @project.ignore_pending_checks.to_s.split(",").include?(s.dig(:app, :name))
        )
    end

    overall_state = check_suites.
      map { |suite| check_state(suite[:conclusion]) }.
      max_by { |state| STATE_PRIORITY.index(state.to_sym) }

    statuses = check_runs.map do |check_run|
      {
        state: check_state(check_run[:conclusion]),
        description: ApplicationController.helpers.markdown(check_run[:output][:summary]),
        context: check_run[:name],
        target_url: check_run[:html_url],
        updated_at: check_run[:started_at]
      }
    end
    statuses += missing_check_runs_statuses(check_suites, check_runs)

    {state: overall_state || 'pending', statuses: statuses}
  end
# Gets commit statuses using GitHub's check API. Currently parsing it to match status structure to better facilitate
# transition to new API. See https://developer.github.com/v3/checks/runs/ and
# https://developer.github.com/v3/checks/suites/ for details
# @return [Hash]
Gets commit statuses using GitHub's check API. Currently parsing it to match status structure to better facilitate
transition to new API.
Gets commit statuses using GitHub ' s check API . Currently parsing it to match status structure to better facilitate transition to new API .
def github_check_status
    base_url = "repos/#{@project.repository_path}/commits/#{@commit}"
    preview_header = {Accept: 'application/vnd.github.antiope-preview+json'}
    check_suites = GITHUB.get("#{base_url}/check-suites", headers: preview_header).to_attrs.fetch(:check_suites)
    check_runs = GITHUB.get("#{base_url}/check-runs", headers: preview_header).to_attrs.fetch(:check_runs)
    check_suites.reject! do |s|
      check_state(s[:conclusion]) == "pending" &&
        (
          IGNORE_PENDING_CHECKS.include?(s.dig(:app, :name)) ||
          @project.ignore_pending_checks.to_s.split(",").include?(s.dig(:app, :name))
        )
    end
    overall_state = check_suites.
      map { |suite| check_state(suite[:conclusion]) }.
      max_by { |state| STATE_PRIORITY.index(state.to_sym) }
    statuses = check_runs.map do |check_run|
      {
        state: check_state(check_run[:conclusion]),
        description: ApplicationController.helpers.markdown(check_run[:output][:summary]),
        context: check_run[:name],
        target_url: check_run[:html_url],
        updated_at: check_run[:started_at]
      }
    end
    statuses += missing_check_runs_statuses(check_suites, check_runs)
    {state: overall_state || 'pending', statuses: statuses}
  end
def github_check_status base_url = "repos/#{@project.repository_path}/commits/#{@commit}" preview_header = { Accept : 'application/vnd.github.antiope-preview+json' } check_suites = GITHUB . get ( "#{base_url}/check-suites" , headers : preview_header ) . to_attrs . fetch ( :check_suites ) check_runs = GITHUB . get ( "#{base_url}/check-runs" , headers : preview_header ) . to_attrs . fetch ( :check_runs ) check_suites . reject! do | s | check_state ( s [ :conclusion ] ) == "pending" && ( IGNORE_PENDING_CHECKS . include? ( s . dig ( :app , :name ) ) || @project . ignore_pending_checks . to_s . split ( "," ) . include? ( s . dig ( :app , :name ) ) ) end overall_state = check_suites . map { | suite | check_state ( suite [ :conclusion ] ) } . max_by { | state | STATE_PRIORITY . index ( state . to_sym ) } statuses = check_runs . map do | check_run | { state : check_state ( check_run [ :conclusion ] ) , description : ApplicationController . helpers . markdown ( check_run [ :output ] [ :summary ] ) , context : check_run [ :name ] , target_url : check_run [ :html_url ] , updated_at : check_run [ :started_at ] } end statuses += missing_check_runs_statuses ( check_suites , check_runs ) { state : overall_state || 'pending' , statuses : statuses } end
Gets commit statuses using GitHub's check API.
Gets commit statuses using GitHub ' s check API .
# ignore pending unimportant
None
Hash