Commit ed9c54b5 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 8f1f6b37
...@@ -9,6 +9,7 @@ stages: ...@@ -9,6 +9,7 @@ stages:
- review - review
- qa - qa
- post-test - post-test
- notification
- pages - pages
variables: variables:
...@@ -33,6 +34,7 @@ include: ...@@ -33,6 +34,7 @@ include:
- local: .gitlab/ci/frontend.gitlab-ci.yml - local: .gitlab/ci/frontend.gitlab-ci.yml
- local: .gitlab/ci/global.gitlab-ci.yml - local: .gitlab/ci/global.gitlab-ci.yml
- local: .gitlab/ci/memory.gitlab-ci.yml - local: .gitlab/ci/memory.gitlab-ci.yml
- local: .gitlab/ci/notifications.gitlab-ci.yml
- local: .gitlab/ci/pages.gitlab-ci.yml - local: .gitlab/ci/pages.gitlab-ci.yml
- local: .gitlab/ci/qa.gitlab-ci.yml - local: .gitlab/ci/qa.gitlab-ci.yml
- local: .gitlab/ci/reports.gitlab-ci.yml - local: .gitlab/ci/reports.gitlab-ci.yml
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
- "config.ru" - "config.ru"
- "{package.json,yarn.lock}" - "{package.json,yarn.lock}"
- "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*" - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- "doc/api/graphql/**/*" - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
.backstage-patterns: &backstage-patterns .backstage-patterns: &backstage-patterns
- "Dangerfile" - "Dangerfile"
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
- "config.ru" - "config.ru"
- "{package.json,yarn.lock}" - "{package.json,yarn.lock}"
- "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*" - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- "doc/api/graphql/**/*" - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
# Backstage changes # Backstage changes
- "Dangerfile" - "Dangerfile"
- "danger/**/*" - "danger/**/*"
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
- "config.ru" - "config.ru"
- "{package.json,yarn.lock}" - "{package.json,yarn.lock}"
- "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*" - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- "doc/api/graphql/**/*" - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
# QA changes # QA changes
- ".dockerignore" - ".dockerignore"
- "qa/**/*" - "qa/**/*"
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
- "config.ru" - "config.ru"
- "{package.json,yarn.lock}" - "{package.json,yarn.lock}"
- "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*" - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- "doc/api/graphql/**/*" - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
# Backstage changes # Backstage changes
- "Dangerfile" - "Dangerfile"
- "danger/**/*" - "danger/**/*"
......
.notify:
image: alpine
stage: notification
dependencies: []
cache: {}
before_script:
- apk update && apk add git curl bash
variables:
COMMIT_NOTES_URL: "https://$CI_SERVER_HOST/$CI_PROJECT_PATH/commit/$CI_COMMIT_SHA#notes-list"
schedule:package-and-qa:notify-failure:
extends:
- .only:variables_refs-canonical-dot-com-schedules
- .notify
script:
- 'scripts/notify-slack qa-master ":skull_and_crossbones: Scheduled QA against master failed! :skull_and_crossbones: See $CI_PIPELINE_URL. For downstream pipelines, see $COMMIT_NOTES_URL" ci_failing'
needs: ["schedule:package-and-qa"]
when: on_failure
...@@ -48,7 +48,7 @@ export default { ...@@ -48,7 +48,7 @@ export default {
}); });
}, },
[types.RECEIVE_SEARCHED_ITEMS_SUCCESS](state, results) { [types.RECEIVE_SEARCHED_ITEMS_SUCCESS](state, results) {
const rawItems = results.data; const rawItems = results.data ? results.data : results; // Api.groups returns array, Api.projects returns object
Object.assign(state, { Object.assign(state, {
items: rawItems.map(rawItem => ({ items: rawItems.map(rawItem => ({
id: rawItem.id, id: rawItem.id,
......
...@@ -602,3 +602,19 @@ export const getDatesInRange = (d1, d2, formatter = x => x) => { ...@@ -602,3 +602,19 @@ export const getDatesInRange = (d1, d2, formatter = x => x) => {
* @return {Number} number of milliseconds * @return {Number} number of milliseconds
*/ */
export const secondsToMilliseconds = seconds => seconds * 1000; export const secondsToMilliseconds = seconds => seconds * 1000;
/**
* Converts the supplied number of seconds to days.
*
* @param {Number} seconds
* @return {Number} number of days
*/
export const secondsToDays = seconds => Math.round(seconds / 86400);
/**
* Returns the date after the date provided
*
* @param {Date} date the initial date
* @return {Date} the date following the date provided
*/
export const dayAfter = date => new Date(newDate(date).setDate(date.getDate() + 1));
import invalidUrl from '~/lib/utils/invalid_url'; import invalidUrl from '~/lib/utils/invalid_url';
export default () => ({ export default () => ({
hasMetrics: false,
showPanels: true,
metricsEndpoint: null, metricsEndpoint: null,
environmentsEndpoint: null, environmentsEndpoint: null,
deploymentsEndpoint: null, deploymentsEndpoint: null,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Clusters module Clusters
module Applications module Applications
class Runner < ApplicationRecord class Runner < ApplicationRecord
VERSION = '0.10.1' VERSION = '0.11.0'
self.table_name = 'clusters_applications_runners' self.table_name = 'clusters_applications_runners'
......
---
title: Allow specifying Kubernetes namespace for an environment in gitlab-ci.yml
merge_request: 20270
author:
type: added
---
title: Fix group search in groups dropdown
merge_request: 20535
author:
type: fixed
---
title: Update GitLab Runner Helm Chart to 0.11.0
merge_request: 20461
author:
type: other
...@@ -135,6 +135,7 @@ The following job parameters can be defined inside a `default:` block: ...@@ -135,6 +135,7 @@ The following job parameters can be defined inside a `default:` block:
- [`before_script`](#before_script-and-after_script) - [`before_script`](#before_script-and-after_script)
- [`after_script`](#before_script-and-after_script) - [`after_script`](#before_script-and-after_script)
- [`cache`](#cache) - [`cache`](#cache)
- [`retry`](#retry)
- [`timeout`](#timeout) - [`timeout`](#timeout)
- [`interruptible`](#interruptible) - [`interruptible`](#interruptible)
......
...@@ -29,6 +29,7 @@ The current stages are: ...@@ -29,6 +29,7 @@ The current stages are:
- `review`: This stage includes jobs that deploy the GitLab and Docs Review Apps. - `review`: This stage includes jobs that deploy the GitLab and Docs Review Apps.
- `qa`: This stage includes jobs that perform QA tasks against the Review App - `qa`: This stage includes jobs that perform QA tasks against the Review App
that is deployed in the previous stage. that is deployed in the previous stage.
- `notification`: This stage includes jobs that sends notifications about pipeline status.
- `post-test`: This stage includes jobs that build reports or gather data from - `post-test`: This stage includes jobs that build reports or gather data from
the previous stages' jobs (e.g. coverage, Knapsack metadata etc.). the previous stages' jobs (e.g. coverage, Knapsack metadata etc.).
- `pages`: This stage includes a job that deploys the various reports as - `pages`: This stage includes a job that deploys the various reports as
...@@ -209,6 +210,11 @@ subgraph "`qa` stage" ...@@ -209,6 +210,11 @@ subgraph "`qa` stage"
dast -.-> |needs and depends on| G; dast -.-> |needs and depends on| G;
end end
subgraph "`notification` stage"
NOTIFICATION1["schedule:package-and-qa:notify-success<br>(on_success)"] -.-> |needs| P;
NOTIFICATION2["schedule:package-and-qa:notify-failure<br>(on_failure)"] -.-> |needs| P;
end
subgraph "`post-test` stage" subgraph "`post-test` stage"
M M
end end
......
...@@ -15,7 +15,7 @@ module Gitlab ...@@ -15,7 +15,7 @@ module Gitlab
ALLOWED_KEYS = %i[before_script image services ALLOWED_KEYS = %i[before_script image services
after_script cache interruptible after_script cache interruptible
timeout].freeze timeout retry].freeze
validations do validations do
validates :config, allowed_keys: ALLOWED_KEYS validates :config, allowed_keys: ALLOWED_KEYS
...@@ -49,7 +49,11 @@ module Gitlab ...@@ -49,7 +49,11 @@ module Gitlab
description: 'Set jobs default timeout.', description: 'Set jobs default timeout.',
inherit: false inherit: false
helpers :before_script, :image, :services, :after_script, :cache, :interruptible, :timeout entry :retry, Entry::Retry,
description: 'Set retry default value.',
inherit: false
helpers :before_script, :image, :services, :after_script, :cache, :interruptible, :timeout, :retry
private private
......
...@@ -8,9 +8,11 @@ module Gitlab ...@@ -8,9 +8,11 @@ module Gitlab
# Entry that represents an environment. # Entry that represents an environment.
# #
class Environment < ::Gitlab::Config::Entry::Node class Environment < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable include ::Gitlab::Config::Entry::Configurable
ALLOWED_KEYS = %i[name url action on_stop].freeze ALLOWED_KEYS = %i[name url action on_stop kubernetes].freeze
entry :kubernetes, Entry::Kubernetes, description: 'Kubernetes deployment configuration.'
validations do validations do
validate do validate do
...@@ -46,6 +48,7 @@ module Gitlab ...@@ -46,6 +48,7 @@ module Gitlab
allow_nil: true allow_nil: true
validates :on_stop, type: String, allow_nil: true validates :on_stop, type: String, allow_nil: true
validates :kubernetes, type: Hash, allow_nil: true
end end
end end
...@@ -73,6 +76,10 @@ module Gitlab ...@@ -73,6 +76,10 @@ module Gitlab
value[:on_stop] value[:on_stop]
end end
def kubernetes
value[:kubernetes]
end
def value def value
case @config case @config
when String then { name: @config, action: 'start' } when String then { name: @config, action: 'start' }
...@@ -80,6 +87,10 @@ module Gitlab ...@@ -80,6 +87,10 @@ module Gitlab
else {} else {}
end end
end end
def skip_config_hash_validation?
true
end
end end
end end
end end
......
...@@ -105,6 +105,10 @@ module Gitlab ...@@ -105,6 +105,10 @@ module Gitlab
description: 'Timeout duration of this job.', description: 'Timeout duration of this job.',
inherit: true inherit: true
entry :retry, Entry::Retry,
description: 'Retry configuration for this job.',
inherit: true
entry :only, Entry::Policy, entry :only, Entry::Policy,
description: 'Refs policy this job will be executed for.', description: 'Refs policy this job will be executed for.',
default: Entry::Policy::DEFAULT_ONLY, default: Entry::Policy::DEFAULT_ONLY,
...@@ -142,10 +146,6 @@ module Gitlab ...@@ -142,10 +146,6 @@ module Gitlab
description: 'Coverage configuration for this job.', description: 'Coverage configuration for this job.',
inherit: false inherit: false
entry :retry, Entry::Retry,
description: 'Retry configuration for this job.',
inherit: false
helpers :before_script, :script, :stage, :type, :after_script, helpers :before_script, :script, :stage, :type, :after_script,
:cache, :image, :services, :only, :except, :variables, :cache, :image, :services, :only, :except, :variables,
:artifacts, :environment, :coverage, :retry, :rules, :artifacts, :environment, :coverage, :retry, :rules,
......
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Entry
class Kubernetes < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
include ::Gitlab::Config::Entry::Attributable
ALLOWED_KEYS = %i[namespace].freeze
attributes ALLOWED_KEYS
validations do
validates :config, type: Hash
validates :config, allowed_keys: ALLOWED_KEYS
validates :namespace, type: String, presence: true
end
end
end
end
end
end
#!/bin/bash
# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set).
# ICON_EMOJI needs to be set to an icon emoji name (without the `:` around it).
CHANNEL=$1
MSG=$2
ICON_EMOJI=$3
if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ]; then
echo "Missing argument(s) - Use: $0 channel message icon_emoji"
echo "and set CI_SLACK_WEBHOOK_URL environment variable."
else
curl -X POST --data-urlencode 'payload={"channel": "#'"$CHANNEL"'", "username": "GitLab QA Bot", "text": "'"$MSG"'", "icon_emoji": "'":$ICON_EMOJI:"'"}' "$CI_SLACK_WEBHOOK_URL"
fi
...@@ -482,3 +482,27 @@ describe('secondsToMilliseconds', () => { ...@@ -482,3 +482,27 @@ describe('secondsToMilliseconds', () => {
expect(datetimeUtility.secondsToMilliseconds(123)).toBe(123000); expect(datetimeUtility.secondsToMilliseconds(123)).toBe(123000);
}); });
}); });
describe('dayAfter', () => {
const date = new Date('2019-07-16T00:00:00.000Z');
it('returns the following date', () => {
const nextDay = datetimeUtility.dayAfter(date);
const expectedNextDate = new Date('2019-07-17T00:00:00.000Z');
expect(nextDay).toStrictEqual(expectedNextDate);
});
it('does not modifiy the original date', () => {
datetimeUtility.dayAfter(date);
expect(date).toStrictEqual(new Date('2019-07-16T00:00:00.000Z'));
});
});
describe('secondsToDays', () => {
it('converts seconds to days correctly', () => {
expect(datetimeUtility.secondsToDays(0)).toBe(0);
expect(datetimeUtility.secondsToDays(90000)).toBe(1);
expect(datetimeUtility.secondsToDays(270000)).toBe(3);
});
});
...@@ -68,7 +68,7 @@ export const mockFrequentGroups = [ ...@@ -68,7 +68,7 @@ export const mockFrequentGroups = [
}, },
]; ];
export const mockSearchedGroups = { data: [mockRawGroup] }; export const mockSearchedGroups = [mockRawGroup];
export const mockProcessedSearchedGroups = [mockGroup]; export const mockProcessedSearchedGroups = [mockGroup];
export const mockProject = { export const mockProject = {
......
...@@ -27,7 +27,7 @@ describe Gitlab::Ci::Config::Entry::Default do ...@@ -27,7 +27,7 @@ describe Gitlab::Ci::Config::Entry::Default do
expect(described_class.nodes.keys) expect(described_class.nodes.keys)
.to match_array(%i[before_script image services .to match_array(%i[before_script image services
after_script cache interruptible after_script cache interruptible
timeout]) timeout retry])
end end
end end
end end
......
...@@ -241,4 +241,28 @@ describe Gitlab::Ci::Config::Entry::Environment do ...@@ -241,4 +241,28 @@ describe Gitlab::Ci::Config::Entry::Environment do
end end
end end
end end
describe 'kubernetes' do
let(:config) do
{ name: 'production', kubernetes: kubernetes_config }
end
context 'is a string' do
let(:kubernetes_config) { 'production' }
it { expect(entry).not_to be_valid }
end
context 'is a hash' do
let(:kubernetes_config) { Hash(namespace: 'production') }
it { expect(entry).to be_valid }
end
context 'is nil' do
let(:kubernetes_config) { nil }
it { expect(entry).to be_valid }
end
end
end end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::Ci::Config::Entry::Kubernetes do
subject { described_class.new(config) }
describe 'attributes' do
it { is_expected.to respond_to(:namespace) }
it { is_expected.to respond_to(:has_namespace?) }
end
describe 'validations' do
describe 'config' do
context 'is a hash containing known keys' do
let(:config) { Hash(namespace: 'namespace') }
it { is_expected.to be_valid }
end
context 'is a hash containing an unknown key' do
let(:config) { Hash(unknown: 'attribute') }
it { is_expected.not_to be_valid }
end
context 'is a string' do
let(:config) { 'config' }
it { is_expected.not_to be_valid }
end
end
describe 'namespace' do
let(:config) { Hash(namespace: namespace) }
context 'is a string' do
let(:namespace) { 'namespace' }
it { is_expected.to be_valid }
end
context 'is a hash' do
let(:namespace) { Hash(key: 'namespace') }
it { is_expected.not_to be_valid }
end
context 'is not present' do
let(:namespace) { '' }
it { is_expected.not_to be_valid }
end
end
end
end
...@@ -149,6 +149,28 @@ module Gitlab ...@@ -149,6 +149,28 @@ module Gitlab
expect(subject[:options]).not_to have_key(:retry) expect(subject[:options]).not_to have_key(:retry)
end end
end end
context 'when retry count is specified by default' do
let(:config) do
YAML.dump(default: { retry: { max: 1 } },
rspec: { script: 'rspec' })
end
it 'does use the default value' do
expect(subject[:options]).to include(retry: { max: 1 })
end
end
context 'when retry count default value is overridden' do
let(:config) do
YAML.dump(default: { retry: { max: 1 } },
rspec: { script: 'rspec', retry: { max: 2 } })
end
it 'does use the job value' do
expect(subject[:options]).to include(retry: { max: 2 })
end
end
end end
describe 'allow failure entry' do describe 'allow failure entry' do
......
...@@ -801,6 +801,32 @@ describe Ci::CreatePipelineService do ...@@ -801,6 +801,32 @@ describe Ci::CreatePipelineService do
end end
end end
context 'environment with Kubernetes configuration' do
let(:kubernetes_namespace) { 'custom-namespace' }
before do
config = YAML.dump(
deploy: {
environment: {
name: "environment-name",
kubernetes: { namespace: kubernetes_namespace }
},
script: 'ls'
}
)
stub_ci_pipeline_yaml_file(config)
end
it 'stores the requested namespace' do
result = execute_service
build = result.builds.first
expect(result).to be_persisted
expect(build.options.dig(:environment, :kubernetes, :namespace)).to eq(kubernetes_namespace)
end
end
context 'when environment with invalid name' do context 'when environment with invalid name' do
before do before do
config = YAML.dump(deploy: { environment: { name: 'name,with,commas' }, script: 'ls' }) config = YAML.dump(deploy: { environment: { name: 'name,with,commas' }, script: 'ls' })
......
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