Commit 64bfd9d7 authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Remove ci_ prefix from all ci related things

parent 059c2c541d4c
...@@ -2,8 +2,8 @@ class Admin::RunnerProjectsController < Admin::ApplicationController ...@@ -2,8 +2,8 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
before_action :project, only: [:create] before_action :project, only: [:create]
def index def index
@runner_projects = project.ci_runner_projects.all @runner_projects = project.runner_projects.all
@runner_project = project.ci_runner_projects.new @runner_project = project.runner_projects.new
end end
def create def create
......
...@@ -8,7 +8,7 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -8,7 +8,7 @@ class Projects::BuildsController < Projects::ApplicationController
def index def index
@scope = params[:scope] @scope = params[:scope]
@all_builds = project.ci_builds @all_builds = project.builds
@builds = @all_builds.order('created_at DESC') @builds = @all_builds.order('created_at DESC')
@builds = @builds =
case @scope case @scope
...@@ -23,7 +23,7 @@ def index ...@@ -23,7 +23,7 @@ def index
end end
def cancel_all def cancel_all
@project.ci_builds.running_or_pending.each(&:cancel) @project.builds.running_or_pending.each(&:cancel)
redirect_to namespace_project_builds_path(project.namespace, project) redirect_to namespace_project_builds_path(project.namespace, project)
end end
...@@ -76,7 +76,7 @@ def cancel ...@@ -76,7 +76,7 @@ def cancel
private private
def build def build
@build ||= project.ci_builds.unscoped.find_by!(id: params[:id]) @build ||= project.builds.unscoped.find_by!(id: params[:id])
end end
def artifacts_file def artifacts_file
......
...@@ -18,7 +18,7 @@ def create ...@@ -18,7 +18,7 @@ def create
end end
def destroy def destroy
runner_project = project.ci_runner_projects.find(params[:id]) runner_project = project.runner_projects.find(params[:id])
runner_project.destroy runner_project.destroy
redirect_to runners_path(project) redirect_to runners_path(project)
......
...@@ -5,9 +5,9 @@ class Projects::RunnersController < Projects::ApplicationController ...@@ -5,9 +5,9 @@ class Projects::RunnersController < Projects::ApplicationController
layout 'project_settings' layout 'project_settings'
def index def index
@runners = project.ci_runners.ordered @runners = project.runners.ordered
@specific_runners = current_user.ci_authorized_runners. @specific_runners = current_user.ci_authorized_runners.
where.not(id: project.ci_runners). where.not(id: project.runners).
ordered.page(params[:page]).per(20) ordered.page(params[:page]).per(20)
@shared_runners = Ci::Runner.shared.active @shared_runners = Ci::Runner.shared.active
@shared_runners_count = @shared_runners.count(:all) @shared_runners_count = @shared_runners.count(:all)
...@@ -60,7 +60,7 @@ def toggle_shared_runners ...@@ -60,7 +60,7 @@ def toggle_shared_runners
protected protected
def set_runner def set_runner
@runner ||= project.ci_runners.find(params[:id]) @runner ||= project.runners.find(params[:id])
end end
def runner_params def runner_params
......
...@@ -4,18 +4,18 @@ class Projects::TriggersController < Projects::ApplicationController ...@@ -4,18 +4,18 @@ class Projects::TriggersController < Projects::ApplicationController
layout 'project_settings' layout 'project_settings'
def index def index
@triggers = project.ci_triggers @triggers = project.triggers
@trigger = Ci::Trigger.new @trigger = Ci::Trigger.new
end end
def create def create
@trigger = project.ci_triggers.new @trigger = project.triggers.new
@trigger.save @trigger.save
if @trigger.valid? if @trigger.valid?
redirect_to namespace_project_triggers_path(@project.namespace, @project) redirect_to namespace_project_triggers_path(@project.namespace, @project)
else else
@triggers = project.ci_triggers.select(&:persisted?) @triggers = project.triggers.select(&:persisted?)
render :index render :index
end end
end end
...@@ -29,6 +29,6 @@ def destroy ...@@ -29,6 +29,6 @@ def destroy
private private
def trigger def trigger
@trigger ||= project.ci_triggers.find(params[:id]) @trigger ||= project.triggers.find(params[:id])
end end
end end
...@@ -17,6 +17,6 @@ def update ...@@ -17,6 +17,6 @@ def update
private private
def project_params def project_params
params.require(:project).permit({ ci_variables_attributes: [:id, :key, :value, :_destroy] }) params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] })
end end
end end
...@@ -65,7 +65,7 @@ def render_ci_status(ci_commit) ...@@ -65,7 +65,7 @@ def render_ci_status(ci_commit)
end end
def no_runners_for_project?(project) def no_runners_for_project?(project)
project.ci_runners.blank? && project.runners.blank? &&
Ci::Runner.shared.blank? Ci::Runner.shared.blank?
end end
end end
...@@ -287,7 +287,7 @@ def yaml_variables ...@@ -287,7 +287,7 @@ def yaml_variables
end end
def project_variables def project_variables
project.ci_variables.map do |variable| project.variables.map do |variable|
{ key: variable.key, value: variable.value, public: false } { key: variable.key, value: variable.value, public: false }
end end
end end
......
...@@ -52,7 +52,7 @@ def set_default_values ...@@ -52,7 +52,7 @@ def set_default_values
def assign_to(project, current_user = nil) def assign_to(project, current_user = nil)
self.is_shared = false if shared? self.is_shared = false if shared?
self.save self.save
project.ci_runner_projects.create!(runner_id: self.id) project.runner_projects.create!(runner_id: self.id)
end end
def display_name def display_name
......
...@@ -128,15 +128,15 @@ def set_last_activity_at ...@@ -128,15 +128,15 @@ def set_last_activity_at
has_one :import_data, dependent: :destroy, class_name: "ProjectImportData" has_one :import_data, dependent: :destroy, class_name: "ProjectImportData"
has_many :commit_statuses, dependent: :destroy, class_name: 'CommitStatus', foreign_key: :gl_project_id
has_many :ci_commits, dependent: :destroy, class_name: 'Ci::Commit', foreign_key: :gl_project_id has_many :ci_commits, dependent: :destroy, class_name: 'Ci::Commit', foreign_key: :gl_project_id
has_many :ci_statuses, dependent: :destroy, class_name: 'CommitStatus', foreign_key: :gl_project_id has_many :builds, class_name: 'Ci::Build', foreign_key: :gl_project_id # the builds are created from the commit_statuses
has_many :ci_builds, class_name: 'Ci::Build', foreign_key: :gl_project_id # the builds are created from the ci_statuses has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject', foreign_key: :gl_project_id
has_many :ci_runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject', foreign_key: :gl_project_id has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
has_many :ci_runners, through: :ci_runner_projects, source: :runner, class_name: 'Ci::Runner' has_many :variables, dependent: :destroy, class_name: 'Ci::Variable', foreign_key: :gl_project_id
has_many :ci_variables, dependent: :destroy, class_name: 'Ci::Variable', foreign_key: :gl_project_id has_many :triggers, dependent: :destroy, class_name: 'Ci::Trigger', foreign_key: :gl_project_id
has_many :ci_triggers, dependent: :destroy, class_name: 'Ci::Trigger', foreign_key: :gl_project_id
accepts_nested_attributes_for :ci_variables, allow_destroy: true accepts_nested_attributes_for :variables, allow_destroy: true
delegate :name, to: :owner, allow_nil: true, prefix: true delegate :name, to: :owner, allow_nil: true, prefix: true
delegate :members, to: :team, prefix: true delegate :members, to: :team, prefix: true
...@@ -822,7 +822,7 @@ def unlink_fork ...@@ -822,7 +822,7 @@ def unlink_fork
end end
def any_runners?(&block) def any_runners?(&block)
if ci_runners.active.any?(&block) if runners.active.any?(&block)
return true return true
end end
......
...@@ -134,7 +134,7 @@ class User < ActiveRecord::Base ...@@ -134,7 +134,7 @@ class User < ActiveRecord::Base
has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest" has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest"
has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: :destroy has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: :destroy
has_one :abuse_report, dependent: :destroy has_one :abuse_report, dependent: :destroy
has_many :ci_builds, dependent: :nullify, class_name: 'Ci::Build' has_many :builds, dependent: :nullify, class_name: 'Ci::Build'
# #
......
module Ci
class CreateCommitService
def execute(project, user, params)
sha = params[:checkout_sha] || params[:after]
origin_ref = params[:ref]
unless origin_ref && sha.present?
return false
end
ref = origin_ref.gsub(/\Arefs\/(tags|heads)\//, '')
# Skip branch removal
if sha == Ci::Git::BLANK_SHA
return false
end
tag = origin_ref.start_with?('refs/tags/')
commit = project.ensure_ci_commit(sha)
unless commit.skip_ci?
commit.update_committed!
commit.create_builds(ref, tag, user)
end
commit
end
end
end
class CreateCommitBuildsService
def execute(project, user, params)
return false unless project.builds_enabled?
sha = params[:checkout_sha] || params[:after]
origin_ref = params[:ref]
unless origin_ref && sha.present?
return false
end
ref = origin_ref.gsub(/\Arefs\/(tags|heads)\//, '')
# Skip branch removal
if sha == Ci::Git::BLANK_SHA
return false
end
tag = origin_ref.start_with?('refs/tags/')
commit = project.ensure_ci_commit(sha)
unless commit.skip_ci?
commit.update_committed!
commit.create_builds(ref, tag, user)
end
commit
end
end
...@@ -61,6 +61,7 @@ def execute(project, user, oldrev, newrev, ref) ...@@ -61,6 +61,7 @@ def execute(project, user, oldrev, newrev, ref)
EventCreateService.new.push(project, user, @push_data) EventCreateService.new.push(project, user, @push_data)
project.execute_hooks(@push_data.dup, :push_hooks) project.execute_hooks(@push_data.dup, :push_hooks)
project.execute_services(@push_data.dup, :push_hooks) project.execute_services(@push_data.dup, :push_hooks)
CreateCommitBuildsService.new.execute(project, @user, @push_data)
ProjectCacheWorker.perform_async(project.id) ProjectCacheWorker.perform_async(project.id)
end end
......
...@@ -10,6 +10,7 @@ def execute(project, user, oldrev, newrev, ref) ...@@ -10,6 +10,7 @@ def execute(project, user, oldrev, newrev, ref)
EventCreateService.new.push(project, user, @push_data) EventCreateService.new.push(project, user, @push_data)
project.execute_hooks(@push_data.dup, :tag_push_hooks) project.execute_hooks(@push_data.dup, :tag_push_hooks)
project.execute_services(@push_data.dup, :tag_push_hooks) project.execute_services(@push_data.dup, :tag_push_hooks)
CreateCommitBuildsService.new.execute(project, @user, @push_data)
ProjectCacheWorker.perform_async(project.id) ProjectCacheWorker.perform_async(project.id)
true true
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
= project.name_with_namespace = project.name_with_namespace
%td %td
.pull-right .pull-right
= form_for [:admin, project.namespace, project, project.ci_runner_projects.new] do |f| = form_for [:admin, project.namespace, project, project.runner_projects.new] do |f|
= f.hidden_field :runner_id, value: @runner.id = f.hidden_field :runner_id, value: @runner.id
= f.submit 'Enable', class: 'btn btn-xs' = f.submit 'Enable', class: 'btn btn-xs'
= paginate @projects = paginate @projects
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
= icon('cubes fw') = icon('cubes fw')
%span %span
Builds Builds
%span.count.builds_counter= @project.ci_builds.running_or_pending.count(:all) %span.count.builds_counter= @project.builds.running_or_pending.count(:all)
- if project_nav_tab? :graphs - if project_nav_tab? :graphs
= nav_link(controller: %w(graphs)) do = nav_link(controller: %w(graphs)) do
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
%ul %ul
%li %li
Total: Total:
%strong= pluralize @project.ci_builds.count(:all), 'build' %strong= pluralize @project.builds.count(:all), 'build'
%li %li
Successful: Successful:
%strong= pluralize @project.ci_builds.success.count(:all), 'build' %strong= pluralize @project.builds.success.count(:all), 'build'
%li %li
Failed: Failed:
%strong= pluralize @project.ci_builds.failed.count(:all), 'build' %strong= pluralize @project.builds.failed.count(:all), 'build'
%li %li
Success ratio: Success ratio:
%strong %strong
#{success_ratio(@project.ci_builds.success, @project.ci_builds.failed)}% #{success_ratio(@project.builds.success, @project.builds.failed)}%
%li %li
Commits covered: Commits covered:
%strong %strong
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
- if runner.belongs_to_one_project? - if runner.belongs_to_one_project?
= link_to 'Remove runner', runner_path(runner), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' = link_to 'Remove runner', runner_path(runner), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- else - else
- runner_project = @project.ci_runner_projects.find_by(runner_id: runner) - runner_project = @project.runner_projects.find_by(runner_id: runner)
= link_to 'Disable for this project', namespace_project_runner_project_path(@project.namespace, @project, runner_project), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' = link_to 'Disable for this project', namespace_project_runner_project_path(@project.namespace, @project, runner_project), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- elsif runner.specific? - elsif runner.specific?
= form_for [@project.namespace, @project, @project.ci_runner_projects.new] do |f| = form_for [@project.namespace, @project, @project.runner_projects.new] do |f|
= f.hidden_field :runner_id, value: runner.id = f.hidden_field :runner_id, value: runner.id
= f.submit 'Enable for this project', class: 'btn btn-sm' = f.submit 'Enable for this project', class: 'btn btn-sm'
.pull-right .pull-right
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
- @project.errors.full_messages.each do |msg| - @project.errors.full_messages.each do |msg|
%li= msg %li= msg
= f.fields_for :ci_variables do |variable_form| = f.fields_for :variables do |variable_form|
.form-group .form-group
= variable_form.label :key, 'Key', class: 'control-label' = variable_form.label :key, 'Key', class: 'control-label'
.col-sm-10 .col-sm-10
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
%hr %hr
%p %p
.clearfix .clearfix
= f.link_to_add "Add a variable", :ci_variables, class: 'btn btn-success pull-right' = f.link_to_add "Add a variable", :variables, class: 'btn btn-success pull-right'
.form-actions .form-actions
= f.submit 'Save changes', class: 'btn btn-save', return_to: request.original_url = f.submit 'Save changes', class: 'btn btn-save', return_to: request.original_url
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment