Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-02-19 06:10:35 +00:00
parent f9d2a3e215
commit 9da2bb742f
9 changed files with 145 additions and 17 deletions

View File

@ -280,7 +280,7 @@ module ApplicationHelper
def page_class
class_names = []
class_names << 'issue-boards-page gl-overflow-hidden' if current_controller?(:boards)
class_names << 'issue-boards-page gl-overflow-auto' if current_controller?(:boards)
class_names << 'environment-logs-page' if current_controller?(:logs)
class_names << 'with-performance-bar' if performance_bar_enabled?
class_names << system_message_class

View File

@ -0,0 +1,5 @@
---
title: Implement passing trigger payload into pipeline variable
merge_request: 54544
author:
type: added

View File

@ -0,0 +1,5 @@
---
title: Restore missing horizontal scrollbar on issue boards
merge_request: 54634
author:
type: fixed

View File

@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/321027
milestone: '13.9'
type: development
group: group::pipeline authoring
default_enabled: false
default_enabled: true

View File

@ -188,10 +188,10 @@ source repository. Be sure to URL-encode `ref` if it contains slashes.
### Using webhook payload in the triggered pipeline
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/31197) in GitLab 13.9.
> - It's [deployed behind a feature flag](../../user/feature_flags.md), disabled by default.
> - It's disabled on GitLab.com.
> - It's not recommended for production use.
> - To use it in GitLab self-managed instances, ask a GitLab administrator to [enable it](#enable-or-disable-the-trigger_payload-variable). **(FREE SELF)**
> - It's [deployed behind a feature flag](../../user/feature_flags.md), enabled by default.
> - It's enabled on GitLab.com.
> - It's recommended for production use.
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-the-trigger_payload-variable). **(FREE SELF)**
WARNING:
This feature might not be available to you. Check the **version history** note above for details.
@ -203,16 +203,10 @@ so you can access the data with `cat $TRIGGER_PAYLOAD` or a similar command.
#### Enable or disable the `TRIGGER_PAYLOAD` variable
The `TRIGGER_PAYLOAD` CI/CD variable is under development and not ready for production use. It is
deployed behind a feature flag that is **disabled by default**.
The `TRIGGER_PAYLOAD` CI/CD variable is under development but ready for production use.
It is deployed behind a feature flag that is **enabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can enable it.
To enable it:
```ruby
Feature.enable(:ci_trigger_payload_into_pipeline)
```
can opt to disable it.
To disable it:
@ -220,6 +214,12 @@ To disable it:
Feature.disable(:ci_trigger_payload_into_pipeline)
```
To enable it:
```ruby
Feature.enable(:ci_trigger_payload_into_pipeline)
```
## Making use of trigger variables
You can pass any number of arbitrary variables in the trigger API call and they

View File

@ -0,0 +1,48 @@
# frozen_string_literal: true
module Gitlab
module Analytics
module CycleAnalytics
class Average
include Gitlab::Utils::StrongMemoize
include StageQueryHelpers
def initialize(stage:, query:)
@stage = stage
@query = query
end
def seconds
select_average ? select_average['average'] : nil
end
def days
seconds ? seconds.fdiv(1.day) : nil
end
private
attr_reader :stage
# rubocop: disable CodeReuse/ActiveRecord
def select_average
strong_memoize(:select_average) do
execute_query(@query.select(average_in_seconds.as('average')).reorder(nil)).first
end
end
# rubocop: enable CodeReuse/ActiveRecord
def average
Arel::Nodes::NamedFunction.new(
'AVG',
[duration]
)
end
def average_in_seconds
Arel::Nodes::Extract.new(average, :epoch)
end
end
end
end
end

View File

@ -31,6 +31,12 @@ module Gitlab
end
end
def average
strong_memoize(:average) do
Average.new(stage: stage, query: query)
end
end
private
attr_reader :stage, :params

View File

@ -24,8 +24,6 @@ module QA
end
it 'runs auto devops', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/702' do
skip('Test requires tunnel: see https://gitlab.com/gitlab-org/gitlab/-/issues/251090')
Flow::Login.sign_in
# Set an application secret CI variable (prefixed with K8S_SECRET_)

View File

@ -0,0 +1,66 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Analytics::CycleAnalytics::Average do
let_it_be(:project) { create(:project) }
let_it_be(:issue_1) do
# Duration: 10 days
create(:issue, project: project, created_at: 20.days.ago).tap do |issue|
issue.metrics.update!(first_mentioned_in_commit_at: 10.days.ago)
end
end
let_it_be(:issue_2) do
# Duration: 5 days
create(:issue, project: project, created_at: 20.days.ago).tap do |issue|
issue.metrics.update!(first_mentioned_in_commit_at: 15.days.ago)
end
end
let(:stage) do
build(
:cycle_analytics_project_stage,
start_event_identifier: Gitlab::Analytics::CycleAnalytics::StageEvents::IssueCreated.identifier,
end_event_identifier: Gitlab::Analytics::CycleAnalytics::StageEvents::IssueFirstMentionedInCommit.identifier,
project: project
)
end
let(:query) { Issue.joins(:metrics).in_projects(project.id) }
around do |example|
freeze_time { example.run }
end
subject(:average) { described_class.new(stage: stage, query: query) }
describe '#seconds' do
subject(:average_duration_in_seconds) { average.seconds }
context 'when no results' do
let(:query) { Issue.none }
it { is_expected.to eq(nil) }
end
context 'returns the average duration in seconds' do
it { is_expected.to be_within(0.5).of(7.5.days.to_f) }
end
end
describe '#days' do
subject(:average_duration_in_days) { average.days }
context 'when no results' do
let(:query) { Issue.none }
it { is_expected.to eq(nil) }
end
context 'returns the average duration in days' do
it { is_expected.to be_within(0.01).of(7.5) }
end
end
end