Module: InchCI::Worker::Project::BuildJSON

Defined in:
lib/inch_ci/worker/project/build_json.rb

Overview

The Build worker is responsible for “building” projects, i.e. cloning and analysing repos, by utilizing a gem called “inch_ci-worker”.

Defined Under Namespace

Classes: ShellInvocation

Class Method Summary collapse

Class Method Details

.enqueue(filename, trigger = nil) ⇒ Build

Returns:


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/inch_ci/worker/project/build_json.rb', line 14

def self.enqueue(filename, trigger = nil)
  # this is invoked from the inch_ci-worker gem
  json = InchCI::Worker::BuildJSON.json(filename)
  if trigger.nil?
    trigger = 'ci'
    trigger = 'shell' if json.shell?
    trigger = 'travis' if json.travis?
    trigger = 'circleci' if json.circleci?
  end

  if json.url
    branch = Store::EnsureProjectAndBranch.call(json.url, json.branch_name)

    scheduled_builds = Store::FindScheduledBuildsInBranch.call(branch)
    scheduled_builds.each do |build|
      Store::UpdateBuildStatus.call(build, STATUS_CANCELLED)
    end

    build = Store::CreateBuild.call(branch, trigger)
    Gossip.new_build(build, build.project, build.branch)
    ShellInvocation.perform_async(filename, json.url, json.branch_name, trigger, build.id)
    build
  end
end