Commit b5571e6e authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent f92a53a2
......@@ -23,7 +23,7 @@ build-qa-image:
stage: prepare
script:
- '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"'
- export QA_MASTER_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:master"
- export QA_MASTER_IMAGE="${CI_REGISTRY}/gitlab-org/gitlab/gitlab/gitlab-${GITLAB_EDITION}-qa:master"
- export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}"
- time docker pull "${QA_MASTER_IMAGE}"
- time docker build --cache-from "${QA_MASTER_IMAGE}" --tag ${QA_IMAGE} --file ./qa/Dockerfile ./
......
......@@ -2,13 +2,13 @@
import $ from 'jquery';
import _ from 'underscore';
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import Cookies from 'js-cookie';
import { __ } from './locale';
import { updateTooltipTitle } from './lib/utils/common_utils';
import { isInVueNoteablePage } from './lib/utils/dom_utils';
import flash from './flash';
import axios from './lib/utils/axios_utils';
import bp from './breakpoints';
const animationEndEventString = 'animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd';
const transitionEndEventString = 'transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd';
......
......@@ -2,7 +2,7 @@
class Projects::Environments::SampleMetricsController < Projects::ApplicationController
def query
result = Metrics::SampleMetricsService.new(params[:identifier]).query
result = Metrics::SampleMetricsService.new(params[:identifier], range_start: params[:start], range_end: params[:end]).query
if result
render json: { "status": "success", "data": { "resultType": "matrix", "result": result } }
......
......@@ -15,11 +15,11 @@ module Taskable
INCOMPLETE_PATTERN = /(\[[\s]\])/.freeze
ITEM_PATTERN = %r{
^
(?:(?:>\s{0,4})*) # optional blockquote characters
\s*(?:[-+*]|(?:\d+\.)) # list prefix required - task item has to be always in a list
\s+ # whitespace prefix has to be always presented for a list item
(\[\s\]|\[[xX]\]) # checkbox
(\s.+) # followed by whitespace and some text.
(?:(?:>\s{0,4})*) # optional blockquote characters
(?:\s*(?:[-+*]|(?:\d+\.)))+ # list prefix (one or more) required - task item has to be always in a list
\s+ # whitespace prefix has to be always presented for a list item
(\[\s\]|\[[xX]\]) # checkbox
(\s.+) # followed by whitespace and some text.
}x.freeze
def self.get_tasks(content)
......
......@@ -4,16 +4,17 @@ module Metrics
class SampleMetricsService
DIRECTORY = "sample_metrics"
attr_reader :identifier
attr_reader :identifier, :range_minutes
def initialize(identifier)
def initialize(identifier, range_start:, range_end:)
@identifier = identifier
@range_minutes = convert_range_minutes(range_start, range_end)
end
def query
return unless identifier && File.exist?(file_location)
YAML.load_file(File.expand_path(file_location, __dir__))
query_interval
end
private
......@@ -22,5 +23,14 @@ module Metrics
sanitized_string = identifier.gsub(/[^0-9A-Za-z_]/, '')
File.join(Rails.root, DIRECTORY, "#{sanitized_string}.yml")
end
def query_interval
result = YAML.load_file(File.expand_path(file_location, __dir__))
result[range_minutes]
end
def convert_range_minutes(range_start, range_end)
((range_end.to_time - range_start.to_time) / 1.minute).to_i
end
end
end
---
title: Properly check a task embedded in a list with no text
merge_request: 21947
author:
type: fixed
---
title: Add full text search to pod logs
merge_request: 21656
author:
type: added
---
title: Rename common template jobs in sast and ds
merge_request: 22084
author:
type: fixed
---
title: Generate Prometheus sample metrics over pre-set intervals
merge_request: 22066
author:
type: added
---
title: Update Workhorse to v8.18.0
merge_request: 22091
author:
type: other
......@@ -58,6 +58,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :trace, defaults: { format: 'json' }
get :raw
get :terminal
# This route is also defined in gitlab-workhorse. Make sure to update accordingly.
get '/terminal.ws/authorize', to: 'jobs#terminal_websocket_authorize', format: false
end
......@@ -235,6 +237,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :metrics
get :additional_metrics
get :metrics_dashboard
# This route is also defined in gitlab-workhorse. Make sure to update accordingly.
get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', format: false
get '/prometheus/api/v1/*proxy_path', to: 'environments/prometheus_api#proxy', as: :prometheus_api
......
......@@ -78,13 +78,27 @@ projects:
All Go projects should include these GitLab CI/CD jobs:
```yaml
go lint:
image: golang:1.11
lint:
image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine
stage: test
script:
- go get -u golang.org/x/lint/golint
- golint -set_exit_status $(go list ./... | grep -v "vendor/")
# Use default .golangci.yml file from the image if one is not present in the project root.
- '[ -e .golangci.yml ] || cp /golangci/.golangci.yml .'
# Write the code coverage report to gl-code-quality-report.json
# and print linting issues to stdout in the format: path/to/file:line description
- golangci-lint run --out-format code-climate | tee gl-code-quality-report.json | jq -r '.[] | "\(.location.path):\(.location.lines.begin) \(.description)"'
artifacts:
reports:
codequality: gl-code-quality-report.json
paths:
- gl-code-quality-report.json
allow_failure: true
```
Including a `.golangci.yml` in the root directory of the project allows for
configuration of `golangci-lint`. All options for `golangci-lint` are listed in
this [example](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml).
Once [recursive includes](https://gitlab.com/gitlab-org/gitlab-foss/issues/56836)
become available, you will be able to share job templates like this
[analyzer](https://gitlab.com/gitlab-org/security-products/ci-templates/raw/master/includes-dev/analyzer.yml).
......
# Generate Sample Prometheus Data
This command will run Prometheus queries for each of the metrics of a specific environment
for a default time interval of 7 days ago to now. The results of each of query are stored
under a `sample_metrics` directory as a yaml file named by the metric's `identifier`.
When the environmental variable `USE_SAMPLE_METRICS` is set, the Prometheus API query is
re-routed to `Projects::Environments::SampleMetricsController` which loads the appropriate
data set if it is present within the `sample_metrics` directory.
for a series of time intervals: 30 minutes, 3 hours, 8 hours, 24 hours, 72 hours, and 7 days
to now. The results of each of query are stored under a `sample_metrics` directory as a yaml
file named by the metric's `identifier`. When the environmental variable `USE_SAMPLE_METRICS`
is set, the Prometheus API query is re-routed to `Projects::Environments::SampleMetricsController`
which loads the appropriate data set if it is present within the `sample_metrics` directory.
- This command requires an id from an Environment with an available Prometheus installation.
......
......@@ -72,7 +72,7 @@ dependency_scanning:
- $DEPENDENCY_SCANNING_DISABLED
- $DS_DISABLE_DIND == 'true'
.analyzer:
.ds-analyzer:
extends: dependency_scanning
services: []
except:
......@@ -82,7 +82,7 @@ dependency_scanning:
- /analyzer run
gemnasium-dependency_scanning:
extends: .analyzer
extends: .ds-analyzer
image:
name: "$DS_ANALYZER_IMAGE_PREFIX/gemnasium:$DS_MAJOR_VERSION"
only:
......@@ -92,7 +92,7 @@ gemnasium-dependency_scanning:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /ruby|javascript|php/
gemnasium-maven-dependency_scanning:
extends: .analyzer
extends: .ds-analyzer
image:
name: "$DS_ANALYZER_IMAGE_PREFIX/gemnasium-maven:$DS_MAJOR_VERSION"
only:
......@@ -102,7 +102,7 @@ gemnasium-maven-dependency_scanning:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\bjava\b/
gemnasium-python-dependency_scanning:
extends: .analyzer
extends: .ds-analyzer
image:
name: "$DS_ANALYZER_IMAGE_PREFIX/gemnasium-python:$DS_MAJOR_VERSION"
only:
......@@ -112,7 +112,7 @@ gemnasium-python-dependency_scanning:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /python/
bundler-audit-dependency_scanning:
extends: .analyzer
extends: .ds-analyzer
image:
name: "$DS_ANALYZER_IMAGE_PREFIX/bundler-audit:$DS_MAJOR_VERSION"
only:
......@@ -122,7 +122,7 @@ bundler-audit-dependency_scanning:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /ruby/
retire-js-dependency_scanning:
extends: .analyzer
extends: .ds-analyzer
image:
name: "$DS_ANALYZER_IMAGE_PREFIX/retire.js:$DS_MAJOR_VERSION"
only:
......
......@@ -50,7 +50,7 @@ sast:
- $SAST_DISABLED
- $SAST_DISABLE_DIND == 'true'
.analyzer:
.sast-analyzer:
extends: sast
services: []
except:
......@@ -60,7 +60,7 @@ sast:
- /analyzer run
bandit-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/bandit:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -70,7 +70,7 @@ bandit-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /python/
brakeman-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -80,7 +80,7 @@ brakeman-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /ruby/
eslint-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/eslint:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -90,7 +90,7 @@ eslint-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/
flawfinder-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -100,7 +100,7 @@ flawfinder-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\b(c\+\+|c)\b/
kubesec-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/kubesec:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -110,7 +110,7 @@ kubesec-sast:
$SCAN_KUBERNETES_MANIFESTS == 'true'
gosec-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/gosec:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -120,7 +120,7 @@ gosec-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\bgo\b/
nodejs-scan-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -130,7 +130,7 @@ nodejs-scan-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/
phpcs-security-audit-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/phpcs-security-audit:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -140,7 +140,7 @@ phpcs-security-audit-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /php/
pmd-apex-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/pmd-apex:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -150,7 +150,7 @@ pmd-apex-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /apex/
secrets-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/secrets:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -159,7 +159,7 @@ secrets-sast:
$SAST_DEFAULT_ANALYZERS =~ /secrets/
security-code-scan-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/security-code-scan:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -169,7 +169,7 @@ security-code-scan-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\b(c\#|visual basic\b)/
sobelow-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/sobelow:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -179,7 +179,7 @@ sobelow-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /elixir/
spotbugs-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/spotbugs:$SAST_ANALYZER_IMAGE_TAG"
only:
......@@ -189,7 +189,7 @@ spotbugs-sast:
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /java\b/
tslint-sast:
extends: .analyzer
extends: .sast-analyzer
image:
name: "$SAST_ANALYZER_IMAGE_PREFIX/tslint:$SAST_ANALYZER_IMAGE_TAG"
only:
......
......@@ -8,12 +8,17 @@ namespace :gitlab do
sample_metrics_directory_name = Metrics::SampleMetricsService::DIRECTORY
FileUtils.mkdir_p(sample_metrics_directory_name)
sample_metrics_intervals = [30.minutes, 180.minutes, 8.hours, 24.hours, 72.hours, 7.days]
metrics.each do |metric|
query = metric.query % query_variables
result = environment.prometheus_adapter.prometheus_client.query_range(query, start: 7.days.ago)
next unless metric.identifier
result = sample_metrics_intervals.each_with_object({}) do |interval, memo|
memo[interval.to_i / 60] = environment.prometheus_adapter.prometheus_client.query_range(query, start: interval.ago)
end
File.write("#{sample_metrics_directory_name}/#{metric.identifier}.yml", result.to_yaml)
end
end
......
......@@ -6896,6 +6896,9 @@ msgstr ""
msgid "Environments|Rollback environment %{name}?"
msgstr ""
msgid "Environments|Search"
msgstr ""
msgid "Environments|Show all"
msgstr ""
......
......@@ -24,12 +24,8 @@ module QA
project = Resource::Project.fabricate_via_api! do |resource|
resource.name = 'xss-test-for-mentions-project'
end
project.visit!
Page::Project::Show.perform(&:go_to_members_settings)
Page::Project::Settings::Members.perform do |members|
members.add_member(user.username)
end
Flow::Project.add_member(project: project, username: user.username)
issue = Resource::Issue.fabricate_via_api! do |issue|
issue.title = 'issue title'
......@@ -42,7 +38,7 @@ module QA
show.comment("cc-ing you here @#{user.username}")
expect do
expect(show).to have_content("cc-ing you here")
expect(show).to have_comment("cc-ing you here")
end.not_to raise_error # Selenium::WebDriver::Error::UnhandledAlertError
end
end
......
......@@ -58,7 +58,9 @@ describe Projects::Environments::SampleMetricsController do
id: environment.id.to_s,
namespace_id: project.namespace.full_path,
project_id: project.name,
identifier: 'sample_metric_query_result'
identifier: 'sample_metric_query_result',
start: '2019-12-02T23:31:45.000Z',
end: '2019-12-03T00:01:45.000Z'
}.merge(params)
end
end
......@@ -4,7 +4,10 @@ require 'spec_helper'
describe Metrics::SampleMetricsService do
describe 'query' do
subject { described_class.new(identifier).query }
let(:range_start) { '2019-12-02T23:31:45.000Z' }
let(:range_end) { '2019-12-03T00:01:45.000Z' }
subject { described_class.new(identifier, range_start: range_start, range_end: range_end).query }
context 'when the file is not found' do
let(:identifier) { nil }
......@@ -26,10 +29,10 @@ describe Metrics::SampleMetricsService do
FileUtils.rm(destination)
end
subject { described_class.new(identifier).query }
subject { described_class.new(identifier, range_start: range_start, range_end: range_end).query }
it 'loads data from the sample file correctly' do
expect(subject).to eq(YAML.load_file(source))
expect(subject).to eq(YAML.load_file(source)[30])
end
end
......
......@@ -121,7 +121,7 @@ describe TaskListToggleService do
> * [x] Task 2
EOT
markdown_html = Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
markdown_html = parse_markdown(markdown)
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: true,
line_source: '> > * [ ] Task 1', line_number: 1)
......@@ -142,7 +142,7 @@ describe TaskListToggleService do
* [x] Task 2
EOT
markdown_html = Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
markdown_html = parse_markdown(markdown)
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: true,
line_source: '* [ ] Task 1', line_number: 5)
......@@ -151,4 +151,44 @@ describe TaskListToggleService do
expect(toggler.updated_markdown.lines[4]).to eq "* [x] Task 1\n"
expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
end
context 'when clicking an embedded subtask' do
it 'properly handles it inside an unordered list' do
markdown =
<<-EOT.strip_heredoc
- - [ ] Task 1
- [x] Task 2
EOT
markdown_html = parse_markdown(markdown)
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: true,
line_source: '- - [ ] Task 1', line_number: 1)
expect(toggler.execute).to be_truthy
expect(toggler.updated_markdown.lines[0]).to eq "- - [x] Task 1\n"
expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
end
it 'properly handles it inside an ordered list' do
markdown =
<<-EOT.strip_heredoc
1. - [ ] Task 1
- [x] Task 2
EOT
markdown_html = parse_markdown(markdown)
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: true,
line_source: '1. - [ ] Task 1', line_number: 1)
expect(toggler.execute).to be_truthy
expect(toggler.updated_markdown.lines[0]).to eq "1. - [x] Task 1\n"
expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
end
end
def parse_markdown(markdown)
Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
end
end
......@@ -17,7 +17,7 @@ describe 'gitlab:generate_sample_prometheus_data rake task' do
it 'creates the file correctly' do
Rake.application.rake_require 'tasks/gitlab/generate_sample_prometheus_data'
allow(Environment).to receive(:find).and_return(environment)
allow(environment).to receive_message_chain(:prometheus_adapter, :prometheus_client, :query_range) { sample_query_result }
allow(environment).to receive_message_chain(:prometheus_adapter, :prometheus_client, :query_range) { sample_query_result[30] }
run_rake_task('gitlab:generate_sample_prometheus_data', [environment.id])
expect(File.exist?(sample_query_file)).to be true
......
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