BigW Consortium Gitlab

Commit 6a6fd757 by Lin Jen-Shin

Merge branch '9-0-stable' into 9-0-stable-dev

* 9-0-stable: Merge branch 'protobuf-3.2.0.2' into 'master' Merge branch '28890-allow-creating-mr-without-target-branch-in-url' into 'master' Merge branch '24683-sidebar-spinners' into 'master' Merge branch '29534-todos-performance' into 'master' Merge branch '29586-pipelines-tabs' into 'master' Merge branch 'fix/regressions-in-ci-v4-api' into 'master'
parents 67f4501f bb3fea89
...@@ -304,7 +304,7 @@ GEM ...@@ -304,7 +304,7 @@ GEM
multi_json (~> 1.10) multi_json (~> 1.10)
retriable (~> 1.4) retriable (~> 1.4)
signet (~> 0.6) signet (~> 0.6)
google-protobuf (3.2.0) google-protobuf (3.2.0.2)
googleauth (0.5.1) googleauth (0.5.1)
faraday (~> 0.9) faraday (~> 0.9)
jwt (~> 1.4) jwt (~> 1.4)
......
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
const selectedDateValue = this.datePayload[this.abilityName].due_date; const selectedDateValue = this.datePayload[this.abilityName].due_date;
const displayedDateStyle = this.displayedDate !== 'No due date' ? 'bold' : 'no-value'; const displayedDateStyle = this.displayedDate !== 'No due date' ? 'bold' : 'no-value';
this.$loading.fadeIn(); this.$loading.removeClass('hidden').fadeIn();
if (isDropdown) { if (isDropdown) {
this.$dropdown.trigger('loading.gl.dropdown'); this.$dropdown.trigger('loading.gl.dropdown');
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
if (!selected.length) { if (!selected.length) {
data[abilityName].label_ids = ['']; data[abilityName].label_ids = [''];
} }
$loading.fadeIn(); $loading.removeClass('hidden').fadeIn();
$dropdown.trigger('loading.gl.dropdown'); $dropdown.trigger('loading.gl.dropdown');
return $.ajax({ return $.ajax({
type: 'PUT', type: 'PUT',
......
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
} }
$dropdown.trigger('loading.gl.dropdown'); $dropdown.trigger('loading.gl.dropdown');
$loading.fadeIn(); $loading.removeClass('hidden').fadeIn();
gl.issueBoards.BoardsStore.detail.issue.update($dropdown.attr('data-issue-update')) gl.issueBoards.BoardsStore.detail.issue.update($dropdown.attr('data-issue-update'))
.then(function () { .then(function () {
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
data = {}; data = {};
data[abilityName] = {}; data[abilityName] = {};
data[abilityName].milestone_id = selected != null ? selected : null; data[abilityName].milestone_id = selected != null ? selected : null;
$loading.fadeIn(); $loading.removeClass('hidden').fadeIn();
$dropdown.trigger('loading.gl.dropdown'); $dropdown.trigger('loading.gl.dropdown');
return $.ajax({ return $.ajax({
type: 'PUT', type: 'PUT',
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
$loading = $block.find('.block-loading').fadeOut(); $loading = $block.find('.block-loading').fadeOut();
var updateIssueBoardsIssue = function () { var updateIssueBoardsIssue = function () {
$loading.fadeIn(); $loading.removeClass('hidden').fadeIn();
gl.issueBoards.BoardsStore.detail.issue.update($dropdown.attr('data-issue-update')) gl.issueBoards.BoardsStore.detail.issue.update($dropdown.attr('data-issue-update'))
.then(function () { .then(function () {
$loading.fadeOut(); $loading.fadeOut();
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
data = {}; data = {};
data[abilityName] = {}; data[abilityName] = {};
data[abilityName].assignee_id = selected != null ? selected : null; data[abilityName].assignee_id = selected != null ? selected : null;
$loading.fadeIn(); $loading.removeClass('hidden').fadeIn();
$dropdown.trigger('loading.gl.dropdown'); $dropdown.trigger('loading.gl.dropdown');
return $.ajax({ return $.ajax({
type: 'PUT', type: 'PUT',
......
...@@ -138,7 +138,6 @@ ...@@ -138,7 +138,6 @@
.nav-links { .nav-links {
display: inline-block; display: inline-block;
width: 50%;
margin-bottom: 0; margin-bottom: 0;
border-bottom: none; border-bottom: none;
......
...@@ -45,7 +45,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController ...@@ -45,7 +45,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
private private
def find_todos def find_todos
@todos ||= TodosFinder.new(current_user, params).execute @todos ||= TodosFinder.new(current_user, params.merge(include_associations: true)).execute
end end
def todos_counts def todos_counts
......
...@@ -24,6 +24,7 @@ class TodosFinder ...@@ -24,6 +24,7 @@ class TodosFinder
def execute def execute
items = current_user.todos items = current_user.todos
items = include_associations(items)
items = by_action_id(items) items = by_action_id(items)
items = by_action(items) items = by_action(items)
items = by_author(items) items = by_author(items)
...@@ -38,6 +39,17 @@ class TodosFinder ...@@ -38,6 +39,17 @@ class TodosFinder
private private
def include_associations(items)
return items unless params[:include_associations]
items.includes(
[
target: { project: [:route, namespace: :route] },
author: { namespace: :route },
]
)
end
def action_id? def action_id?
action_id.present? && Todo::ACTION_NAMES.has_key?(action_id.to_i) action_id.present? && Todo::ACTION_NAMES.has_key?(action_id.to_i)
end end
......
...@@ -39,9 +39,13 @@ module TodosHelper ...@@ -39,9 +39,13 @@ module TodosHelper
namespace_project_commit_path(todo.project.namespace.becomes(Namespace), todo.project, namespace_project_commit_path(todo.project.namespace.becomes(Namespace), todo.project,
todo.target, anchor: anchor) todo.target, anchor: anchor)
else else
path = [todo.project.namespace.becomes(Namespace), todo.project, todo.target] if todo.build_failed?
# associated namespace and route would be loaded from the db again if todo.project was used
path.unshift(:pipelines) if todo.build_failed? project = todo.target.project
path = [:pipelines, project.namespace.becomes(Namespace), project, todo.target]
else
path = [todo.target]
end
polymorphic_path(path, anchor: anchor) polymorphic_path(path, anchor: anchor)
end end
......
...@@ -539,6 +539,16 @@ module Ci ...@@ -539,6 +539,16 @@ module Ci
Gitlab::Ci::Build::Credentials::Factory.new(self).create! Gitlab::Ci::Build::Credentials::Factory.new(self).create!
end end
def dependencies
depended_jobs = depends_on_builds
return depended_jobs unless options[:dependencies].present?
depended_jobs.select do |job|
options[:dependencies].include?(job.name)
end
end
private private
def update_artifacts_size def update_artifacts_size
......
...@@ -7,6 +7,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -7,6 +7,7 @@ class MergeRequest < ActiveRecord::Base
belongs_to :target_project, class_name: "Project" belongs_to :target_project, class_name: "Project"
belongs_to :source_project, class_name: "Project" belongs_to :source_project, class_name: "Project"
belongs_to :project, foreign_key: :target_project_id
belongs_to :merge_user, class_name: "User" belongs_to :merge_user, class_name: "User"
has_many :merge_request_diffs, dependent: :destroy has_many :merge_request_diffs, dependent: :destroy
...@@ -537,10 +538,6 @@ class MergeRequest < ActiveRecord::Base ...@@ -537,10 +538,6 @@ class MergeRequest < ActiveRecord::Base
target_project != source_project target_project != source_project
end end
def project
target_project
end
# If the merge request closes any issues, save this information in the # If the merge request closes any issues, save this information in the
# `MergeRequestsClosingIssues` model. This is a performance optimization. # `MergeRequestsClosingIssues` model. This is a performance optimization.
# Calculating this information for a number of merge requests requires # Calculating this information for a number of merge requests requires
......
...@@ -6,7 +6,7 @@ module MergeRequests ...@@ -6,7 +6,7 @@ module MergeRequests
merge_request.source_project = find_source_project merge_request.source_project = find_source_project
merge_request.target_project = find_target_project merge_request.target_project = find_target_project
merge_request.target_branch = find_target_branch merge_request.target_branch = find_target_branch
merge_request.can_be_created = branches_valid? && source_branch_specified? && target_branch_specified? merge_request.can_be_created = branches_valid?
compare_branches if branches_present? compare_branches if branches_present?
assign_title_and_description if merge_request.can_be_created assign_title_and_description if merge_request.can_be_created
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
= icon('user', 'aria-hidden': 'true') = icon('user', 'aria-hidden': 'true')
.title.hide-collapsed .title.hide-collapsed
Assignee Assignee
= icon('spinner spin', class: 'block-loading', 'aria-hidden': 'true') = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can_edit_issuable - if can_edit_issuable
= link_to 'Edit', '#', class: 'edit-link pull-right' = link_to 'Edit', '#', class: 'edit-link pull-right'
.value.hide-collapsed .value.hide-collapsed
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
None None
.title.hide-collapsed .title.hide-collapsed
Milestone Milestone
= icon('spinner spin', class: 'block-loading', 'aria-hidden': 'true') = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can_edit_issuable - if can_edit_issuable
= link_to 'Edit', '#', class: 'edit-link pull-right' = link_to 'Edit', '#', class: 'edit-link pull-right'
.value.hide-collapsed .value.hide-collapsed
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
= issuable.due_date.try(:to_s, :medium) || 'None' = issuable.due_date.try(:to_s, :medium) || 'None'
.title.hide-collapsed .title.hide-collapsed
Due date Due date
= icon('spinner spin', class: 'block-loading', 'aria-hidden': 'true') = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project) - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
= link_to 'Edit', '#', class: 'edit-link pull-right' = link_to 'Edit', '#', class: 'edit-link pull-right'
.value.hide-collapsed .value.hide-collapsed
...@@ -121,12 +121,12 @@ ...@@ -121,12 +121,12 @@
- selected_labels = issuable.labels - selected_labels = issuable.labels
.block.labels .block.labels
.sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(issuable.labels_array), data: { placement: "left", container: "body" } } .sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(issuable.labels_array), data: { placement: "left", container: "body" } }
= icon('tags', 'aria-hidden': 'true') = icon('tags', class: 'hidden', 'aria-hidden': 'true')
%span %span
= selected_labels.size = selected_labels.size
.title.hide-collapsed .title.hide-collapsed
Labels Labels
= icon('spinner spin', class: 'block-loading', 'aria-hidden': 'true') = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can_edit_issuable - if can_edit_issuable
= link_to 'Edit', '#', class: 'edit-link pull-right' = link_to 'Edit', '#', class: 'edit-link pull-right'
.value.issuable-show-labels.hide-collapsed{ class: ("has-labels" if selected_labels.any?) } .value.issuable-show-labels.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
......
---
title: hide loading spinners for server-rendered sidebar fields
merge_request:
author:
---
title: Allow creating merge request even if target branch is not specified in query
params
merge_request: 9968
author:
...@@ -768,7 +768,7 @@ module API ...@@ -768,7 +768,7 @@ module API
end end
class Dependency < Grape::Entity class Dependency < Grape::Entity
expose :id, :name expose :id, :name, :token
expose :artifacts_file, using: ArtifactFile, if: ->(job, _) { job.artifacts? } expose :artifacts_file, using: ArtifactFile, if: ->(job, _) { job.artifacts? }
end end
...@@ -796,7 +796,7 @@ module API ...@@ -796,7 +796,7 @@ module API
expose :artifacts, using: Artifacts expose :artifacts, using: Artifacts
expose :cache, using: Cache expose :cache, using: Cache
expose :credentials, using: Credentials expose :credentials, using: Credentials
expose :depends_on_builds, as: :dependencies, using: Dependency expose :dependencies, using: Dependency
end end
end end
end end
......
...@@ -41,14 +41,6 @@ module API ...@@ -41,14 +41,6 @@ module API
(Time.now - current_runner.contacted_at) >= contacted_at_max_age (Time.now - current_runner.contacted_at) >= contacted_at_max_age
end end
def job_not_found!
if headers['User-Agent'].to_s =~ /gitlab(-ci-multi)?-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /
no_content!
else
not_found!
end
end
def validate_job!(job) def validate_job!(job)
not_found! unless job not_found! unless job
......
...@@ -47,11 +47,25 @@ module API ...@@ -47,11 +47,25 @@ module API
authenticate_runner! authenticate_runner!
Ci::Runner.find_by_token(params[:token]).destroy Ci::Runner.find_by_token(params[:token]).destroy
end end
desc 'Validates authentication credentials' do
http_codes [[200, 'Credentials are valid'], [403, 'Forbidden']]
end
params do
requires :token, type: String, desc: %q(Runner's authentication token)
end
post '/verify' do
authenticate_runner!
status 200
end
end end
resource :jobs do resource :jobs do
desc 'Request a job' do desc 'Request a job' do
success Entities::JobRequest::Response success Entities::JobRequest::Response
http_codes [[201, 'Job was scheduled'],
[204, 'No job for Runner'],
[403, 'Forbidden']]
end end
params do params do
requires :token, type: String, desc: %q(Runner's authentication token) requires :token, type: String, desc: %q(Runner's authentication token)
...@@ -60,13 +74,13 @@ module API ...@@ -60,13 +74,13 @@ module API
end end
post '/request' do post '/request' do
authenticate_runner! authenticate_runner!
not_found! unless current_runner.active? no_content! unless current_runner.active?
update_runner_info update_runner_info
if current_runner.is_runner_queue_value_latest?(params[:last_update]) if current_runner.is_runner_queue_value_latest?(params[:last_update])
header 'X-GitLab-Last-Update', params[:last_update] header 'X-GitLab-Last-Update', params[:last_update]
Gitlab::Metrics.add_event(:build_not_found_cached) Gitlab::Metrics.add_event(:build_not_found_cached)
return job_not_found! return no_content!
end end
new_update = current_runner.ensure_runner_queue_value new_update = current_runner.ensure_runner_queue_value
...@@ -80,7 +94,7 @@ module API ...@@ -80,7 +94,7 @@ module API
else else
Gitlab::Metrics.add_event(:build_not_found) Gitlab::Metrics.add_event(:build_not_found)
header 'X-GitLab-Last-Update', new_update header 'X-GitLab-Last-Update', new_update
job_not_found! no_content!
end end
else else
# We received build that is invalid due to concurrency conflict # We received build that is invalid due to concurrency conflict
......
...@@ -4,6 +4,7 @@ FactoryGirl.define do ...@@ -4,6 +4,7 @@ FactoryGirl.define do
author author
association :source_project, :repository, factory: :project association :source_project, :repository, factory: :project
target_project { source_project } target_project { source_project }
project { target_project }
# $ git log --pretty=oneline feature..master # $ git log --pretty=oneline feature..master
# 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com # 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com
......
...@@ -133,7 +133,6 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do ...@@ -133,7 +133,6 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do
it 'changes target_branch in new merge_request' do it 'changes target_branch in new merge_request' do
visit new_namespace_project_merge_request_path(another_project.namespace, another_project, new_url_opts) visit new_namespace_project_merge_request_path(another_project.namespace, another_project, new_url_opts)
click_button "Compare branches and continue"
fill_in "merge_request_title", with: 'My brand new feature' fill_in "merge_request_title", with: 'My brand new feature'
fill_in "merge_request_description", with: "le feature \n/target_branch fix\nFeature description:" fill_in "merge_request_description", with: "le feature \n/target_branch fix\nFeature description:"
......
require "spec_helper" require "spec_helper"
describe TodosHelper do describe TodosHelper do
include GitlabRoutingHelper
describe '#todo_target_path' do
let(:project) { create(:project) }
let(:merge_request) { create(:merge_request, target_project: project, source_project: project) }
let(:issue) { create(:issue, project: project) }
let(:note) { create(:note_on_issue, noteable: issue, project: project) }
let(:mr_todo) { build(:todo, project: project, target: merge_request) }
let(:issue_todo) { build(:todo, project: project, target: issue) }
let(:note_todo) { build(:todo, project: project, target: issue, note: note) }
let(:build_failed_todo) { build(:todo, :build_failed, project: project, target: merge_request) }
it 'returns correct path to the todo MR' do
expect(todo_target_path(mr_todo)).
to eq("/#{project.full_path}/merge_requests/#{merge_request.iid}")
end
it 'returns correct path to the todo issue' do
expect(todo_target_path(issue_todo)).
to eq("/#{project.full_path}/issues/#{issue.iid}")
end
it 'returns correct path to the todo note' do
expect(todo_target_path(note_todo)).
to eq("/#{project.full_path}/issues/#{issue.iid}#note_#{note.id}")
end
it 'returns correct path to build_todo MR when pipeline failed' do
expect(todo_target_path(build_failed_todo)).
to eq("/#{project.full_path}/merge_requests/#{merge_request.iid}/pipelines")
end
end
describe '#todo_projects_options' do describe '#todo_projects_options' do
let(:projects) { create_list(:empty_project, 3) } let(:projects) { create_list(:empty_project, 3) }
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -152,6 +152,34 @@ describe API::Runner do ...@@ -152,6 +152,34 @@ describe API::Runner do
end end
end end
end end
describe 'POST /api/v4/runners/verify' do
let(:runner) { create(:ci_runner) }
context 'when no token is provided' do
it 'returns 400 error' do
post api('/runners/verify')
expect(response).to have_http_status :bad_request
end
end
context 'when invalid token is provided' do
it 'returns 403 error' do
post api('/runners/verify'), token: 'invalid-token'
expect(response).to have_http_status 403
end
end
context 'when valid token is provided' do
it 'verifies Runner credentials' do
post api('/runners/verify'), token: runner.token
expect(response).to have_http_status 200
end
end
end
end end
describe '/api/v4/jobs' do describe '/api/v4/jobs' do
...@@ -220,18 +248,6 @@ describe API::Runner do ...@@ -220,18 +248,6 @@ describe API::Runner do
it { expect(response).to have_http_status(204) } it { expect(response).to have_http_status(204) }
end end
end end
context "when runner doesn't send version in User-Agent" do
let(:user_agent) { 'Go-http-client/1.1' }
it { expect(response).to have_http_status(404) }
end
context "when runner doesn't have a User-Agent" do
let(:user_agent) { nil }
it { expect(response).to have_http_status(404) }
end
end end
context 'when no token is provided' do context 'when no token is provided' do
...@@ -254,10 +270,10 @@ describe API::Runner do ...@@ -254,10 +270,10 @@ describe API::Runner do
context 'when Runner is not active' do context 'when Runner is not active' do
let(:runner) { create(:ci_runner, :inactive) } let(:runner) { create(:ci_runner, :inactive) }
it 'returns 404 error' do it 'returns 204 error' do
request_job request_job
expect(response).to have_http_status 404 expect(response).to have_http_status 204
end end
end end
...@@ -401,9 +417,39 @@ describe API::Runner do ...@@ -401,9 +417,39 @@ describe API::Runner do
end end
context 'when project and pipeline have multiple jobs' do context 'when project and pipeline have multiple jobs' do
let!(:job) { create(:ci_build_tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
let!(:job2) { create(:ci_build_tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) }
let!(:test_job) { create(:ci_build, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 1) } let!(:test_job) { create(:ci_build, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 1) }
before { job.success } before do
job.success
job2.success
end
it 'returns dependent jobs' do
request_job
expect(response).to have_http_status(201)
expect(json_response['id']).to eq(test_job.id)
expect(json_response['dependencies'].count).to eq(2)
expect(json_response['dependencies']).to include({ 'id' => job.id, 'name' => job.name, 'token' => job.token },
{ 'id' => job2.id, 'name' => job2.name, 'token' => job2.token })
end
end
context 'when explicit dependencies are defined' do
let!(:job) { create(:ci_build_tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
let!(:job2) { create(:ci_build_tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) }
let!(:test_job) do
create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'deploy',
stage: 'deploy', stage_idx: 1,
options: { dependencies: [job2.name] })
end
before do
job.success
job2.success
end
it 'returns dependent jobs' do it 'returns dependent jobs' do
request_job request_job
...@@ -411,7 +457,7 @@ describe API::Runner do ...@@ -411,7 +457,7 @@ describe API::Runner do
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['id']).to eq(test_job.id) expect(json_response['id']).to eq(test_job.id)
expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'].count).to eq(1)
expect(json_response['dependencies'][0]).to include('id' => job.id, 'name' => 'spinach') expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token)
end end
end end
......
...@@ -49,10 +49,13 @@ describe MergeRequests::BuildService, services: true do ...@@ -49,10 +49,13 @@ describe MergeRequests::BuildService, services: true do
let(:commits) { Commit.decorate([commit_1], project) } let(:commits) { Commit.decorate([commit_1], project) }
it 'creates compare object with target branch as default branch' do it 'creates compare object with target branch as default branch' do
expect(merge_request.can_be_created).to eq(false)
expect(merge_request.compare).to be_present expect(merge_request.compare).to be_present
expect(merge_request.target_branch).to eq(project.default_branch) expect(merge_request.target_branch).to eq(project.default_branch)
end end
it 'allows the merge request to be created' do
expect(merge_request.can_be_created).to eq(true)
end
end end
context 'same source and target branch' do context 'same source and target branch' do
......
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