Class: PreCommit::Checks::Ci

Inherits:
Plugin
  • Object
show all
Defined in:
lib/plugins/pre_commit/checks/ci.rb

Overview

The CI check will run ‘rake pre_commmit:ci` before the commit and check its exit code. If the task runs successfully, the commit will proceed. If it fails, the commit will be aborted.

Constant Summary collapse

CI_TASK_NAME =
'pre_commit:ci'

Instance Attribute Summary

Attributes inherited from Plugin

#config, #pluginator

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

#initialize, #name

Constructor Details

This class inherits a constructor from PreCommit::Checks::Plugin

Class Method Details

.descriptionObject



13
14
15
# File 'lib/plugins/pre_commit/checks/ci.rb', line 13

def self.description
  "Runs 'rake #{CI_TASK_NAME} --silent'"
end

Instance Method Details

#call(_) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/plugins/pre_commit/checks/ci.rb', line 17

def call(_)
  return if system("rake", CI_TASK_NAME, "--silent")

  PreCommit::ErrorList.new(
    "your test suite has failed, for the full output run `#{CI_TASK_NAME}`"
  )
end