From ecefe090460687a078e3d1aacf621fd5bff07fb5 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 31 Aug 2018 16:58:13 +0100 Subject: Render link to branch only when branch still exists --- app/views/projects/pipelines/_info.html.haml | 6 +++++- changelogs/unreleased/42611-removed-branch-link.yml | 5 +++++ spec/features/projects/pipelines/pipeline_spec.rb | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/42611-removed-branch-link.yml diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index ccb83148ded..57c5f64ee8d 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -13,7 +13,11 @@ = pluralize @pipeline.total_size, "job" - if @pipeline.ref from - = link_to @pipeline.ref, project_ref_path(@project, @pipeline.ref), class: "ref-name" + - if @project.repository.branch_exists?(@pipeline.ref) + = link_to @pipeline.ref, project_ref_path(@project, @pipeline.ref), class: "ref-name" + - else + %span.ref-name + = @pipeline.ref - if @pipeline.duration in = time_interval_in_words(@pipeline.duration) diff --git a/changelogs/unreleased/42611-removed-branch-link.yml b/changelogs/unreleased/42611-removed-branch-link.yml new file mode 100644 index 00000000000..03a206871b4 --- /dev/null +++ b/changelogs/unreleased/42611-removed-branch-link.yml @@ -0,0 +1,5 @@ +--- +title: Only render link to branch when branch still exists in pipeline page +merge_request: +author: +type: fixed diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 603503a531c..4d659cb988e 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -63,6 +63,11 @@ describe 'Pipeline', :js do expect(page).to have_css('#js-tab-pipeline.active') end + it 'shows link to the pipeline ref' do + expect(page).to have_link(pipeline.ref) + end + + it_behaves_like 'showing user status' do let(:user_with_status) { pipeline.user } @@ -208,6 +213,18 @@ describe 'Pipeline', :js do it { expect(page).not_to have_content('Cancel running') } end end + + context 'with deleted branch' do + before do + DeleteBranchService.new(@project, @user).execute(pipeline.ref) + end + + it 'does not render link to the pipeline ref' do + expect(page).not_to have_link(pipeline.ref) + expect(page).to have_content(pipeline.ref) + end + end + end context 'when user does not have access to read jobs' do -- cgit v1.2.1 From 2906e09f3ab8df4a5f2baf88663fd9cf459554d1 Mon Sep 17 00:00:00 2001 From: Ryan Hefner Date: Thu, 13 Sep 2018 16:27:57 +0200 Subject: Add dbname to MySQL migration GRANT command --- lib/gitlab/database/migration_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 7f012312819..f1466513d45 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -937,7 +937,7 @@ database (#{dbname}) using a super user and running: For MySQL you instead need to run: - GRANT ALL PRIVILEGES ON *.* TO #{user}@'%' + GRANT ALL PRIVILEGES ON #{dbname}.* TO #{user}@'%' Both queries will grant the user super user permissions, ensuring you don't run into similar problems in the future (e.g. when new tables are created). -- cgit v1.2.1 From 0d583e5e8a36231eef614305208ea67ab91a5b62 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 8 Oct 2018 16:55:13 +0100 Subject: Creates ref_exists? method for Pipeline class --- app/models/ci/pipeline.rb | 4 ++++ app/views/projects/pipelines/_info.html.haml | 2 +- spec/features/projects/pipelines/pipeline_spec.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 17024e8a0af..c53b14bd406 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -268,6 +268,10 @@ module Ci stage unless stage.statuses_count.zero? end + def ref_exists? + project.repository.ref_exists?(self.ref) + end + ## # TODO We do not completely switch to persisted stages because of # race conditions with setting statuses gitlab-ce#23257. diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index 57c5f64ee8d..ba7f542f68e 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -13,7 +13,7 @@ = pluralize @pipeline.total_size, "job" - if @pipeline.ref from - - if @project.repository.branch_exists?(@pipeline.ref) + - if @pipeline.ref_exists? = link_to @pipeline.ref, project_ref_path(@project, @pipeline.ref), class: "ref-name" - else %span.ref-name diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 8cdefebd4ce..a79dbe7f877 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -244,7 +244,7 @@ describe 'Pipeline', :js do context 'with deleted branch' do before do - DeleteBranchService.new(@project, @user).execute(pipeline.ref) + allow(pipeline).to receive(:ref_exists?).and_return(false) end it 'does not render link to the pipeline ref' do -- cgit v1.2.1 From 15168c443364900237e16e17a4c5b8cf7f97a1b4 Mon Sep 17 00:00:00 2001 From: Michael Hahnle Date: Sat, 13 Oct 2018 09:59:31 +0000 Subject: Request to be a German proofreader --- doc/development/i18n/proofreader.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/development/i18n/proofreader.md b/doc/development/i18n/proofreader.md index 5e13c725e15..bf9fa1ed9f0 100644 --- a/doc/development/i18n/proofreader.md +++ b/doc/development/i18n/proofreader.md @@ -20,6 +20,7 @@ are very appreciative of the work done by translators and proofreaders! - French - Davy Defaud - [GitLab](https://gitlab.com/DevDef), [Crowdin](https://crowdin.com/profile/DevDef) - German + - Michael Hahnle - [GitLab](https://gitlab.com/mhah), [Crowdin](https://crowdin.com/profile/mhah) - Indonesian - Ahmad Naufal Mukhtar - [GitLab](https://gitlab.com/anaufalm), [Crowdin](https://crowdin.com/profile/anaufalm) - Italian -- cgit v1.2.1 From 49d7c3b3461442a60d06a26c8cc971205afa3642 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 17 Oct 2018 15:16:28 +0100 Subject: Removes extra empty lines --- spec/features/projects/pipelines/pipeline_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index a79dbe7f877..5734c7e355e 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -72,7 +72,6 @@ describe 'Pipeline', :js do expect(page).to have_link(pipeline.ref) end - it_behaves_like 'showing user status' do let(:user_with_status) { pipeline.user } @@ -252,7 +251,6 @@ describe 'Pipeline', :js do expect(page).to have_content(pipeline.ref) end end - end context 'when user does not have access to read jobs' do -- cgit v1.2.1 From 4c4d1b792867195920fb6d6fb41cfa03a99cd299 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 18 Oct 2018 17:01:55 -0700 Subject: Fix EOF detection with CI artifacts metadata There are some corner cases where a perfectly correct GZIP stream may not hit the EOF until another read is attempted. We now skip the entry if we don't see any valid data, which allows the EOF check to work properly. Closes https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22479 --- changelogs/unreleased/sh-pages-eof-error.yml | 5 +++++ lib/gitlab/ci/build/artifacts/metadata.rb | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/sh-pages-eof-error.yml diff --git a/changelogs/unreleased/sh-pages-eof-error.yml b/changelogs/unreleased/sh-pages-eof-error.yml new file mode 100644 index 00000000000..497a74c1458 --- /dev/null +++ b/changelogs/unreleased/sh-pages-eof-error.yml @@ -0,0 +1,5 @@ +--- +title: Fix EOF detection with CI artifacts metadata +merge_request: 22479 +author: +type: fixed diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb index 375d8bc1ff5..551d4f4473e 100644 --- a/lib/gitlab/ci/build/artifacts/metadata.rb +++ b/lib/gitlab/ci/build/artifacts/metadata.rb @@ -59,9 +59,12 @@ module Gitlab until gz.eof? begin - path = read_string(gz).force_encoding('UTF-8') - meta = read_string(gz).force_encoding('UTF-8') + path = read_string(gz)&.force_encoding('UTF-8') + meta = read_string(gz)&.force_encoding('UTF-8') + # We might hit an EOF while reading either value, so we should + # abort if we don't get any data. + next unless path && meta next unless path.valid_encoding? && meta.valid_encoding? next unless path =~ match_pattern next if path =~ INVALID_PATH_PATTERN -- cgit v1.2.1 From 9065599e7947e44ea51be9824fe60b0d858b1605 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 19 Oct 2018 05:03:53 -0700 Subject: Add a spec that generates the metadata dynamically --- .../lib/gitlab/ci/build/artifacts/metadata_spec.rb | 30 ++++++++++++++ .../helpers/ci_artifact_metadata_generator.rb | 48 ++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 spec/support/helpers/ci_artifact_metadata_generator.rb diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb index e327399d82d..a9a4af1f455 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb @@ -112,4 +112,34 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do end end end + + context 'generated metadata' do + let(:tmpfile) { Tempfile.new('test-metadata') } + let(:generator) { CiArtifactMetadataGenerator.new(tmpfile) } + let(:entry_count) { 5 } + + before do + tmpfile.binmode + + (1..entry_count).each do |index| + generator.add_entry("public/test-#{index}.txt") + end + + generator.write + end + + after do + File.unlink(tmpfile.path) + end + + describe '#find_entries!' do + it 'reads expected number of entries' do + stream = File.open(tmpfile.path) + + metadata = described_class.new(stream, 'public', { recursive: true }) + + expect(metadata.find_entries!.count).to eq entry_count + end + end + end end diff --git a/spec/support/helpers/ci_artifact_metadata_generator.rb b/spec/support/helpers/ci_artifact_metadata_generator.rb new file mode 100644 index 00000000000..ef638d59d2d --- /dev/null +++ b/spec/support/helpers/ci_artifact_metadata_generator.rb @@ -0,0 +1,48 @@ +# frozen_sting_literal: true + +# This generates fake CI metadata .gz for testing +# Based off https://gitlab.com/gitlab-org/gitlab-workhorse/blob/master/internal/zipartifacts/metadata.go +class CiArtifactMetadataGenerator + attr_accessor :entries, :output + + ARTIFACT_METADATA = "GitLab Build Artifacts Metadata 0.0.2\n".freeze + + def initialize(stream) + @entries = {} + @output = Zlib::GzipWriter.new(stream) + end + + def add_entry(filename) + @entries[filename] = { CRC: rand(0xfffffff), Comment: FFaker::Lorem.sentence(10) } + end + + def write + write_version + write_errors + write_entries + output.close + end + + private + + def write_version + write_string(ARTIFACT_METADATA) + end + + def write_errors + write_string('{}') + end + + def write_entries + entries.each do |filename, metadata| + write_string(filename) + write_string(metadata.to_json + "\n") + end + end + + def write_string(data) + bytes = [data.length].pack('L>') + output.write(bytes) + output.write(data) + end +end -- cgit v1.2.1 From 711c1812b7b71d3c6461ca731be77a37e9a97369 Mon Sep 17 00:00:00 2001 From: Adriel Santiago Date: Fri, 19 Oct 2018 19:53:32 -0400 Subject: Backport scss changes for ee 7973 https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7973 --- app/assets/stylesheets/framework/common.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/assets/stylesheets/framework/common.scss b/app/assets/stylesheets/framework/common.scss index 3c9505a21d6..fa753b13e5f 100644 --- a/app/assets/stylesheets/framework/common.scss +++ b/app/assets/stylesheets/framework/common.scss @@ -334,6 +334,14 @@ img.emoji { } } +.outline-0 { + outline: 0; + + &:focus { + outline: 0; + } +} + /** COMMON CLASSES **/ .prepend-top-0 { margin-top: 0; } .prepend-top-2 { margin-top: 2px; } @@ -369,3 +377,5 @@ img.emoji { .flex-align-self-center { align-self: center; } .flex-grow { flex-grow: 1; } .flex-no-shrink { flex-shrink: 0; } +.mw-460 { max-width: 460px; } +.ws-initial { white-space: initial; } -- cgit v1.2.1 From efd0a9da53a0803bcd82d00d0db4824cd505840d Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 22 Oct 2018 06:21:12 +0000 Subject: Correcting a typo --- doc/ci/runners/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ci/runners/README.md b/doc/ci/runners/README.md index 83e0fa34ad6..2a179bfbbf0 100644 --- a/doc/ci/runners/README.md +++ b/doc/ci/runners/README.md @@ -312,7 +312,7 @@ We're always looking for contributions that can mitigate these If you think that registration token for a Project was revealed, you should reset them. It's recommended because such token can be used to register another -Runner to thi Project. It may be next used to obtain the values of secret +Runner to the Project. It may be next used to obtain the values of secret variables or clone the project code, that normally may be unavailable for the attacker. -- cgit v1.2.1 From bc333f38d82097288586d0847d6f8e31738e8575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Sun, 7 Oct 2018 10:22:40 +0200 Subject: Support licenses and performance This introduces a new syntax for all licenses and performance jobs: ```yaml job: reports: performance: performance.json license_management: gl-license-management-report.json ``` --- app/models/ci/job_artifact.rb | 12 +++++++++--- .../support-license-management-and-performance.yml | 5 +++++ lib/gitlab/ci/config/entry/reports.rb | 4 +++- spec/lib/gitlab/ci/config/entry/reports_spec.rb | 2 ++ spec/services/ci/retry_build_service_spec.rb | 1 + 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/support-license-management-and-performance.yml diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 2b28b702b05..34a889057ab 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -19,7 +19,9 @@ module Ci sast: 'gl-sast-report.json', dependency_scanning: 'gl-dependency-scanning-report.json', container_scanning: 'gl-container-scanning-report.json', - dast: 'gl-dast-report.json' + dast: 'gl-dast-report.json', + license_management: 'gl-license-management-report.json', + performance: 'performance.json' }.freeze TYPE_AND_FORMAT_PAIRS = { @@ -35,7 +37,9 @@ module Ci sast: :raw, dependency_scanning: :raw, container_scanning: :raw, - dast: :raw + dast: :raw, + license_management: :raw, + performance: :raw }.freeze belongs_to :project @@ -80,7 +84,9 @@ module Ci dependency_scanning: 6, ## EE-specific container_scanning: 7, ## EE-specific dast: 8, ## EE-specific - codequality: 9 ## EE-specific + codequality: 9, ## EE-specific + license_management: 10, ## EE-specific + performance: 11 ## EE-specific } enum file_format: { diff --git a/changelogs/unreleased/support-license-management-and-performance.yml b/changelogs/unreleased/support-license-management-and-performance.yml new file mode 100644 index 00000000000..2e65dba5e76 --- /dev/null +++ b/changelogs/unreleased/support-license-management-and-performance.yml @@ -0,0 +1,5 @@ +--- +title: Support licenses and performance +merge_request: +author: +type: added diff --git a/lib/gitlab/ci/config/entry/reports.rb b/lib/gitlab/ci/config/entry/reports.rb index 98f12c226b3..3ac2a6fa777 100644 --- a/lib/gitlab/ci/config/entry/reports.rb +++ b/lib/gitlab/ci/config/entry/reports.rb @@ -11,7 +11,7 @@ module Gitlab include Validatable include Attributable - ALLOWED_KEYS = %i[junit codequality sast dependency_scanning container_scanning dast].freeze + ALLOWED_KEYS = %i[junit codequality sast dependency_scanning container_scanning dast performance license_management].freeze attributes ALLOWED_KEYS @@ -26,6 +26,8 @@ module Gitlab validates :dependency_scanning, array_of_strings_or_string: true validates :container_scanning, array_of_strings_or_string: true validates :dast, array_of_strings_or_string: true + validates :performance, array_of_strings_or_string: true + validates :license_management, array_of_strings_or_string: true end end diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb index 7cf541447ce..8095a231cf3 100644 --- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb @@ -38,6 +38,8 @@ describe Gitlab::Ci::Config::Entry::Reports do :dependency_scanning | 'gl-dependency-scanning-report.json' :container_scanning | 'gl-container-scanning-report.json' :dast | 'gl-dast-report.json' + :license_management | 'gl-license-management-report.json' + :performance | 'performance.json' end with_them do diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index 642de81ed52..368abded448 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -27,6 +27,7 @@ describe Ci::RetryBuildService do job_artifacts_metadata job_artifacts_trace job_artifacts_junit job_artifacts_sast job_artifacts_dependency_scanning job_artifacts_container_scanning job_artifacts_dast + job_artifacts_license_management job_artifacts_performance job_artifacts_codequality scheduled_at].freeze IGNORE_ACCESSORS = -- cgit v1.2.1 From 5f412e3a87d1e9444bbef6475a2cd3304f541f7d Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 22 Oct 2018 11:37:52 +0200 Subject: Fix pipeline reference existence check and add specs --- app/models/ci/pipeline.rb | 6 +++--- spec/models/ci/pipeline_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index c53b14bd406..c93f0e0cd55 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -269,7 +269,7 @@ module Ci end def ref_exists? - project.repository.ref_exists?(self.ref) + project.repository.ref_exists?(git_ref) end ## @@ -678,11 +678,11 @@ module Ci def push_details strong_memoize(:push_details) do - Gitlab::Git::Push.new(project, before_sha, sha, push_ref) + Gitlab::Git::Push.new(project, before_sha, sha, git_ref) end end - def push_ref + def git_ref if branch? Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s elsif tag? diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 3b01b39ecab..06f000a7118 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -779,6 +779,29 @@ describe Ci::Pipeline, :mailer do end end + describe 'ref_exists?' do + using RSpec::Parameterized::TableSyntax + + let(:project) { create(:project, :repository) } + + where(:tag, :ref, :result) do + false | 'master' | true + false | 'non-existent-branch' | false + true | 'v1.1.0' | true + true | 'non-existent-tag' | false + end + + with_them do + let(:pipeline) do + create(:ci_empty_pipeline, project: project, tag: tag, ref: ref) + end + + it "correctly detects ref" do + expect(pipeline.ref_exists?).to be result + end + end + end + context 'with non-empty project' do let(:project) { create(:project, :repository) } -- cgit v1.2.1 From 680afb3d77db2f90b1c79d3917ce5d2df187c68b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 22 Oct 2018 13:33:28 +0200 Subject: Do not raise error when checking pipeline reference Return from the `Ci::Pipeline#ref_exists?` in case when there is no repository present. This also fixes pipeline page feature specs by changing pipeline reference instead of stubbing `ref_exist?` method. --- app/models/ci/pipeline.rb | 2 ++ spec/features/projects/pipelines/pipeline_spec.rb | 9 ++++-- spec/models/ci/pipeline_spec.rb | 34 +++++++++++++++-------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index c93f0e0cd55..aeee7f0a5d2 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -270,6 +270,8 @@ module Ci def ref_exists? project.repository.ref_exists?(git_ref) + rescue Gitlab::Git::Repository::NoRepository + false end ## diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 5734c7e355e..cd6c37bf54d 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -241,9 +241,12 @@ describe 'Pipeline', :js do end end - context 'with deleted branch' do - before do - allow(pipeline).to receive(:ref_exists?).and_return(false) + context 'when pipeline ref does not exist in repository anymore' do + let(:pipeline) do + create(:ci_empty_pipeline, project: project, + ref: 'non-existent', + sha: project.commit.id, + user: user) end it 'does not render link to the pipeline ref' do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 06f000a7118..153244b2159 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -780,24 +780,36 @@ describe Ci::Pipeline, :mailer do end describe 'ref_exists?' do - using RSpec::Parameterized::TableSyntax + context 'when repository exists' do + using RSpec::Parameterized::TableSyntax - let(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository) } - where(:tag, :ref, :result) do - false | 'master' | true - false | 'non-existent-branch' | false - true | 'v1.1.0' | true - true | 'non-existent-tag' | false + where(:tag, :ref, :result) do + false | 'master' | true + false | 'non-existent-branch' | false + true | 'v1.1.0' | true + true | 'non-existent-tag' | false + end + + with_them do + let(:pipeline) do + create(:ci_empty_pipeline, project: project, tag: tag, ref: ref) + end + + it "correctly detects ref" do + expect(pipeline.ref_exists?).to be result + end + end end - with_them do + context 'when repository does not exist' do let(:pipeline) do - create(:ci_empty_pipeline, project: project, tag: tag, ref: ref) + create(:ci_empty_pipeline, project: project, ref: 'master') end - it "correctly detects ref" do - expect(pipeline.ref_exists?).to be result + it 'always returns false' do + expect(pipeline.ref_exists?).to eq false end end end -- cgit v1.2.1 From aed0f088f5037e41bd40dc41d029937b71e3c87b Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Thu, 18 Oct 2018 15:21:40 +0200 Subject: Add tests for shared/runners/show.html.haml view --- spec/factories/ci/runners.rb | 10 ++ spec/views/shared/runners/show.html.haml_spec.rb | 155 +++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 spec/views/shared/runners/show.html.haml_spec.rb diff --git a/spec/factories/ci/runners.rb b/spec/factories/ci/runners.rb index f564e7bee47..24e70913b87 100644 --- a/spec/factories/ci/runners.rb +++ b/spec/factories/ci/runners.rb @@ -47,5 +47,15 @@ FactoryBot.define do trait :ref_protected do access_level :ref_protected end + + trait :tagged_only do + run_untagged false + + tag_list %w(tag1 tag2) + end + + trait :locked do + locked true + end end end diff --git a/spec/views/shared/runners/show.html.haml_spec.rb b/spec/views/shared/runners/show.html.haml_spec.rb new file mode 100644 index 00000000000..5e92928b143 --- /dev/null +++ b/spec/views/shared/runners/show.html.haml_spec.rb @@ -0,0 +1,155 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'shared/runners/show.html.haml' do + include PageLayoutHelper + + let(:runner) do + create(:ci_runner, name: 'test runner', + version: '11.4.0', + ip_address: '127.1.2.3', + revision: 'abcd1234', + architecture: 'amd64' ) + end + + before do + assign(:runner, runner) + end + + subject do + render + rendered + end + + describe 'Page title' do + before do + expect_any_instance_of(PageLayoutHelper).to receive(:page_title).with("#{runner.description} ##{runner.id}", 'Runners') + end + + it 'sets proper page title' do + render + end + end + + describe 'Runner id and type' do + context 'when runner is of type instance' do + it { is_expected.to have_content("Runner ##{runner.id} Shared") } + end + + context 'when runner is of type group' do + let(:runner) { create(:ci_runner, :group) } + + it { is_expected.to have_content("Runner ##{runner.id} Group") } + end + + context 'when runner is of type project' do + let(:runner) { create(:ci_runner, :project) } + + it { is_expected.to have_content("Runner ##{runner.id} Specific") } + end + end + + describe 'Active value' do + context 'when runner is active' do + it { is_expected.to have_content('Active Yes') } + end + + context 'when runner is inactive' do + let(:runner) { create(:ci_runner, :inactive) } + + it { is_expected.to have_content('Active No') } + end + end + + describe 'Protected value' do + context 'when runner is not protected' do + it { is_expected.to have_content('Protected No') } + end + + context 'when runner is protected' do + let(:runner) { create(:ci_runner, :ref_protected) } + + it { is_expected.to have_content('Protected Yes') } + end + end + + describe 'Can run untagged jobs value' do + context 'when runner run untagged job is set' do + it { is_expected.to have_content('Can run untagged jobs Yes') } + end + + context 'when runner run untagged job is unset' do + let(:runner) { create(:ci_runner, :tagged_only) } + + it { is_expected.to have_content('Can run untagged jobs No') } + end + end + + describe 'Locked to this project value' do + context 'when runner locked is not set' do + it { is_expected.to have_content('Locked to this project No') } + + context 'when runner is of type group' do + let(:runner) { create(:ci_runner, :group) } + + it { is_expected.not_to have_content('Locked to this project') } + end + end + + context 'when runner locked is set' do + let(:runner) { create(:ci_runner, :locked) } + + it { is_expected.to have_content('Locked to this project Yes') } + + context 'when runner is of type group' do + let(:runner) { create(:ci_runner, :group, :locked) } + + it { is_expected.not_to have_content('Locked to this project') } + end + end + end + + describe 'Tags value' do + context 'when runner does not have tags' do + it { is_expected.to have_content('Tags') } + it { is_expected.not_to have_selector('span.badge.badge-primary')} + end + + context 'when runner have tags' do + let(:runner) { create(:ci_runner, tag_list: %w(tag2 tag3 tag1)) } + + it { is_expected.to have_content('Tags tag1 tag2 tag3') } + it { is_expected.to have_selector('span.badge.badge-primary')} + end + end + + describe 'Metadata values' do + it { is_expected.to have_content("Name #{runner.name}") } + it { is_expected.to have_content("Version #{runner.version}") } + it { is_expected.to have_content("IP Address #{runner.ip_address}") } + it { is_expected.to have_content("Revision #{runner.revision}") } + it { is_expected.to have_content("Platform #{runner.platform}") } + it { is_expected.to have_content("Architecture #{runner.architecture}") } + it { is_expected.to have_content("Description #{runner.description}") } + end + + describe 'Maximum job timeout value' do + let(:runner) { create(:ci_runner, maximum_timeout: 5400) } + + it { is_expected.to have_content('Maximum job timeout 1h 30m') } + end + + describe 'Last contact value' do + context 'when runner have not contacted yet' do + it { is_expected.to have_content('Last contact Never') } + end + + context 'when runner have already contacted' do + let(:runner) { create(:ci_runner, contacted_at: DateTime.now - 6.days) } + let(:expected_contacted_at) { I18n.localize(runner.contacted_at, format: "%b %d, %Y") } + + it { is_expected.to have_content("Last contact #{expected_contacted_at}") } + end + end +end -- cgit v1.2.1 From b254f6d52dcafaa3bd0cf1e42e400dd41d213b4c Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Thu, 18 Oct 2018 15:22:23 +0200 Subject: Fix rendering of 'Protected' value --- app/views/shared/runners/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/runners/show.html.haml b/app/views/shared/runners/show.html.haml index 362569bfbaf..f62eed694d2 100644 --- a/app/views/shared/runners/show.html.haml +++ b/app/views/shared/runners/show.html.haml @@ -24,7 +24,7 @@ %td= @runner.active? ? 'Yes' : 'No' %tr %td Protected - %td= @runner.active? ? _('Yes') : _('No') + %td= @runner.ref_protected? ? 'Yes' : 'No' %tr %td Can run untagged jobs %td= @runner.run_untagged? ? 'Yes' : 'No' -- cgit v1.2.1 From f572226fd56d1e161cfe26c52230b991c75159df Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Thu, 18 Oct 2018 15:23:20 +0200 Subject: Add CHANGELOG entry --- changelogs/unreleased/52840-fix-runners-details-page.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/52840-fix-runners-details-page.yml diff --git a/changelogs/unreleased/52840-fix-runners-details-page.yml b/changelogs/unreleased/52840-fix-runners-details-page.yml new file mode 100644 index 00000000000..b061390fcf0 --- /dev/null +++ b/changelogs/unreleased/52840-fix-runners-details-page.yml @@ -0,0 +1,5 @@ +--- +title: Fix rendering of 'Protected' value on Runner details page +merge_request: 22459 +author: +type: fixed -- cgit v1.2.1 From 77ea33304a903408c84798fcddf571781a5d6c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 18 Oct 2018 16:01:32 +0200 Subject: Run karma for qa-* branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c652b6c75e2..b3593df8b13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -723,7 +723,7 @@ gitlab:assets:compile: - public/assets/ karma: - <<: *dedicated-no-docs-and-no-qa-pull-cache-job + <<: *dedicated-no-docs-pull-cache-job <<: *use-pg dependencies: - compile-assets -- cgit v1.2.1 From be493207b069d832d5ecb97fb157df60fa58094f Mon Sep 17 00:00:00 2001 From: Cindy Pallares Date: Fri, 19 Oct 2018 11:36:41 -0500 Subject: Alias the lfs_enabled method We currently check for `project.lfs_enabled` to display the state of lfs being enabled/disabled, but this is set to nil by default, even when lfs is enabled. Aliasing the method to #lfs_enabled? will return the correct state. --- app/models/project.rb | 2 ++ changelogs/unreleased/lfs-project-attribute-alias.yml | 5 +++++ spec/lib/gitlab/import_export/project_tree_restorer_spec.rb | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/lfs-project-attribute-alias.yml diff --git a/app/models/project.rb b/app/models/project.rb index 086f256174f..1967f5e2427 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -548,6 +548,8 @@ class Project < ActiveRecord::Base self[:lfs_enabled] && Gitlab.config.lfs.enabled end + alias_method :lfs_enabled, :lfs_enabled? + def auto_devops_enabled? if auto_devops&.enabled.nil? has_auto_devops_implicitly_enabled? diff --git a/changelogs/unreleased/lfs-project-attribute-alias.yml b/changelogs/unreleased/lfs-project-attribute-alias.yml new file mode 100644 index 00000000000..883869f651a --- /dev/null +++ b/changelogs/unreleased/lfs-project-attribute-alias.yml @@ -0,0 +1,5 @@ +--- +title: Resolve LFS not correctly showing enabled +merge_request: 22501 +author: +type: fixed diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb index 7ebfc61f5e7..b0570680d5a 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb @@ -335,7 +335,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do restored_project_json - expect(project.lfs_enabled).to be_nil + expect(project.lfs_enabled).to be_falsey end end -- cgit v1.2.1 From 1e4d61500039ad84e2ab95b58910f592994f56e5 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Mon, 22 Oct 2018 16:47:54 -0500 Subject: Add RoleBinding methods Includes RoleBinding methods to Kubeclient and introduce a new lib class to generate RoleBinding resources. This MR is part of https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22011 --- .../unreleased/add-role-binding-to-kubeclient.yml | 5 +++ lib/gitlab/kubernetes/kube_client.rb | 7 ++++ lib/gitlab/kubernetes/role_binding.rb | 47 ++++++++++++++++++++++ spec/lib/gitlab/kubernetes/role_binding_spec.rb | 47 ++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 changelogs/unreleased/add-role-binding-to-kubeclient.yml create mode 100644 lib/gitlab/kubernetes/role_binding.rb create mode 100644 spec/lib/gitlab/kubernetes/role_binding_spec.rb diff --git a/changelogs/unreleased/add-role-binding-to-kubeclient.yml b/changelogs/unreleased/add-role-binding-to-kubeclient.yml new file mode 100644 index 00000000000..bc343116eb4 --- /dev/null +++ b/changelogs/unreleased/add-role-binding-to-kubeclient.yml @@ -0,0 +1,5 @@ +--- +title: Allow kubeclient to call RoleBinding methods +merge_request: 22524 +author: +type: other diff --git a/lib/gitlab/kubernetes/kube_client.rb b/lib/gitlab/kubernetes/kube_client.rb index 588238de608..e88a15b8acd 100644 --- a/lib/gitlab/kubernetes/kube_client.rb +++ b/lib/gitlab/kubernetes/kube_client.rb @@ -45,6 +45,13 @@ module Gitlab :update_cluster_role_binding, to: :rbac_client + # RBAC methods delegates to the apis/rbac.authorization.k8s.io api + # group client + delegate :create_role_binding, + :get_role_binding, + :update_role_binding, + to: :rbac_client + # Deployments resource is currently on the apis/extensions api group delegate :get_deployments, to: :extensions_client diff --git a/lib/gitlab/kubernetes/role_binding.rb b/lib/gitlab/kubernetes/role_binding.rb new file mode 100644 index 00000000000..4f3ee040bf2 --- /dev/null +++ b/lib/gitlab/kubernetes/role_binding.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Gitlab + module Kubernetes + class RoleBinding + attr_reader :role_name, :namespace, :service_account_name + + def initialize(role_name:, namespace:, service_account_name:) + @role_name = role_name + @namespace = namespace + @service_account_name = service_account_name + end + + def generate + ::Kubeclient::Resource.new.tap do |resource| + resource.metadata = metadata + resource.roleRef = role_ref + resource.subjects = subjects + end + end + + private + + def metadata + { name: "gitlab-#{namespace}", namespace: namespace } + end + + def role_ref + { + apiGroup: 'rbac.authorization.k8s.io', + kind: 'Role', + name: role_name + } + end + + def subjects + [ + { + kind: 'ServiceAccount', + name: service_account_name, + namespace: namespace + } + ] + end + end + end +end diff --git a/spec/lib/gitlab/kubernetes/role_binding_spec.rb b/spec/lib/gitlab/kubernetes/role_binding_spec.rb new file mode 100644 index 00000000000..da3f5d27b25 --- /dev/null +++ b/spec/lib/gitlab/kubernetes/role_binding_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Kubernetes::RoleBinding, '#generate' do + let(:role_name) { 'edit' } + let(:namespace) { 'my-namespace' } + let(:service_account_name) { 'my-service-account' } + + let(:subjects) do + [ + { + kind: 'ServiceAccount', + name: service_account_name, + namespace: namespace + } + ] + end + + let(:role_ref) do + { + apiGroup: 'rbac.authorization.k8s.io', + kind: 'Role', + name: role_name + } + end + + let(:resource) do + ::Kubeclient::Resource.new( + metadata: { name: "gitlab-#{namespace}", namespace: namespace }, + roleRef: role_ref, + subjects: subjects + ) + end + + subject do + described_class.new( + role_name: role_name, + namespace: namespace, + service_account_name: service_account_name + ).generate + end + + it 'should build a Kubeclient Resource' do + is_expected.to eq(resource) + end +end -- cgit v1.2.1 From 2d00e7fce5b33f2a8c89dccd33d5d1758cc846c7 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 8 Oct 2018 11:50:22 +0100 Subject: Add list mode to file browser in diffs This adds toggle buttons to switch between file & tree list. For file list, it renders the truncated paths with the ellipsis at the start of the path. When focusing the input, it hides the toggle buttons. On blur, the buttons get shown again. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51859 --- .../javascripts/diffs/components/tree_list.vue | 101 ++++++++++++++++----- app/assets/javascripts/diffs/store/utils.js | 13 +++ .../javascripts/vue_shared/components/file_row.vue | 8 +- app/assets/stylesheets/pages/diff.scss | 14 ++- changelogs/unreleased/mr-file-list.yml | 5 + locale/gitlab.pot | 6 ++ .../javascripts/diffs/components/tree_list_spec.js | 70 ++++++++++++++ spec/javascripts/diffs/store/utils_spec.js | 28 ++++++ 8 files changed, 221 insertions(+), 24 deletions(-) create mode 100644 changelogs/unreleased/mr-file-list.yml diff --git a/app/assets/javascripts/diffs/components/tree_list.vue b/app/assets/javascripts/diffs/components/tree_list.vue index cfe4273742f..ea1a73d40cd 100644 --- a/app/assets/javascripts/diffs/components/tree_list.vue +++ b/app/assets/javascripts/diffs/components/tree_list.vue @@ -1,10 +1,14 @@