From 9a538b9eebd6aed362c6ed86445d96c8e06ffdf2 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 9 Mar 2018 15:54:20 +0800 Subject: [PATCH 01/65] Introduce Key namespace so we could put more keys --- qa/qa.rb | 5 +++- qa/qa/runtime/key/rsa.rb | 23 +++++++++++++++++++ qa/qa/runtime/rsa_key.rb | 21 ----------------- .../features/project/add_deploy_key_spec.rb | 2 +- .../features/project/deploy_key_clone_spec.rb | 2 +- .../runtime/{rsa_key.rb => key/rsa_spec.rb} | 2 +- 6 files changed, 30 insertions(+), 25 deletions(-) create mode 100644 qa/qa/runtime/key/rsa.rb delete mode 100644 qa/qa/runtime/rsa_key.rb rename qa/spec/runtime/{rsa_key.rb => key/rsa_spec.rb} (85%) diff --git a/qa/qa.rb b/qa/qa.rb index 7220af5088e..f2ad43cd04a 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -11,9 +11,12 @@ module QA autoload :Scenario, 'qa/runtime/scenario' autoload :Browser, 'qa/runtime/browser' autoload :Env, 'qa/runtime/env' - autoload :RSAKey, 'qa/runtime/rsa_key' autoload :Address, 'qa/runtime/address' autoload :API, 'qa/runtime/api' + + module Key + autoload :RSA, 'qa/runtime/key/rsa' + end end ## diff --git a/qa/qa/runtime/key/rsa.rb b/qa/qa/runtime/key/rsa.rb new file mode 100644 index 00000000000..faa6b47b5a0 --- /dev/null +++ b/qa/qa/runtime/key/rsa.rb @@ -0,0 +1,23 @@ +require 'net/ssh' +require 'forwardable' + +module QA + module Runtime + module Key + class RSA + extend Forwardable + + attr_reader :key + def_delegators :@key, :fingerprint, :to_pem + + def initialize(bits = 4096) + @key = OpenSSL::PKey::RSA.new(bits) + end + + def public_key + @public_key ||= "#{key.ssh_type} #{[key.to_blob].pack('m0')}" + end + end + end + end +end diff --git a/qa/qa/runtime/rsa_key.rb b/qa/qa/runtime/rsa_key.rb deleted file mode 100644 index fcd7dcc4f02..00000000000 --- a/qa/qa/runtime/rsa_key.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'net/ssh' -require 'forwardable' - -module QA - module Runtime - class RSAKey - extend Forwardable - - attr_reader :key - def_delegators :@key, :fingerprint, :to_pem - - def initialize(bits = 4096) - @key = OpenSSL::PKey::RSA.new(bits) - end - - def public_key - @public_key ||= "#{key.ssh_type} #{[key.to_blob].pack('m0')}" - end - end - end -end diff --git a/qa/qa/specs/features/project/add_deploy_key_spec.rb b/qa/qa/specs/features/project/add_deploy_key_spec.rb index b9998dda895..79e5ebe3633 100644 --- a/qa/qa/specs/features/project/add_deploy_key_spec.rb +++ b/qa/qa/specs/features/project/add_deploy_key_spec.rb @@ -4,7 +4,7 @@ module QA Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } - key = Runtime::RSAKey.new + key = Runtime::Key::RSA.new deploy_key_title = 'deploy key title' deploy_key_value = key.public_key diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 19d3c83758a..0c09f8168d9 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -3,7 +3,7 @@ require 'digest/sha1' module QA feature 'cloning code using a deploy key', :core, :docker do let(:runner_name) { "qa-runner-#{Time.now.to_i}" } - let(:key) { Runtime::RSAKey.new } + let(:key) { Runtime::Key::RSA.new } given(:project) do Factory::Resource::Project.fabricate! do |resource| diff --git a/qa/spec/runtime/rsa_key.rb b/qa/spec/runtime/key/rsa_spec.rb similarity index 85% rename from qa/spec/runtime/rsa_key.rb rename to qa/spec/runtime/key/rsa_spec.rb index 6d7ab4dcd2e..0921f9a7c6b 100644 --- a/qa/spec/runtime/rsa_key.rb +++ b/qa/spec/runtime/key/rsa_spec.rb @@ -1,4 +1,4 @@ -describe QA::Runtime::RSAKey do +describe QA::Runtime::Key::RSA do describe '#public_key' do subject { described_class.new.public_key } From 211b2f390c3311f5880b3de6a2fb16f7865ebaae Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 9 Mar 2018 11:50:21 +0000 Subject: [PATCH 02/65] Implement other ssh keys and use ssh-keygen instead --- qa/Gemfile | 1 - qa/Gemfile.lock | 2 - qa/qa.rb | 4 ++ qa/qa/runtime/key/base.rb | 38 +++++++++++++++++++ qa/qa/runtime/key/dsa.rb | 11 ++++++ qa/qa/runtime/key/ecdsa.rb | 11 ++++++ qa/qa/runtime/key/ed25519.rb | 11 ++++++ qa/qa/runtime/key/rsa.rb | 16 +------- .../features/project/deploy_key_clone_spec.rb | 2 +- qa/spec/runtime/key/dsa_spec.rb | 9 +++++ qa/spec/runtime/key/ecdsa_spec.rb | 17 +++++++++ qa/spec/runtime/key/ed25519_spec.rb | 9 +++++ qa/spec/runtime/key/rsa_spec.rb | 2 +- 13 files changed, 114 insertions(+), 19 deletions(-) create mode 100644 qa/qa/runtime/key/base.rb create mode 100644 qa/qa/runtime/key/dsa.rb create mode 100644 qa/qa/runtime/key/ecdsa.rb create mode 100644 qa/qa/runtime/key/ed25519.rb create mode 100644 qa/spec/runtime/key/dsa_spec.rb create mode 100644 qa/spec/runtime/key/ecdsa_spec.rb create mode 100644 qa/spec/runtime/key/ed25519_spec.rb diff --git a/qa/Gemfile b/qa/Gemfile index c3e61568f3d..d69c71003ae 100644 --- a/qa/Gemfile +++ b/qa/Gemfile @@ -6,5 +6,4 @@ gem 'capybara-screenshot', '~> 1.0.18' gem 'rake', '~> 12.3.0' gem 'rspec', '~> 3.7' gem 'selenium-webdriver', '~> 3.8.0' -gem 'net-ssh', require: false gem 'airborne', '~> 0.2.13' diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index 51d2e4d7a10..565adac7499 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -46,7 +46,6 @@ GEM mini_mime (1.0.0) mini_portile2 (2.3.0) minitest (5.11.1) - net-ssh (4.1.0) netrc (0.11.0) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) @@ -98,7 +97,6 @@ DEPENDENCIES airborne (~> 0.2.13) capybara (~> 2.16.1) capybara-screenshot (~> 1.0.18) - net-ssh pry-byebug (~> 3.5.1) rake (~> 12.3.0) rspec (~> 3.7) diff --git a/qa/qa.rb b/qa/qa.rb index f2ad43cd04a..fb926dbe735 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -15,7 +15,11 @@ module QA autoload :API, 'qa/runtime/api' module Key + autoload :Base, 'qa/runtime/key/base' autoload :RSA, 'qa/runtime/key/rsa' + autoload :DSA, 'qa/runtime/key/dsa' + autoload :ECDSA, 'qa/runtime/key/ecdsa' + autoload :ED25519, 'qa/runtime/key/ed25519' end end diff --git a/qa/qa/runtime/key/base.rb b/qa/qa/runtime/key/base.rb new file mode 100644 index 00000000000..85f339033e5 --- /dev/null +++ b/qa/qa/runtime/key/base.rb @@ -0,0 +1,38 @@ +module QA + module Runtime + module Key + class Base + attr_reader :private_key, :public_key, :fingerprint + + def initialize(name, bits) + Dir.mktmpdir do |dir| + path = "#{dir}/id_#{name}" + + ssh_keygen(name, bits, path) + populate_key_data(path) + end + end + + private + + def ssh_keygen(name, bits, path) + cmd = %W[ssh-keygen -t #{name} -b #{bits} -f #{path} -N] << '' + + IO.popen([*cmd, err: %i[child out]]) do |io| + out = io.read + io.close + + raise "ssh-keygen failed with output: #{out}" unless $?.success? + end + end + + def populate_key_data(path) + @private_key = File.binread(path) + @public_key = File.binread("#{path}.pub") + @fingerprint = + `ssh-keygen -l -E md5 -f #{path} | cut -d' ' -f2 | cut -d: -f2-`.chomp + end + end + end + end +end diff --git a/qa/qa/runtime/key/dsa.rb b/qa/qa/runtime/key/dsa.rb new file mode 100644 index 00000000000..e984107b747 --- /dev/null +++ b/qa/qa/runtime/key/dsa.rb @@ -0,0 +1,11 @@ +module QA + module Runtime + module Key + class DSA < Base + def initialize + super('dsa', 1024) + end + end + end + end +end diff --git a/qa/qa/runtime/key/ecdsa.rb b/qa/qa/runtime/key/ecdsa.rb new file mode 100644 index 00000000000..71238e4352a --- /dev/null +++ b/qa/qa/runtime/key/ecdsa.rb @@ -0,0 +1,11 @@ +module QA + module Runtime + module Key + class ECDSA < Base + def initialize(bits = 521) + super('ecdsa', bits) + end + end + end + end +end diff --git a/qa/qa/runtime/key/ed25519.rb b/qa/qa/runtime/key/ed25519.rb new file mode 100644 index 00000000000..bd2f2522447 --- /dev/null +++ b/qa/qa/runtime/key/ed25519.rb @@ -0,0 +1,11 @@ +module QA + module Runtime + module Key + class ED25519 < Base + def initialize + super('ed25519', 256) + end + end + end + end +end diff --git a/qa/qa/runtime/key/rsa.rb b/qa/qa/runtime/key/rsa.rb index faa6b47b5a0..d94bde52325 100644 --- a/qa/qa/runtime/key/rsa.rb +++ b/qa/qa/runtime/key/rsa.rb @@ -1,21 +1,9 @@ -require 'net/ssh' -require 'forwardable' - module QA module Runtime module Key - class RSA - extend Forwardable - - attr_reader :key - def_delegators :@key, :fingerprint, :to_pem - + class RSA < Base def initialize(bits = 4096) - @key = OpenSSL::PKey::RSA.new(bits) - end - - def public_key - @public_key ||= "#{key.ssh_type} #{[key.to_blob].pack('m0')}" + super('rsa', bits) end end end diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 0c09f8168d9..0e240bf9029 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -35,7 +35,7 @@ module QA Factory::Resource::SecretVariable.fabricate! do |resource| resource.project = project resource.key = 'DEPLOY_KEY' - resource.value = key.to_pem + resource.value = key.private_key end project.visit! diff --git a/qa/spec/runtime/key/dsa_spec.rb b/qa/spec/runtime/key/dsa_spec.rb new file mode 100644 index 00000000000..600e7ce4ee6 --- /dev/null +++ b/qa/spec/runtime/key/dsa_spec.rb @@ -0,0 +1,9 @@ +describe QA::Runtime::Key::DSA do + describe '#public_key' do + subject { described_class.new.public_key } + + it 'generates a public DSA key' do + expect(subject).to match(%r{\Assh\-dss AAAA[0-9A-Za-z+/]+={0,3}}) + end + end +end diff --git a/qa/spec/runtime/key/ecdsa_spec.rb b/qa/spec/runtime/key/ecdsa_spec.rb new file mode 100644 index 00000000000..55a5c5e5c1b --- /dev/null +++ b/qa/spec/runtime/key/ecdsa_spec.rb @@ -0,0 +1,17 @@ +describe QA::Runtime::Key::ECDSA do + describe '#public_key' do + [256, 384, 521].each do |bits| + it "generates a public #{bits}-bits ECDSA key" do + subject = described_class.new(bits).public_key + + expect(subject).to match(%r{\Aecdsa\-sha2\-\w+ AAAA[0-9A-Za-z+/]+={0,3}}) + end + end + end + + describe '#new' do + it 'does not support arbitrary bits' do + expect { described_class.new(123) }.to raise_error(RuntimeError) + end + end +end diff --git a/qa/spec/runtime/key/ed25519_spec.rb b/qa/spec/runtime/key/ed25519_spec.rb new file mode 100644 index 00000000000..4844e7affdf --- /dev/null +++ b/qa/spec/runtime/key/ed25519_spec.rb @@ -0,0 +1,9 @@ +describe QA::Runtime::Key::ED25519 do + describe '#public_key' do + subject { described_class.new.public_key } + + it 'generates a public ED25519 key' do + expect(subject).to match(%r{\Assh\-ed25519 AAAA[0-9A-Za-z+/]}) + end + end +end diff --git a/qa/spec/runtime/key/rsa_spec.rb b/qa/spec/runtime/key/rsa_spec.rb index 0921f9a7c6b..fbcc7ffdcb4 100644 --- a/qa/spec/runtime/key/rsa_spec.rb +++ b/qa/spec/runtime/key/rsa_spec.rb @@ -3,7 +3,7 @@ describe QA::Runtime::Key::RSA do subject { described_class.new.public_key } it 'generates a public RSA key' do - expect(subject).to match(%r{\Assh\-rsa AAAA[0-9A-Za-z+/]+={0,3}\z}) + expect(subject).to match(%r{\Assh\-rsa AAAA[0-9A-Za-z+/]+={0,3}}) end end end From 1783a3d510d19d0cc906290f4ec82806319a97d1 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 9 Mar 2018 20:14:27 +0800 Subject: [PATCH 03/65] Run through all kinds of ssh keys for deploy key --- qa/qa/runtime/key/base.rb | 5 +- .../features/project/deploy_key_clone_spec.rb | 114 ++++++++++-------- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/qa/qa/runtime/key/base.rb b/qa/qa/runtime/key/base.rb index 85f339033e5..0f74d314c56 100644 --- a/qa/qa/runtime/key/base.rb +++ b/qa/qa/runtime/key/base.rb @@ -2,9 +2,12 @@ module QA module Runtime module Key class Base - attr_reader :private_key, :public_key, :fingerprint + attr_reader :name, :bits, :private_key, :public_key, :fingerprint def initialize(name, bits) + @name = name + @bits = bits + Dir.mktmpdir do |dir| path = "#{dir}/id_#{name}" diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 0e240bf9029..c5428fee0d5 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -3,7 +3,6 @@ require 'digest/sha1' module QA feature 'cloning code using a deploy key', :core, :docker do let(:runner_name) { "qa-runner-#{Time.now.to_i}" } - let(:key) { Runtime::Key::RSA.new } given(:project) do Factory::Resource::Project.fabricate! do |resource| @@ -15,66 +14,79 @@ module QA Service::Runner.new(runner_name).remove! end - scenario 'user sets up a deploy key to clone code using pipelines' do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } + keys = [ + Runtime::Key::RSA.new(2048), + Runtime::Key::RSA.new(4096), + Runtime::Key::RSA.new(8192), + Runtime::Key::DSA.new, + Runtime::Key::ECDSA.new(256), + Runtime::Key::ECDSA.new(384), + Runtime::Key::ECDSA.new(521), + Runtime::Key::ED25519.new + ] - Factory::Resource::Runner.fabricate! do |resource| - resource.project = project - resource.name = runner_name - resource.tags = %w[qa docker] - resource.image = 'gitlab/gitlab-runner:ubuntu' - end + keys.each do |key| + scenario "user sets up a deploy key with #{key.name}(#{key.bits}) to clone code using pipelines" do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } - Factory::Resource::DeployKey.fabricate! do |resource| - resource.project = project - resource.title = 'deploy key title' - resource.key = key.public_key - end + Factory::Resource::Runner.fabricate! do |resource| + resource.project = project + resource.name = runner_name + resource.tags = %w[qa docker] + resource.image = 'gitlab/gitlab-runner:ubuntu' + end - Factory::Resource::SecretVariable.fabricate! do |resource| - resource.project = project - resource.key = 'DEPLOY_KEY' - resource.value = key.private_key - end + Factory::Resource::DeployKey.fabricate! do |resource| + resource.project = project + resource.title = 'deploy key title' + resource.key = key.public_key + end - project.visit! + Factory::Resource::SecretVariable.fabricate! do |resource| + resource.project = project + resource.key = 'DEPLOY_KEY' + resource.value = key.private_key + end - repository_uri = Page::Project::Show.act do - choose_repository_clone_ssh - repository_location_uri - end + project.visit! - gitlab_ci = <<~YAML - cat-config: - script: - - mkdir -p ~/.ssh - - ssh-keyscan -p #{repository_uri.port} #{repository_uri.host} >> ~/.ssh/known_hosts - - eval $(ssh-agent -s) - - echo "$DEPLOY_KEY" | ssh-add - - - git clone #{repository_uri.git_uri} - - sha1sum #{project.name}/.gitlab-ci.yml - tags: - - qa - - docker - YAML + repository_uri = Page::Project::Show.act do + choose_repository_clone_ssh + repository_location_uri + end - Factory::Repository::Push.fabricate! do |resource| - resource.project = project - resource.file_name = '.gitlab-ci.yml' - resource.commit_message = 'Add .gitlab-ci.yml' - resource.file_content = gitlab_ci - end + gitlab_ci = <<~YAML + cat-config: + script: + - mkdir -p ~/.ssh + - ssh-keyscan -p #{repository_uri.port} #{repository_uri.host} >> ~/.ssh/known_hosts + - eval $(ssh-agent -s) + - echo "$DEPLOY_KEY" | ssh-add - + - git clone #{repository_uri.git_uri} + - sha1sum #{project.name}/.gitlab-ci.yml + tags: + - qa + - docker + YAML - sha1sum = Digest::SHA1.hexdigest(gitlab_ci) + Factory::Repository::Push.fabricate! do |resource| + resource.project = project + resource.file_name = '.gitlab-ci.yml' + resource.commit_message = 'Add .gitlab-ci.yml' + resource.file_content = gitlab_ci + end - Page::Project::Show.act { wait_for_push } - Page::Menu::Side.act { click_ci_cd_pipelines } - Page::Project::Pipeline::Index.act { go_to_latest_pipeline } - Page::Project::Pipeline::Show.act { go_to_first_job } + sha1sum = Digest::SHA1.hexdigest(gitlab_ci) - Page::Project::Job::Show.perform do |job| - expect(job.output).to include(sha1sum) + Page::Project::Show.act { wait_for_push } + Page::Menu::Side.act { click_ci_cd_pipelines } + Page::Project::Pipeline::Index.act { go_to_latest_pipeline } + Page::Project::Pipeline::Show.act { go_to_first_job } + + Page::Project::Job::Show.perform do |job| + expect(job.output).to include(sha1sum) + end end end end From 94aa0b16f91e1ef239d3711f018313f3edbfc800 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 12 Mar 2018 23:34:48 +0800 Subject: [PATCH 04/65] Update qa/Dockerfile for openssh-client jessie doesn't support `ssh-keygen -l -E` but stretch does: https://manpages.debian.org/jessie/openssh-client/ssh-keygen.1.en.html --- qa/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/Dockerfile b/qa/Dockerfile index ed2ee73bea0..77cee9c5461 100644 --- a/qa/Dockerfile +++ b/qa/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.4 +FROM ruby:2.4-stretch LABEL maintainer "Grzegorz Bizon " ENV DEBIAN_FRONTEND noninteractive From b1625d39f5b6e37ccccd0c996dd2db2f7f37730d Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 14 Mar 2018 21:06:02 +0800 Subject: [PATCH 05/65] Make sure the job is not still running --- qa/qa/specs/features/project/deploy_key_clone_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index c5428fee0d5..3465fe109ee 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -82,7 +82,14 @@ module QA Page::Project::Show.act { wait_for_push } Page::Menu::Side.act { click_ci_cd_pipelines } Page::Project::Pipeline::Index.act { go_to_latest_pipeline } - Page::Project::Pipeline::Show.act { go_to_first_job } + + Page::Project::Pipeline::Show.act do + go_to_first_job + + wait do + !has_content?('running') + end + end Page::Project::Job::Show.perform do |job| expect(job.output).to include(sha1sum) From 187711c1b020514fd3c05360b4809f10369ef755 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Sat, 17 Mar 2018 01:30:55 +0800 Subject: [PATCH 06/65] Remove test against DSA ssh keys because we're not really supporting them out of the box. See: https://gitlab.com/gitlab-org/gitlab-ce/issues/44363 --- qa/qa.rb | 1 - qa/qa/runtime/key/dsa.rb | 11 ----------- qa/qa/specs/features/project/deploy_key_clone_spec.rb | 1 - qa/spec/runtime/key/dsa_spec.rb | 9 --------- 4 files changed, 22 deletions(-) delete mode 100644 qa/qa/runtime/key/dsa.rb delete mode 100644 qa/spec/runtime/key/dsa_spec.rb diff --git a/qa/qa.rb b/qa/qa.rb index fb926dbe735..5fb9364a6ab 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -17,7 +17,6 @@ module QA module Key autoload :Base, 'qa/runtime/key/base' autoload :RSA, 'qa/runtime/key/rsa' - autoload :DSA, 'qa/runtime/key/dsa' autoload :ECDSA, 'qa/runtime/key/ecdsa' autoload :ED25519, 'qa/runtime/key/ed25519' end diff --git a/qa/qa/runtime/key/dsa.rb b/qa/qa/runtime/key/dsa.rb deleted file mode 100644 index e984107b747..00000000000 --- a/qa/qa/runtime/key/dsa.rb +++ /dev/null @@ -1,11 +0,0 @@ -module QA - module Runtime - module Key - class DSA < Base - def initialize - super('dsa', 1024) - end - end - end - end -end diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 3465fe109ee..424a8e18257 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -18,7 +18,6 @@ module QA Runtime::Key::RSA.new(2048), Runtime::Key::RSA.new(4096), Runtime::Key::RSA.new(8192), - Runtime::Key::DSA.new, Runtime::Key::ECDSA.new(256), Runtime::Key::ECDSA.new(384), Runtime::Key::ECDSA.new(521), diff --git a/qa/spec/runtime/key/dsa_spec.rb b/qa/spec/runtime/key/dsa_spec.rb deleted file mode 100644 index 600e7ce4ee6..00000000000 --- a/qa/spec/runtime/key/dsa_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -describe QA::Runtime::Key::DSA do - describe '#public_key' do - subject { described_class.new.public_key } - - it 'generates a public DSA key' do - expect(subject).to match(%r{\Assh\-dss AAAA[0-9A-Za-z+/]+={0,3}}) - end - end -end From ae0c7af2f8bf023f69c384ca6cba4a3a101613ad Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 28 Mar 2018 19:47:20 +0800 Subject: [PATCH 07/65] Only test some of the keys for now We could speed it up and test more keys later --- qa/qa/specs/features/project/deploy_key_clone_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 424a8e18257..cbb383f9291 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -15,11 +15,7 @@ module QA end keys = [ - Runtime::Key::RSA.new(2048), - Runtime::Key::RSA.new(4096), Runtime::Key::RSA.new(8192), - Runtime::Key::ECDSA.new(256), - Runtime::Key::ECDSA.new(384), Runtime::Key::ECDSA.new(521), Runtime::Key::ED25519.new ] From 4e712f766fb893705816fe199b1225460dd451b2 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 28 Mar 2018 19:47:49 +0800 Subject: [PATCH 08/65] Introduce repository_ssh_uri as a project product --- qa/qa/factory/resource/project.rb | 7 +++++++ qa/qa/specs/features/project/deploy_key_clone_spec.rb | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qa/qa/factory/resource/project.rb b/qa/qa/factory/resource/project.rb index 7df2dc6618c..857d8c98626 100644 --- a/qa/qa/factory/resource/project.rb +++ b/qa/qa/factory/resource/project.rb @@ -17,6 +17,13 @@ module QA Page::Project::Show.act { project_name } end + product :repository_ssh_uri do + Page::Project::Show.act do + choose_repository_clone_ssh + repository_location_uri + end + end + def fabricate! group.visit! diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index cbb383f9291..706a39a5331 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -46,10 +46,7 @@ module QA project.visit! - repository_uri = Page::Project::Show.act do - choose_repository_clone_ssh - repository_location_uri - end + repository_uri = project.repository_ssh_uri gitlab_ci = <<~YAML cat-config: From 9d9ee76197818486d3cd5a178af4b28ba8b4fc31 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 28 Mar 2018 19:48:09 +0800 Subject: [PATCH 09/65] Use Service::Shellout.shell to spawn a command --- qa/qa/runtime/key/base.rb | 7 +------ qa/qa/service/shellout.rb | 4 +++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/qa/qa/runtime/key/base.rb b/qa/qa/runtime/key/base.rb index 0f74d314c56..c7e5ebada7b 100644 --- a/qa/qa/runtime/key/base.rb +++ b/qa/qa/runtime/key/base.rb @@ -21,12 +21,7 @@ module QA def ssh_keygen(name, bits, path) cmd = %W[ssh-keygen -t #{name} -b #{bits} -f #{path} -N] << '' - IO.popen([*cmd, err: %i[child out]]) do |io| - out = io.read - io.close - - raise "ssh-keygen failed with output: #{out}" unless $?.success? - end + Service::Shellout.shell(cmd) end def populate_key_data(path) diff --git a/qa/qa/service/shellout.rb b/qa/qa/service/shellout.rb index 76fb2af6319..1ca9504bb33 100644 --- a/qa/qa/service/shellout.rb +++ b/qa/qa/service/shellout.rb @@ -5,6 +5,8 @@ module QA module Shellout CommandError = Class.new(StandardError) + module_function + ## # TODO, make it possible to use generic QA framework classes # as a library - gitlab-org/gitlab-qa#94 @@ -12,7 +14,7 @@ module QA def shell(command) puts "Executing `#{command}`" - Open3.popen2e(command) do |_in, out, wait| + Open3.popen2e(*command) do |_in, out, wait| out.each { |line| puts line } if wait.value.exited? && wait.value.exitstatus.nonzero? From 437f59c2fe326552f27fc13289cb2b727f173baa Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 28 Mar 2018 21:59:36 +0800 Subject: [PATCH 10/65] Put project and runner in before(:all) --- .../features/project/deploy_key_clone_spec.rb | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 706a39a5331..ba1c0375549 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -2,16 +2,32 @@ require 'digest/sha1' module QA feature 'cloning code using a deploy key', :core, :docker do - let(:runner_name) { "qa-runner-#{Time.now.to_i}" } + def login + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + end - given(:project) do - Factory::Resource::Project.fabricate! do |resource| + before(:all) do + login + + @runner_name = "qa-runner-#{Time.now.to_i}" + + @project = Factory::Resource::Project.fabricate! do |resource| resource.name = 'deploy-key-clone-project' end + + @repository_uri = @project.repository_ssh_uri + + Factory::Resource::Runner.fabricate! do |resource| + resource.project = @project + resource.name = @runner_name + resource.tags = %w[qa docker] + resource.image = 'gitlab/gitlab-runner:ubuntu' + end end - after do - Service::Runner.new(runner_name).remove! + after(:all) do + Service::Runner.new(@runner_name).remove! end keys = [ @@ -22,51 +38,42 @@ module QA keys.each do |key| scenario "user sets up a deploy key with #{key.name}(#{key.bits}) to clone code using pipelines" do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } - - Factory::Resource::Runner.fabricate! do |resource| - resource.project = project - resource.name = runner_name - resource.tags = %w[qa docker] - resource.image = 'gitlab/gitlab-runner:ubuntu' - end + login Factory::Resource::DeployKey.fabricate! do |resource| - resource.project = project - resource.title = 'deploy key title' + resource.project = @project + resource.title = "deploy key #{key.name}(#{key.bits})" resource.key = key.public_key end + deploy_key_name = "DEPLOY_KEY_#{key.name}_#{key.bits}" + Factory::Resource::SecretVariable.fabricate! do |resource| - resource.project = project - resource.key = 'DEPLOY_KEY' + resource.project = @project + resource.key = deploy_key_name resource.value = key.private_key end - project.visit! - - repository_uri = project.repository_ssh_uri - gitlab_ci = <<~YAML cat-config: script: - mkdir -p ~/.ssh - - ssh-keyscan -p #{repository_uri.port} #{repository_uri.host} >> ~/.ssh/known_hosts + - ssh-keyscan -p #{@repository_uri.port} #{@repository_uri.host} >> ~/.ssh/known_hosts - eval $(ssh-agent -s) - - echo "$DEPLOY_KEY" | ssh-add - - - git clone #{repository_uri.git_uri} - - sha1sum #{project.name}/.gitlab-ci.yml + - echo "$#{deploy_key_name}" | ssh-add - + - git clone #{@repository_uri.git_uri} + - sha1sum #{@project.name}/.gitlab-ci.yml tags: - qa - docker YAML Factory::Repository::Push.fabricate! do |resource| - resource.project = project + resource.project = @project resource.file_name = '.gitlab-ci.yml' resource.commit_message = 'Add .gitlab-ci.yml' resource.file_content = gitlab_ci + resource.branch_name = deploy_key_name end sha1sum = Digest::SHA1.hexdigest(gitlab_ci) From 483fe24b74db092c099cfd7243934230498e3984 Mon Sep 17 00:00:00 2001 From: Fabio Busatto Date: Fri, 30 Mar 2018 14:45:57 +0000 Subject: [PATCH 11/65] Add better explanation for CI_PIPELINE_SOURCE --- doc/ci/variables/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md index bd4aeb006bd..7beec2bfa3d 100644 --- a/doc/ci/variables/README.md +++ b/doc/ci/variables/README.md @@ -61,7 +61,7 @@ future GitLab releases.** | **CI_RUNNER_EXECUTABLE_ARCH** | all | 10.6 | The OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor) | | **CI_PIPELINE_ID** | 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally | | **CI_PIPELINE_TRIGGERED** | all | all | The flag to indicate that job was [triggered] | -| **CI_PIPELINE_SOURCE** | 10.0 | all | The source for this pipeline, one of: push, web, trigger, schedule, api, external. Pipelines created before 9.5 will have unknown as source | +| **CI_PIPELINE_SOURCE** | 10.0 | all | Indicates how the pipeline was triggered. Possible options are: `push`, `web`, `trigger`, `schedule`, `api`, and `pipeline`. For pipelines created before GitLab 9.5, this will show as `unknown` | | **CI_PROJECT_DIR** | all | all | The full path where the repository is cloned and where the job is run | | **CI_PROJECT_ID** | all | all | The unique id of the current project that GitLab CI uses internally | | **CI_PROJECT_NAME** | 8.10 | 0.5 | The project name that is currently being built (actually it is project folder name) | From 353c5782b47211f9a7e2439189b23dde8678960a Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 3 Apr 2018 22:47:46 +0800 Subject: [PATCH 12/65] Checkout to a new branch --- qa/qa/factory/repository/push.rb | 7 ++++++- qa/qa/git/repository.rb | 4 ++++ qa/qa/specs/features/project/deploy_key_clone_spec.rb | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/qa/qa/factory/repository/push.rb b/qa/qa/factory/repository/push.rb index 6e8905cde78..bd4dee4c7be 100644 --- a/qa/qa/factory/repository/push.rb +++ b/qa/qa/factory/repository/push.rb @@ -30,7 +30,12 @@ module QA repository.clone repository.configure_identity('GitLab QA', 'root@gitlab.com') - repository.checkout(@branch_name) unless @new_branch + if @new_branch + repository.checkout_new_branch(@branch_name) + else + repository.checkout(@branch_name) + end + repository.add_file(@file_name, @file_content) repository.commit(@commit_message) repository.push_changes(@branch_name) diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index b3150e8f3fa..4ffe25304a1 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -40,6 +40,10 @@ module QA `git checkout "#{branch_name}"` end + def checkout_new_branch(branch_name) + `git checkout -b "#{branch_name}"` + end + def shallow_clone clone('--depth 1') end diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index ba1c0375549..f193c77288d 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -74,6 +74,7 @@ module QA resource.commit_message = 'Add .gitlab-ci.yml' resource.file_content = gitlab_ci resource.branch_name = deploy_key_name + resource.new_branch = true end sha1sum = Digest::SHA1.hexdigest(gitlab_ci) From f9eab32879507cdcb5d43d7874d4ddc4982e51c2 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 3 Apr 2018 22:48:19 +0800 Subject: [PATCH 13/65] Populate the fingerprint by known title Without this, if we have more than one deploy key, it would be ambiguous. --- qa/qa/factory/resource/deploy_key.rb | 14 +++++++------- qa/qa/page/base.rb | 4 ++++ qa/qa/page/project/settings/deploy_keys.rb | 12 ++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/qa/qa/factory/resource/deploy_key.rb b/qa/qa/factory/resource/deploy_key.rb index ff0b4a46b77..ea8a3ad687d 100644 --- a/qa/qa/factory/resource/deploy_key.rb +++ b/qa/qa/factory/resource/deploy_key.rb @@ -4,15 +4,15 @@ module QA class DeployKey < Factory::Base attr_accessor :title, :key - product :title do + product :fingerprint do |resource| Page::Project::Settings::Repository.act do - expand_deploy_keys(&:key_title) - end - end + expand_deploy_keys do |key| + key_offset = key.key_titles.index do |title| + title.text == resource.title + end - product :fingerprint do - Page::Project::Settings::Repository.act do - expand_deploy_keys(&:key_fingerprint) + key.key_fingerprints[key_offset].text + end end end diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index a313d46205d..6fc8004b051 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -64,6 +64,10 @@ module QA find(element_selector_css(name)) end + def all_element(name) + all(element_selector_css(name)) + end + def click_element(name) find_element(name).click end diff --git a/qa/qa/page/project/settings/deploy_keys.rb b/qa/qa/page/project/settings/deploy_keys.rb index 332e84724c7..3de064b376a 100644 --- a/qa/qa/page/project/settings/deploy_keys.rb +++ b/qa/qa/page/project/settings/deploy_keys.rb @@ -42,6 +42,18 @@ module QA end end + def key_titles + within_project_deploy_keys do + all_element(:key_title) + end + end + + def key_fingerprints + within_project_deploy_keys do + all_element(:key_fingerprint) + end + end + private def within_project_deploy_keys From 61b4c157444ea0b9e60f44959630db42e21067ad Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 3 Apr 2018 22:49:08 +0800 Subject: [PATCH 14/65] Sign out so we could sign in; Clean up previous keys --- qa/qa/specs/features/project/deploy_key_clone_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index f193c77288d..1fb3e85a338 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -24,6 +24,8 @@ module QA resource.tags = %w[qa docker] resource.image = 'gitlab/gitlab-runner:ubuntu' end + + Page::Menu::Main.act { sign_out } end after(:all) do @@ -60,6 +62,7 @@ module QA - mkdir -p ~/.ssh - ssh-keyscan -p #{@repository_uri.port} #{@repository_uri.host} >> ~/.ssh/known_hosts - eval $(ssh-agent -s) + - ssh-add -D - echo "$#{deploy_key_name}" | ssh-add - - git clone #{@repository_uri.git_uri} - sha1sum #{@project.name}/.gitlab-ci.yml From f2c684960ce52e7ad05ccd836e10cb2f4ccdf74d Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Tue, 10 Apr 2018 14:18:58 +0200 Subject: [PATCH 15/65] Explain Auto DevOps better https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5290 --- doc/topics/autodevops/index.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/topics/autodevops/index.md b/doc/topics/autodevops/index.md index e88b787187c..c36609d3a86 100644 --- a/doc/topics/autodevops/index.md +++ b/doc/topics/autodevops/index.md @@ -10,8 +10,30 @@ applications. ## Overview With Auto DevOps, the software development process becomes easier to set up -as every project can have a complete workflow from build to deploy and monitoring, -with minimal to zero configuration. +as every project can have a complete workflow from verification to monitoring +without needing to configure anything. Just push your code and GitLab takes +care of everything else. This makes it easier to start new projects and brings +consistency to how applications are set up throughout a company. + +## Comparison to application platforms and PaaS + +Auto DevOps provides functionality described by others as an application +platform or as a Platform as a Service (PaaS). It takes inspiration from the +innovative work done by [Heroku](https://www.heroku.com/) and goes beyond it +in a couple of ways: + +1. Auto DevOps works with any Kubernetes cluster, you're not limited to running + on GitLab's infrastructure (note that many features also work without Kubernetes). +1. There is no additional cost (no markup on the infrastructure costs), and you + can use a self-hosted Kubernetes cluster or Containers as a Service on any + public cloud (for example [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine/)). +1. Auto DevOps has more features including security testing, performance testing, + and code quality testing. +1. It offers an incremental graduation path. If you need advanced customizations + you can start modifying the templates without having to start over on a + completely different platform. + +## Features Comprised of a set of stages, Auto DevOps brings these best practices to your project in an easy and automatic way: From fca03376bd42b503badf3ae6cc8b79eed132c099 Mon Sep 17 00:00:00 2001 From: Xiaogang Wen Date: Thu, 12 Apr 2018 00:52:27 +0000 Subject: [PATCH 16/65] Update github.md on GHE URL --- doc/integration/github.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/integration/github.md b/doc/integration/github.md index b0d67db8b59..1af295b3742 100644 --- a/doc/integration/github.md +++ b/doc/integration/github.md @@ -69,7 +69,7 @@ GitHub will generate an application ID and secret key for you to use. "name" => "github", "app_id" => "YOUR_APP_ID", "app_secret" => "YOUR_APP_SECRET", - "url" => "https://github.com/", + "url" => "https://github.example.com/", "args" => { "scope" => "user:email" } } ] From f900204ade9fcd4b891f1605ff482141822a816c Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Thu, 12 Apr 2018 10:32:14 +0200 Subject: [PATCH 17/65] Correct another one github.example.com [ci skip] --- doc/integration/github.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/integration/github.md b/doc/integration/github.md index 1af295b3742..23bb8ef9303 100644 --- a/doc/integration/github.md +++ b/doc/integration/github.md @@ -125,7 +125,7 @@ For omnibus package: "name" => "github", "app_id" => "YOUR_APP_ID", "app_secret" => "YOUR_APP_SECRET", - "url" => "https://github.com/", + "url" => "https://github.example.com/", "verify_ssl" => false, "args" => { "scope" => "user:email" } } From ffdb47a2463f0ab42bc02a586df062c1fe73d796 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Mon, 16 Apr 2018 21:59:04 +0300 Subject: [PATCH 18/65] Restore label underline color --- app/assets/stylesheets/pages/labels.scss | 4 ++++ changelogs/unreleased/restore-label-underline-color.yml | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 changelogs/unreleased/restore-label-underline-color.yml diff --git a/app/assets/stylesheets/pages/labels.scss b/app/assets/stylesheets/pages/labels.scss index b0852adb459..d81236c5883 100644 --- a/app/assets/stylesheets/pages/labels.scss +++ b/app/assets/stylesheets/pages/labels.scss @@ -314,6 +314,10 @@ display: inline-flex; vertical-align: top; + &:hover .color-label { + text-decoration: underline; + } + .label { vertical-align: inherit; font-size: $label-font-size; diff --git a/changelogs/unreleased/restore-label-underline-color.yml b/changelogs/unreleased/restore-label-underline-color.yml new file mode 100644 index 00000000000..2e24ece5c36 --- /dev/null +++ b/changelogs/unreleased/restore-label-underline-color.yml @@ -0,0 +1,5 @@ +--- +title: Restore label underline color +merge_request: 18407 +author: George Tsiolis +type: fixed From 4c86b4e2dc5a646de4f2ff6f05e17bac2a1e9124 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 17 Apr 2018 22:18:14 +0800 Subject: [PATCH 19/65] Properly fill variable pair to the last fields --- qa/qa/factory/resource/secret_variable.rb | 3 +-- qa/qa/page/project/settings/secret_variables.rb | 11 +++++------ qa/qa/specs/features/project/deploy_key_clone_spec.rb | 4 +++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/qa/qa/factory/resource/secret_variable.rb b/qa/qa/factory/resource/secret_variable.rb index c734d739b4a..12a830da116 100644 --- a/qa/qa/factory/resource/secret_variable.rb +++ b/qa/qa/factory/resource/secret_variable.rb @@ -16,8 +16,7 @@ module QA Page::Project::Settings::CICD.perform do |setting| setting.expand_secret_variables do |page| - page.fill_variable_key(key) - page.fill_variable_value(value) + page.fill_variable(key, value) page.save_variables end diff --git a/qa/qa/page/project/settings/secret_variables.rb b/qa/qa/page/project/settings/secret_variables.rb index c95c79f137d..89f1424a5fa 100644 --- a/qa/qa/page/project/settings/secret_variables.rb +++ b/qa/qa/page/project/settings/secret_variables.rb @@ -18,12 +18,11 @@ module QA element :reveal_values, '.js-secret-value-reveal-button' end - def fill_variable_key(key) - fill_in('Input variable key', with: key, match: :first) - end - - def fill_variable_value(value) - fill_in('Input variable value', with: value, match: :first) + def fill_variable(key, value) + all('.js-ci-variable-input-key')[-1].set(key) + # After we fill the key, JS would generate another field so + # we need to fill the one before last one instead of last one + all('.js-ci-variable-input-value')[-2].set(value) end def save_variables diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 1fb3e85a338..42588d1181d 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -65,7 +65,9 @@ module QA - ssh-add -D - echo "$#{deploy_key_name}" | ssh-add - - git clone #{@repository_uri.git_uri} - - sha1sum #{@project.name}/.gitlab-ci.yml + - cd #{@project.name} + - git checkout #{deploy_key_name} + - sha1sum .gitlab-ci.yml tags: - qa - docker From 2517a3647d6d167b9841ff168f8ca6b9037d2392 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 18 Apr 2018 00:54:49 +0800 Subject: [PATCH 20/65] We no longer populate the title, so don't test it --- qa/qa/specs/features/project/add_deploy_key_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/qa/qa/specs/features/project/add_deploy_key_spec.rb b/qa/qa/specs/features/project/add_deploy_key_spec.rb index 79e5ebe3633..de53613dee1 100644 --- a/qa/qa/specs/features/project/add_deploy_key_spec.rb +++ b/qa/qa/specs/features/project/add_deploy_key_spec.rb @@ -13,7 +13,6 @@ module QA resource.key = deploy_key_value end - expect(deploy_key.title).to eq(deploy_key_title) expect(deploy_key.fingerprint).to eq(key.fingerprint) end end From 597acb96ee986159109feb03a9ac51826916c072 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Tue, 17 Apr 2018 22:29:19 -0400 Subject: [PATCH 21/65] Link back to root Helm chart page for deprecated GitLab chart --- doc/install/kubernetes/gitlab_chart.md | 487 +------------------------ doc/install/kubernetes/index.md | 1 - 2 files changed, 1 insertion(+), 487 deletions(-) diff --git a/doc/install/kubernetes/gitlab_chart.md b/doc/install/kubernetes/gitlab_chart.md index 84eeacac3fd..7474cee3af6 100644 --- a/doc/install/kubernetes/gitlab_chart.md +++ b/doc/install/kubernetes/gitlab_chart.md @@ -1,488 +1,3 @@ # GitLab Helm Chart -> **Note:** -* This chart has been tested on Google Kubernetes Engine and Azure Container Service. -**This chart is deprecated.** For small installations on Kubernetes today, we recommend the beta [`gitlab-omnibus` Helm chart](gitlab_omnibus.md). - -A new [cloud native GitLab chart](index.md#cloud-native-gitlab-chart) is in development with increased scalability and resilience, among other benefits. The cloud native chart will replace both the `gitlab` and `gitlab-omnibus` charts when available later this year. - -Due to the significant architectural changes, migrating will require backing up data out of this instance and restoring it into the new deployment. For more information on available GitLab Helm Charts, please see our [overview](index.md#chart-overview). - -## Introduction - -The `gitlab` Helm chart deploys just GitLab into your Kubernetes cluster, and offers extensive configuration options. This chart requires advanced knowledge of Kubernetes to successfully use. We **strongly recommend** the [gitlab-omnibus](gitlab_omnibus.md) chart. - -This chart includes the following: - -- Deployment using the [gitlab-ce](https://hub.docker.com/r/gitlab/gitlab-ce) or [gitlab-ee](https://hub.docker.com/r/gitlab/gitlab-ee) container image -- ConfigMap containing the `gitlab.rb` contents that configure [Omnibus GitLab](https://docs.gitlab.com/omnibus/settings/configuration.html#configuration-options) -- Persistent Volume Claims for Data, Config, Logs, and Registry Storage -- A Kubernetes service -- Optional Redis deployment using the [Redis Chart](https://github.com/kubernetes/charts/tree/master/stable/redis) (defaults to enabled) -- Optional PostgreSQL deployment using the [PostgreSQL Chart](https://github.com/kubernetes/charts/tree/master/stable/postgresql) (defaults to enabled) -- Optional Ingress (defaults to disabled) - -## Prerequisites - -- _At least_ 3 GB of RAM available on your cluster. 41GB of storage and 2 CPU are also required. -- Kubernetes 1.4+ with Beta APIs enabled -- [Persistent Volume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) provisioner support in the underlying infrastructure -- The ability to point a DNS entry or URL at your GitLab install -- The `kubectl` CLI installed locally and authenticated for the cluster -- The [Helm client](https://github.com/kubernetes/helm/blob/master/docs/quickstart.md) installed locally on your machine - -## Configuring GitLab - -Create a `values.yaml` file for your GitLab configuration. See the -[Helm docs](https://github.com/kubernetes/helm/blob/master/docs/chart_template_guide/values_files.md) -for information on how your values file will override the defaults. - -The default configuration can always be [found in the `values.yaml`](https://gitlab.com/charts/charts.gitlab.io/blob/master/charts/gitlab/values.yaml), in the chart repository. - -### Required configuration - -In order for GitLab to function, your config file **must** specify the following: - -- An `externalUrl` that GitLab will be reachable at. - -### Choosing GitLab Edition - -The Helm chart defaults to installing GitLab CE. This can be controlled by setting the `edition` variable in your values. - -Setting `edition` to GitLab Enterprise Edition (EE) in your `values.yaml` - -```yaml -edition: EE - -externalUrl: 'http://gitlab.example.com' -``` - -### Choosing a different GitLab release version - -The version of GitLab installed is based on the `edition` setting (see [section](#choosing-gitlab-edition) above), and -the value of the corresponding helm setting: `ceImage` or `eeImage`. - -```yaml -## GitLab Edition -## ref: https://about.gitlab.com/products/ -## - CE - Community Edition -## - EE - Enterprise Edition - (requires license issued by GitLab Inc) -## -edition: CE - -## GitLab CE image -## ref: https://hub.docker.com/r/gitlab/gitlab-ce/tags/ -## -ceImage: gitlab/gitlab-ce:9.1.2-ce.0 - -## GitLab EE image -## ref: https://hub.docker.com/r/gitlab/gitlab-ee/tags/ -## -eeImage: gitlab/gitlab-ee:9.1.2-ee.0 -``` - -The different images can be found in the [gitlab-ce](https://hub.docker.com/r/gitlab/gitlab-ce/tags/) and [gitlab-ee](https://hub.docker.com/r/gitlab/gitlab-ee/tags/) -repositories on Docker Hub - -> **Note:** -There is no guarantee that other release versions of GitLab, other than what are -used by default in the chart, will be supported by a chart install. - - -### Custom Omnibus GitLab configuration - -In addition to the configuration options provided for GitLab in the Helm Chart, you can also pass any custom configuration -that is valid for the [Omnibus GitLab Configuration](https://docs.gitlab.com/omnibus/settings/configuration.html). - -The setting to pass these values in is `omnibusConfigRuby`. It accepts any valid -Ruby code that could used in the Omnibus `/etc/gitlab/gitlab.rb` file. In -Kubernetes, the contents will be stored in a ConfigMap. - -Example setting: - -```yaml -omnibusConfigRuby: | - unicorn['worker_processes'] = 2; - gitlab_rails['trusted_proxies'] = ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"]; -``` - -### Persistent storage - -By default, persistent storage is enabled for GitLab and the charts it depends -on (Redis and PostgreSQL). - -Components can have their claim size set from your `values.yaml`, and each -component allows you to optionally configure the `storageClass` variable so you -can take advantage of faster drives on your cloud provider. - -Basic configuration: - -```yaml -## Enable persistence using Persistent Volume Claims -## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ -## ref: https://docs.gitlab.com/ce/install/requirements.html#storage -## -persistence: - ## This volume persists generated configuration files, keys, and certs. - ## - gitlabEtc: - enabled: true - size: 1Gi - ## If defined, volume.beta.kubernetes.io/storage-class: - ## Default: volume.alpha.kubernetes.io/storage-class: default - ## - # storageClass: - accessMode: ReadWriteOnce - ## This volume is used to store git data and other project files. - ## ref: https://docs.gitlab.com/omnibus/settings/configuration.html#storing-git-data-in-an-alternative-directory - ## - gitlabData: - enabled: true - size: 10Gi - ## If defined, volume.beta.kubernetes.io/storage-class: - ## Default: volume.alpha.kubernetes.io/storage-class: default - ## - # storageClass: - accessMode: ReadWriteOnce - gitlabRegistry: - enabled: true - size: 10Gi - ## If defined, volume.beta.kubernetes.io/storage-class: - ## Default: volume.alpha.kubernetes.io/storage-class: default - ## - # storageClass: - - postgresql: - persistence: - # storageClass: - size: 10Gi - ## Configuration values for the Redis dependency. - ## ref: https://github.com/kubernetes/charts/blob/master/stable/redis/README.md - ## - redis: - persistence: - # storageClass: - size: 10Gi -``` - ->**Note:** -You can make use of faster SSD drives by adding a [StorageClass] to your cluster -and using the `storageClass` setting in the above config to the name of -your new storage class. - -### Routing - -By default, the GitLab chart uses a service type of `LoadBalancer` which will -result in the GitLab service being exposed externally using your cloud provider's -load balancer. - -This field is configurable in your `values.yml` by setting the top-level -`serviceType` field. See the [Service documentation][kube-srv] for more -information on the possible values. - -#### Ingress routing - -Optionally, you can enable the Chart's ingress for use by an ingress controller -deployed in your cluster. - -To enable the ingress, edit its section in your `values.yaml`: - -```yaml -ingress: - ## If true, gitlab Ingress will be created - ## - enabled: true - - ## gitlab Ingress hostnames - ## Must be provided if Ingress is enabled - ## - hosts: - - gitlab.example.com - - ## gitlab Ingress annotations - ## - annotations: - kubernetes.io/ingress.class: nginx -``` - -You must also provide the list of hosts that the ingress will use. In order for -you ingress controller to work with the GitLab Ingress, you will need to specify -its class in an annotation. - ->**Note:** -The Ingress alone doesn't expose GitLab externally. You need to have a Ingress controller setup to do that. -Setting up an Ingress controller can be done by installing the `nginx-ingress` helm chart. But be sure -to read the [documentation](https://github.com/kubernetes/charts/blob/master/stable/nginx-ingress/README.md). ->**Note:** -If you would like to use the Registry, you will also need to ensure your Ingress supports a [sufficiently large request size](http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size). - -#### Preserving Source IPs - -If you are using the `LoadBalancer` serviceType you may run into issues where user IP addresses in the GitLab -logs, and used in abuse throttling are not accurate. This is due to how Kubernetes uses source NATing on cluster nodes without endpoints. - -See the [Kubernetes documentation](https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-typeloadbalancer) for more information. - -To fix this you can add the following service annotation to your `values.yaml` - -```yaml -## For minikube, set this to NodePort, elsewhere use LoadBalancer -## ref: http://kubernetes.io/docs/user-guide/services/#publishing-services---service-types -## -serviceType: LoadBalancer - -## Optional annotations for gitlab service. -serviceAnnotations: - service.beta.kubernetes.io/external-traffic: "OnlyLocal" -``` - ->**Note:** -If you are using the ingress routing, you will likely also need to specify the annotation on the service for the ingress -controller. For `nginx-ingress` you can check the -[configuration documentation](https://github.com/kubernetes/charts/blob/master/stable/nginx-ingress/README.md#configuration) -on how to add the annotation to the `controller.service.annotations` array. - ->**Note:** -When using the `nginx-ingress` controller on Google Kubernetes Engine (GKE), and using the `external-traffic` annotation, -you will need to additionally set the `controller.kind` to be DaemonSet. Otherwise only pods running on the same node -as the nginx controller will be able to reach GitLab. This may result in pods within your cluster not being able to reach GitLab. -See the [Kubernetes documentation](https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-typeloadbalancer) and -[nginx-ingress configuration documentation](https://github.com/kubernetes/charts/blob/master/stable/nginx-ingress/README.md#configuration) -for more information. - -### External database - -You can configure the GitLab Helm chart to connect to an external PostgreSQL -database. - ->**Note:** -This is currently our recommended approach for a Production setup. - -To use an external database, in your `values.yaml`, disable the included -PostgreSQL dependency, then configure access to your database: - -```yaml -dbHost: "" -dbPassword: "" -dbUsername: "" -dbDatabase: "" - -postgresql: - # Sets whether the PostgreSQL helm chart is used as a dependency - enabled: false -``` - -Be sure to check the GitLab documentation on how to -[configure the external database](../requirements.md#postgresql-requirements) - -You can also configure the chart to use an external Redis server, but this is -not required for basic production use: - -```yaml -dbHost: "" -dbPassword: "" - -redis: - # Sets whether the Redis helm chart is used as a dependency - enabled: false -``` - -### Sending email - -By default, the GitLab container will not be able to send email from your cluster. -In order to send email, you should configure SMTP settings in the -`omnibusConfigRuby` section, as per the [GitLab Omnibus documentation](https://docs.gitlab.com/omnibus/settings/smtp.html). - ->**Note:** -Some cloud providers restrict emails being sent out on SMTP, so you will have -to use a SMTP service that is supported by your provider. See this -[Google Cloud Platform page](https://cloud.google.com/compute/docs/tutorials/sending-mail/) -as and example. - -Here is an example configuration for Mailgun SMTP support: - -```yaml -omnibusConfigRuby: | - # This is example config of what you may already have in your omnibusConfigRuby object - unicorn['worker_processes'] = 2; - gitlab_rails['trusted_proxies'] = ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"]; - - # SMTP settings - gitlab_rails['smtp_enable'] = true - gitlab_rails['smtp_address'] = "smtp.mailgun.org" - gitlab_rails['smtp_port'] = 2525 # High port needed for Google Cloud - gitlab_rails['smtp_authentication'] = "plain" - gitlab_rails['smtp_enable_starttls_auto'] = false - gitlab_rails['smtp_user_name'] = "postmaster@mg.your-mail-domain" - gitlab_rails['smtp_password'] = "you-password" - gitlab_rails['smtp_domain'] = "mg.your-mail-domain" -``` - -### HTTPS configuration - -To setup HTTPS access to your GitLab server, first you need to configure the -chart to use the [ingress](#ingress-routing). - -GitLab's config should be updated to support [proxied SSL](https://docs.gitlab.com/omnibus/settings/nginx.html#supporting-proxied-ssl). - -In addition to having a Ingress Controller deployed and the basic ingress -settings configured, you will also need to specify in the ingress settings -which hosts to use HTTPS for. - -Make sure `externalUrl` now includes `https://` instead of `http://` in its -value, and update the `omnibusConfigRuby` section: - -```yaml -externalUrl: 'https://gitlab.example.com' - -omnibusConfigRuby: | - # This is example config of what you may already have in your omnibusConfigRuby object - unicorn['worker_processes'] = 2; - gitlab_rails['trusted_proxies'] = ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"]; - - # These are the settings needed to support proxied SSL - nginx['listen_port'] = 80 - nginx['listen_https'] = false - nginx['proxy_set_headers'] = { - "X-Forwarded-Proto" => "https", - "X-Forwarded-Ssl" => "on" - } - -ingress: - enabled: true - annotations: - kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: 'true' Annotation used for letsencrypt support - - hosts: - - gitlab.example.com - - ## gitlab Ingress TLS configuration - ## Secrets must be created in the namespace, and is not done for you in this chart - ## - tls: - - secretName: gitlab-tls - hosts: - - gitlab.example.com -``` - -You will need to create the named secret in your cluster, specifying the private -and public certificate pair using the format outlined in the -[ingress documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#tls). - -Alternatively, you can use the `kubernetes.io/tls-acme` annotation, and install -the `kube-lego` chart to your cluster to have Let's Encrypt issue your -certificate. See the [kube-lego documentation](https://github.com/kubernetes/charts/blob/master/stable/kube-lego/README.md) -for more information. - -### Enabling the GitLab Container Registry - -The GitLab Registry is disabled by default but can be enabled by providing an -external URL for it in the configuration. In order for the Registry to be easily -used by GitLab CI and your Kubernetes cluster, you will need to set it up with -a TLS certificate, so these examples will include the ingress settings for that -as well. See the [HTTPS Configuration section](#https-configuration) -for more explanation on some of these settings. - -Example config: - -```yaml -externalUrl: 'https://gitlab.example.com' - -omnibusConfigRuby: | - # This is example config of what you may already have in your omnibusConfigRuby object - unicorn['worker_processes'] = 2; - gitlab_rails['trusted_proxies'] = ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"]; - - registry_external_url 'https://registry.example.com'; - - # These are the settings needed to support proxied SSL - nginx['listen_port'] = 80 - nginx['listen_https'] = false - nginx['proxy_set_headers'] = { - "X-Forwarded-Proto" => "https", - "X-Forwarded-Ssl" => "on" - } - registry_nginx['listen_port'] = 80 - registry_nginx['listen_https'] = false - registry_nginx['proxy_set_headers'] = { - "X-Forwarded-Proto" => "https", - "X-Forwarded-Ssl" => "on" - } - -ingress: - enabled: true - annotations: - kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: 'true' Annotation used for letsencrypt support - - hosts: - - gitlab.example.com - - registry.example.com - - ## gitlab Ingress TLS configuration - ## Secrets must be created in the namespace, and is not done for you in this chart - ## - tls: - - secretName: gitlab-tls - hosts: - - gitlab.example.com - - registry.example.com -``` - -## Installing GitLab using the Helm Chart -> You may see a temporary error message `SchedulerPredicates failed due to PersistentVolumeClaim is not bound` while storage provisions. Once the storage provisions, the pods will automatically restart. This may take a couple minutes depending on your cloud provider. If the error persists, please review the [prerequisites](#prerequisites) to ensure you have enough RAM, CPU, and storage. - -Add the GitLab Helm repository and initialize Helm: - -```bash -helm repo add gitlab https://charts.gitlab.io -helm init -``` - -Once you [have configured](#configuration) GitLab in your `values.yml` file, -run the following: - -```bash -helm install --namespace --name gitlab -f gitlab/gitlab -``` - -where: - -- `` is the Kubernetes namespace where you want to install GitLab. -- `` is the path to values file containing your custom - configuration. See the [Configuration](#configuration) section to create it. - -## Updating GitLab using the Helm Chart - -Once your GitLab Chart is installed, configuration changes and chart updates -should we done using `helm upgrade` - -```bash -helm upgrade --namespace -f gitlab/gitlab -``` - -where: - -- `` is the Kubernetes namespace where GitLab is installed. -- `` is the path to values file containing your custom - [configuration] (#configuration). -- `` is the name you gave the chart when installing it. - In the [Install section](#installing) we called it `gitlab`. - -## Uninstalling GitLab using the Helm Chart - -To uninstall the GitLab Chart, run the following: - -```bash -helm delete --namespace -``` - -where: - -- `` is the Kubernetes namespace where GitLab is installed. -- `` is the name you gave the chart when installing it. - In the [Install section](#installing) we called it `gitlab`. - -[kube-srv]: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types -[storageclass]: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storageclasses +This chart has been deprecated and is no longer available as of March 22nd 2018. Please refer to our [Helm chart documentation](index.md) for current charts. \ No newline at end of file diff --git a/doc/install/kubernetes/index.md b/doc/install/kubernetes/index.md index aa9b8777359..7c988837384 100644 --- a/doc/install/kubernetes/index.md +++ b/doc/install/kubernetes/index.md @@ -13,7 +13,6 @@ should be deployed, upgraded, and configured. * **[Cloud Native GitLab Chart](https://gitlab.com/charts/helm.gitlab.io/blob/master/README.md)**: The next generation GitLab chart, currently in alpha. Will support large deployments with horizontal scaling of individual GitLab components. * Other Charts * [GitLab Runner Chart](gitlab_runner_chart.md): For deploying just the GitLab Runner. - * [Advanced GitLab Installation](gitlab_chart.md): Deprecated, being replaced by the [cloud native GitLab chart](#cloud-native-gitlab-chart). Provides additional deployment options, but provides less functionality out-of-the-box. * [Community Contributed Charts](#community-contributed-charts): Community contributed charts, deprecated by the official GitLab chart. ## GitLab-Omnibus Chart (Recommended) From b5bf1e0847bea0df7562c53e5d0c855ea7052a7e Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Tue, 17 Apr 2018 22:40:09 -0400 Subject: [PATCH 22/65] Change title for SEO reasons --- doc/install/kubernetes/gitlab_chart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/install/kubernetes/gitlab_chart.md b/doc/install/kubernetes/gitlab_chart.md index 7474cee3af6..8e1316ec0ea 100644 --- a/doc/install/kubernetes/gitlab_chart.md +++ b/doc/install/kubernetes/gitlab_chart.md @@ -1,3 +1,3 @@ -# GitLab Helm Chart +# Deprecated Chart This chart has been deprecated and is no longer available as of March 22nd 2018. Please refer to our [Helm chart documentation](index.md) for current charts. \ No newline at end of file From 5c9b7db53cd10b76576aa0f3203dabd7233d1573 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Tue, 17 Apr 2018 22:46:47 -0400 Subject: [PATCH 23/65] Switch over to CNG chart short description --- doc/install/kubernetes/gitlab_chart.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/install/kubernetes/gitlab_chart.md b/doc/install/kubernetes/gitlab_chart.md index 8e1316ec0ea..b56938ea6c7 100644 --- a/doc/install/kubernetes/gitlab_chart.md +++ b/doc/install/kubernetes/gitlab_chart.md @@ -1,3 +1,6 @@ -# Deprecated Chart +# GitLab Helm Chart +> **Note:** This chart is currently in alpha. -This chart has been deprecated and is no longer available as of March 22nd 2018. Please refer to our [Helm chart documentation](index.md) for current charts. \ No newline at end of file +The cloud native `gitlab` chart is the next generation Helm chart, currently in alpha, and will replace the [`gitlab-omnibus`](gitlab_omnibus.md) chart. It will support large deployments with horizontal scaling of individual GitLab components. + +Installation instructions and known issues are available at the [project page](https://gitlab.com/charts/helm.gitlab.io/). \ No newline at end of file From b1a1317e03b24bfba34b5eba0d997a7dc52ccf86 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Tue, 17 Apr 2018 22:47:27 -0400 Subject: [PATCH 24/65] Switch over to CNG chart short description --- doc/install/kubernetes/gitlab_chart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/install/kubernetes/gitlab_chart.md b/doc/install/kubernetes/gitlab_chart.md index b56938ea6c7..f94594f208e 100644 --- a/doc/install/kubernetes/gitlab_chart.md +++ b/doc/install/kubernetes/gitlab_chart.md @@ -3,4 +3,4 @@ The cloud native `gitlab` chart is the next generation Helm chart, currently in alpha, and will replace the [`gitlab-omnibus`](gitlab_omnibus.md) chart. It will support large deployments with horizontal scaling of individual GitLab components. -Installation instructions and known issues are available at the [project page](https://gitlab.com/charts/helm.gitlab.io/). \ No newline at end of file +Installation instructions and known issues during alpha are available at the [project page](https://gitlab.com/charts/helm.gitlab.io/). \ No newline at end of file From 952f18e908faa17ea011c1a95035e4b50c28dd97 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Wed, 18 Apr 2018 13:12:54 +0300 Subject: [PATCH 25/65] Restore size and position for fork icon --- app/assets/stylesheets/framework/wells.scss | 1 + app/assets/stylesheets/pages/commits.scss | 2 +- app/helpers/commits_helper.rb | 2 +- .../unreleased/restore-size-and-position-for-fork-icon.yml | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/restore-size-and-position-for-fork-icon.yml diff --git a/app/assets/stylesheets/framework/wells.scss b/app/assets/stylesheets/framework/wells.scss index 2f3a80daa90..3fa7a260017 100644 --- a/app/assets/stylesheets/framework/wells.scss +++ b/app/assets/stylesheets/framework/wells.scss @@ -19,6 +19,7 @@ .fork-svg { margin-right: 4px; + vertical-align: bottom; } } diff --git a/app/assets/stylesheets/pages/commits.scss b/app/assets/stylesheets/pages/commits.scss index 86cdda0359e..327cb1f57ed 100644 --- a/app/assets/stylesheets/pages/commits.scss +++ b/app/assets/stylesheets/pages/commits.scss @@ -70,7 +70,7 @@ } .branch-info .commit-icon { - margin-right: 3px; + margin-right: 8px; svg { top: 3px; diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 98894b86551..e594a1d0ba3 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -63,7 +63,7 @@ module CommitsHelper # Returns a link formatted as a commit branch link def commit_branch_link(url, text) link_to(url, class: 'label label-gray ref-name branch-link') do - sprite_icon('fork', size: 16, css_class: 'fork-svg') + "#{text}" + sprite_icon('fork', size: 12, css_class: 'fork-svg') + "#{text}" end end diff --git a/changelogs/unreleased/restore-size-and-position-for-fork-icon.yml b/changelogs/unreleased/restore-size-and-position-for-fork-icon.yml new file mode 100644 index 00000000000..dd8dad0b17d --- /dev/null +++ b/changelogs/unreleased/restore-size-and-position-for-fork-icon.yml @@ -0,0 +1,5 @@ +--- +title: Fix size and position for fork icon +merge_request: 18449 +author: George Tsiolis +type: changed From be45d454046b7f58c2b586923f5819b9bec95aa5 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 10 Apr 2018 11:10:16 +0100 Subject: [PATCH 26/65] Fixed bugs with IDE new directory Closes #44838 --- .../ide/components/new_dropdown/modal.vue | 9 +- app/assets/javascripts/ide/stores/actions.js | 8 ++ .../ide/stores/modules/commit/actions.js | 2 + .../javascripts/ide/stores/mutation_types.js | 2 + .../javascripts/ide/stores/mutations.js | 11 +- app/assets/javascripts/ide/stores/utils.js | 7 +- .../stores/workers/files_decorator_worker.js | 2 + .../vue_shared/components/file_icon.vue | 109 +++++++++--------- app/assets/stylesheets/pages/repo.scss | 8 +- spec/javascripts/ide/stores/actions_spec.js | 49 +++++++- spec/javascripts/ide/stores/mutations_spec.js | 22 ++++ 11 files changed, 155 insertions(+), 74 deletions(-) diff --git a/app/assets/javascripts/ide/components/new_dropdown/modal.vue b/app/assets/javascripts/ide/components/new_dropdown/modal.vue index 4b5a50785b6..e228a2f4024 100644 --- a/app/assets/javascripts/ide/components/new_dropdown/modal.vue +++ b/app/assets/javascripts/ide/components/new_dropdown/modal.vue @@ -40,13 +40,6 @@ export default { return __('Create file'); }, - formLabelName() { - if (this.type === 'tree') { - return __('Directory name'); - } - - return __('File name'); - }, }, mounted() { this.$refs.fieldName.focus(); @@ -83,7 +76,7 @@ export default { >
{ commit(types.UPDATE_DELAY_VIEWER_CHANGE, delay); }; +export const updateTempFlagForEntry = ({ commit, dispatch, state }, { entry, tempFile }) => { + commit(types.UPDATE_TEMP_FLAG, { path: entry.path, tempFile }); + + if (entry.parentPath) { + dispatch('updateTempFlagForEntry', { entry: state.entries[entry.parentPath], tempFile }); + } +}; + export * from './actions/tree'; export * from './actions/file'; export * from './actions/project'; diff --git a/app/assets/javascripts/ide/stores/modules/commit/actions.js b/app/assets/javascripts/ide/stores/modules/commit/actions.js index 367c45f7e2d..7964244743b 100644 --- a/app/assets/javascripts/ide/stores/modules/commit/actions.js +++ b/app/assets/javascripts/ide/stores/modules/commit/actions.js @@ -127,6 +127,8 @@ export const updateFilesAfterCommit = ( }, { root: true }, ); + + dispatch('updateTempFlagForEntry', { entry, tempFile: false }, { root: true }); }); commit(rootTypes.REMOVE_ALL_CHANGES_FILES, null, { root: true }); diff --git a/app/assets/javascripts/ide/stores/mutation_types.js b/app/assets/javascripts/ide/stores/mutation_types.js index e3f504e5ab0..08a5a54ad69 100644 --- a/app/assets/javascripts/ide/stores/mutation_types.js +++ b/app/assets/javascripts/ide/stores/mutation_types.js @@ -53,3 +53,5 @@ export const UPDATE_DELAY_VIEWER_CHANGE = 'UPDATE_DELAY_VIEWER_CHANGE'; export const ADD_PENDING_TAB = 'ADD_PENDING_TAB'; export const REMOVE_PENDING_TAB = 'REMOVE_PENDING_TAB'; + +export const UPDATE_TEMP_FLAG = 'UPDATE_TEMP_FLAG'; diff --git a/app/assets/javascripts/ide/stores/mutations.js b/app/assets/javascripts/ide/stores/mutations.js index 5e5eb831662..5c1db1d245b 100644 --- a/app/assets/javascripts/ide/stores/mutations.js +++ b/app/assets/javascripts/ide/stores/mutations.js @@ -4,6 +4,7 @@ import mergeRequestMutation from './mutations/merge_request'; import fileMutations from './mutations/file'; import treeMutations from './mutations/tree'; import branchMutations from './mutations/branch'; +import { sortTree } from './utils'; export default { [types.SET_INITIAL_DATA](state, data) { @@ -68,7 +69,7 @@ export default { f => foundEntry.tree.find(e => e.path === f.path) === undefined, ); Object.assign(foundEntry, { - tree: foundEntry.tree.concat(tree), + tree: sortTree(foundEntry.tree.concat(tree)), }); } @@ -81,10 +82,16 @@ export default { if (!foundEntry) { Object.assign(state.trees[`${projectId}/${branchId}`], { - tree: state.trees[`${projectId}/${branchId}`].tree.concat(data.treeList), + tree: sortTree(state.trees[`${projectId}/${branchId}`].tree.concat(data.treeList)), }); } }, + [types.UPDATE_TEMP_FLAG](state, { path, tempFile }) { + Object.assign(state.entries[path], { + tempFile, + changed: tempFile, + }); + }, [types.UPDATE_VIEWER](state, viewer) { Object.assign(state, { viewer, diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js index 05a019de54f..fefdbc3222f 100644 --- a/app/assets/javascripts/ide/stores/utils.js +++ b/app/assets/javascripts/ide/stores/utils.js @@ -32,6 +32,7 @@ export const dataStructure = () => ({ raw: '', content: '', parentTreeUrl: '', + parentPath: '', renderError: false, base64: false, editorRow: 1, @@ -63,6 +64,7 @@ export const decorateData = entity => { previewMode, file_lock, html, + parentPath = '', } = entity; return { @@ -79,6 +81,7 @@ export const decorateData = entity => { opened, active, parentTreeUrl, + parentPath, changed, renderError, content, @@ -119,8 +122,8 @@ const sortTreesByTypeAndName = (a, b) => { } else if (a.type === 'blob' && b.type === 'tree') { return 1; } - if (a.name.toLowerCase() < b.name.toLowerCase()) return -1; - if (a.name.toLowerCase() > b.name.toLowerCase()) return 1; + if (a.name < b.name) return -1; + if (a.name > b.name) return 1; return 0; }; diff --git a/app/assets/javascripts/ide/stores/workers/files_decorator_worker.js b/app/assets/javascripts/ide/stores/workers/files_decorator_worker.js index a1673276900..949758c1aa6 100644 --- a/app/assets/javascripts/ide/stores/workers/files_decorator_worker.js +++ b/app/assets/javascripts/ide/stores/workers/files_decorator_worker.js @@ -29,6 +29,7 @@ self.addEventListener('message', e => { tempFile, changed: tempFile, opened: tempFile, + parentPath: parentFolder ? parentFolder.path : null, }); Object.assign(acc, { @@ -66,6 +67,7 @@ self.addEventListener('message', e => { content, base64, previewMode: viewerInformationForPath(blobName), + parentPath: fileFolder ? fileFolder.path : null, }); Object.assign(acc, { diff --git a/app/assets/javascripts/vue_shared/components/file_icon.vue b/app/assets/javascripts/vue_shared/components/file_icon.vue index ee1c3498748..be2755452e2 100644 --- a/app/assets/javascripts/vue_shared/components/file_icon.vue +++ b/app/assets/javascripts/vue_shared/components/file_icon.vue @@ -1,9 +1,9 @@