diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-10 06:10:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-10 06:10:11 +0300 |
commit | f2c0afdcb5597b226d75cdb043e57f79034b04bb (patch) | |
tree | e763b343cf6739ad2b43b9d086e5cc66e9e9a2e2 | |
parent | 981771279a48c03263e29f3b4f41f54204ea3146 (diff) |
Add latest changes from gitlab-org/gitlab@master
22 files changed, 316 insertions, 172 deletions
diff --git a/.markdownlint.yml b/.markdownlint.yml index 35e8ef119be..ea7492cf208 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -49,6 +49,7 @@ "Geo", "Git LFS", "git-annex", + "git-sizer", "Git", "Gitaly", "GitHub", diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index a4734f7abe8..b456918a83a 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -0a4e1c785063f4ad2cef80303fa10276e2e4e2a6 +b3d56404cc25983d1bffd015fe0d29c1d50eab58 diff --git a/doc/ci/ci_cd_for_external_repos/index.md b/doc/ci/ci_cd_for_external_repos/index.md index 8c961ea6128..27c808791e5 100644 --- a/doc/ci/ci_cd_for_external_repos/index.md +++ b/doc/ci/ci_cd_for_external_repos/index.md @@ -27,10 +27,10 @@ To connect to an external repository: <!-- vale gitlab.Spelling = NO --> -1. From your GitLab dashboard, click **New project**. -1. Switch to the **CI/CD for external repository** tab. -1. Choose **GitHub** or **Repo by URL**. -1. The next steps are similar to the [import flow](../../user/project/import/index.md). +1. On the top menu, select **Projects > Create new project**. +1. Select **Run CI/CD for external repository**. +1. Select **GitHub** or **Repo by URL**. +1. Complete the fields. <!-- vale gitlab.Spelling = YES --> diff --git a/doc/development/contributing/issue_workflow.md b/doc/development/contributing/issue_workflow.md index b1d18888afe..1dfe560d68d 100644 --- a/doc/development/contributing/issue_workflow.md +++ b/doc/development/contributing/issue_workflow.md @@ -72,12 +72,17 @@ issue should have one and only one. The current type labels are: -- ~feature -- ~bug -- ~tooling -- ~"support request" -- ~meta -- ~documentation +- `~feature` + - `~"feature::addition"` + - `~"feature::enhancement"` + - `~"feature::maintenance"` +- `~bug` +- `~tooling` + - `~"tooling::pipelines"` + - `~"tooling::workflow"` +- `~"support request"` +- `~meta` +- `~documentation` A number of type labels have a priority assigned to them, which automatically makes them float to the top, depending on their importance. diff --git a/doc/topics/git/git_rebase.md b/doc/topics/git/git_rebase.md index 89dbdf54e95..f515677eacf 100644 --- a/doc/topics/git/git_rebase.md +++ b/doc/topics/git/git_rebase.md @@ -174,18 +174,18 @@ the operation you want to perform in each commit. To do so, you need to edit the commits in your terminal's text editor. For example, if you're using [Vim](https://www.vim.org/) as the text editor in -a macOS's `ZSH` shell, and you want to **squash** all the three commits +a macOS's `ZSH` shell, and you want to `squash` or `fixup` all the three commits (join them into one): 1. Press <!-- vale gitlab.FirstPerson = NO --> <kbd>i</kbd> <!-- vale gitlab.FirstPerson = YES --> on your keyboard to switch to Vim's editing mode. 1. Navigate with your keyboard arrows to edit the **second** commit keyword - from `pick` to `squash` (or `s`). Do the same to the **third** commit. + from `pick` to `squash` or `fixup` (or `s` or `f`). Do the same to the **third** commit. The first commit should be left **unchanged** (`pick`) as we want to squash the second and third into the first. 1. Press <kbd>Escape</kbd> to leave the editing mode. 1. Type `:wq` to "write" (save) and "quit". -1. Git outputs the commit message so you have a chance to edit it: +1. When squashing, Git outputs the commit message so you have a chance to edit it: - All lines starting with `#` are ignored and not included in the commit message. Everything else is included. - To leave it as it is, type `:wq`. To edit the commit message: switch to the diff --git a/doc/user/project/repository/reducing_the_repo_size_using_git.md b/doc/user/project/repository/reducing_the_repo_size_using_git.md index 323a2efce76..ecb32feff55 100644 --- a/doc/user/project/repository/reducing_the_repo_size_using_git.md +++ b/doc/user/project/repository/reducing_the_repo_size_using_git.md @@ -13,6 +13,8 @@ Git repositories become larger over time. When large files are added to a Git re - They take up a large amount of storage space on the server. - Git repository storage limits [can be reached](#storage-limits). +Such problems can be detected with [git-sizer](https://github.com/github/git-sizer#getting-started). + Rewriting a repository can remove unwanted history to make the repository smaller. We **recommend [`git filter-repo`](https://github.com/newren/git-filter-repo/blob/main/README.md)** over [`git filter-branch`](https://git-scm.com/docs/git-filter-branch) and diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md index 32f7fee0287..cd0fa351e29 100644 --- a/doc/user/project/settings/import_export.md +++ b/doc/user/project/settings/import_export.md @@ -210,3 +210,59 @@ To help avoid abuse, by default, users are rate limited to: | Import | 6 projects per minute | GitLab.com may have [different settings](../../gitlab_com/index.md#importexport) from the defaults. + +## Troubleshooting + +### Import workaround for large repositories + +[Maximum import size limitations](#importing-the-project) +can prevent an import from being successful. +If changing the import limits is not possible, +the following local workflow can be used to temporarily +reduce the repository size for another import attempt. + +1. Create a temporary working directory from the export: + + ```shell + EXPORT=<filename-without-extension> + + mkdir "$EXPORT" + tar -xf "$EXPORT".tar.gz --directory="$EXPORT"/ + cd "$EXPORT"/ + git clone project.bundle + + # Prevent interference with recreating an importable file later + mv project.bundle ../"$EXPORT"-original.bundle + mv ../"$EXPORT".tar.gz ../"$EXPORT"-original.tar.gz + ``` + +1. To reduce the repository size, + [identify and remove large files](../repository/reducing_the_repo_size_using_git.md) + or [interactively rebase and fixup](../../../topics/git/git_rebase.md#interactive-rebase) + to reduce the number of commits. + + ```shell + # Reduce the .git/objects/pack/ file size + cd project + git reflog expire --expire=now --all + git gc --prune=now --aggressive + + # Prepare recreating an importable file + git bundle create ../project.bundle <default-branch-name> + cd .. + mv project/ ../"$EXPORT"-project + cd .. + + # Recreate an importable file + tar -czf "$EXPORT"-smaller.tar.gz --directory="$EXPORT"/ . + ``` + +1. Import this new, smaller file into GitLab. +1. In a full clone of the original repository, + use `git remote set-url origin <new-url> && git push --force --all` + to complete the import. +1. Update the imported repository's + [branch protection rules](../protected_branches.md) and + its [default branch](../repository/branches/default.md), and + delete the temporary, `smaller-…` branch, and + the local, temporary data. @@ -632,7 +632,9 @@ module QA module Helpers autoload :ContextSelector, 'qa/specs/helpers/context_selector' + autoload :ContextFormatter, 'qa/specs/helpers/context_formatter' autoload :Quarantine, 'qa/specs/helpers/quarantine' + autoload :QuarantineFormatter, 'qa/specs/helpers/quarantine_formatter' autoload :RSpec, 'qa/specs/helpers/rspec' end end @@ -680,6 +682,7 @@ module QA autoload :WaitForRequests, 'qa/support/wait_for_requests' autoload :OTP, 'qa/support/otp' autoload :SSH, 'qa/support/ssh' + autoload :AllureMetadataFormatter, 'qa/support/allure_metadata_formatter.rb' end end diff --git a/qa/qa/runtime/allure_report.rb b/qa/qa/runtime/allure_report.rb index bcfdb09e09f..bf49141566a 100644 --- a/qa/qa/runtime/allure_report.rb +++ b/qa/qa/runtime/allure_report.rb @@ -67,25 +67,8 @@ module QA # @return [void] def configure_rspec RSpec.configure do |config| - config.formatter = AllureRspecFormatter - - config.after do |example| - next if example.attempts && example.attempts > 0 - - testcase = example.metadata[:testcase] - example.tms('Testcase', testcase) if testcase - - quarantine_issue = example.metadata.dig(:quarantine, :issue) - example.issue('Quarantine issue', quarantine_issue) if quarantine_issue - - spec_file = example.file_path.split('/').last - example.issue( - 'Failure issues', - "https://gitlab.com/gitlab-org/gitlab/-/issues?scope=all&state=opened&search=#{spec_file}" - ) - - example.add_link(name: "Job(#{Env.ci_job_name})", url: Env.ci_job_url) if Env.running_in_ci? - end + config.add_formatter(AllureRspecFormatter) + config.add_formatter(QA::Support::AllureMetadataFormatter) end end diff --git a/qa/qa/specs/features/api/1_manage/import_large_github_repo_spec.rb b/qa/qa/specs/features/api/1_manage/import_large_github_repo_spec.rb index bc1e67f93e0..688a1bb7be2 100644 --- a/qa/qa/specs/features/api/1_manage/import_large_github_repo_spec.rb +++ b/qa/qa/specs/features/api/1_manage/import_large_github_repo_spec.rb @@ -96,9 +96,6 @@ module QA end after do |example| - # skip saving data if example is skipped or failed before import finished - next if example.pending? - user.remove_via_api! next unless defined?(@import_time) diff --git a/qa/qa/specs/helpers/context_formatter.rb b/qa/qa/specs/helpers/context_formatter.rb new file mode 100644 index 00000000000..26db7c3b67e --- /dev/null +++ b/qa/qa/specs/helpers/context_formatter.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +require 'rspec/core' +require "rspec/core/formatters/base_formatter" + +module QA + module Specs + module Helpers + class ContextFormatter < ::RSpec::Core::Formatters::BaseFormatter + include ContextSelector + + ::RSpec::Core::Formatters.register( + self, + :example_group_started, + :example_started + ) + + # Starts example group + # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification + # @return [void] + def example_group_started(example_group_notification) + set_skip_metadata(example_group_notification.group) + end + + # Starts example + # @param [RSpec::Core::Notifications::ExampleNotification] example_notification + # @return [void] + def example_started(example_notification) + example = example_notification.example + + # if skip propagated from example_group, do not reset skip metadata + set_skip_metadata(example_notification.example) unless example.metadata[:skip] + end + + private + + # Skip example_group or example + # + # @param [<RSpec::Core::ExampleGroup, RSpec::Core::Example>] example + # @return [void] + def set_skip_metadata(example) + return skip_only(example.metadata) if example.metadata.key?(:only) + return skip_except(example.metadata) if example.metadata.key?(:except) + end + + # Skip based on 'only' condition + # + # @param [Hash] metadata + # @return [void] + def skip_only(metadata) + return if context_matches?(metadata[:only]) + + metadata[:skip] = 'Test is not compatible with this environment or pipeline' + end + + # Skip based on 'except' condition + # + # @param [Hash] metadata + # @return [void] + def skip_except(metadata) + return unless except?(metadata[:except]) + + metadata[:skip] = 'Test is excluded in this job' + end + end + end + end +end diff --git a/qa/qa/specs/helpers/context_selector.rb b/qa/qa/specs/helpers/context_selector.rb index 40ecb9b3506..57665babf68 100644 --- a/qa/qa/specs/helpers/context_selector.rb +++ b/qa/qa/specs/helpers/context_selector.rb @@ -8,18 +8,6 @@ module QA module ContextSelector extend self - def configure_rspec - ::RSpec.configure do |config| - config.before do |example| - if example.metadata.key?(:only) - skip('Test is not compatible with this environment or pipeline') unless ContextSelector.context_matches?(example.metadata[:only]) - elsif example.metadata.key?(:except) - skip('Test is excluded in this job') if ContextSelector.except?(example.metadata[:except]) - end - end - end - end - def except?(*options) return false if Runtime::Env.ci_job_name.blank? && options.any? { |o| o.is_a?(Hash) && o[:job].present? } return false if Runtime::Env.ci_project_name.blank? && options.any? { |o| o.is_a?(Hash) && o[:pipeline].present? } diff --git a/qa/qa/specs/helpers/quarantine.rb b/qa/qa/specs/helpers/quarantine.rb index 15b4ed8336b..49d91fc87cd 100644 --- a/qa/qa/specs/helpers/quarantine.rb +++ b/qa/qa/specs/helpers/quarantine.rb @@ -10,26 +10,6 @@ module QA extend self - def configure_rspec - ::RSpec.configure do |config| - config.before(:context, :quarantine) do - Quarantine.skip_or_run_quarantined_contexts(config.inclusion_filter.rules, self.class) - end - - config.before do |example| - Quarantine.skip_or_run_quarantined_tests_or_contexts(config.inclusion_filter.rules, example) - end - end - end - - # Skip the entire context if a context is quarantined. This avoids running - # before blocks unnecessarily. - def skip_or_run_quarantined_contexts(filters, example) - return unless example.metadata.key?(:quarantine) - - skip_or_run_quarantined_tests_or_contexts(filters, example) - end - # Skip tests in quarantine unless we explicitly focus on them. def skip_or_run_quarantined_tests_or_contexts(filters, example) if filters.key?(:quarantine) @@ -43,19 +23,19 @@ module QA # running that ldap test as well because of the :quarantine metadata. # We could use an exclusion filter, but this way the test report will list # the quarantined tests when they're not run so that we're aware of them - skip("Only running tests tagged with :quarantine and any of #{included_filters.keys}") if should_skip_when_focused?(example.metadata, included_filters) - else - if example.metadata.key?(:quarantine) - quarantine_tag = example.metadata[:quarantine] - - if quarantine_tag.is_a?(Hash) && quarantine_tag&.key?(:only) - # If the :quarantine hash contains :only, we respect that. - # For instance `quarantine: { only: { subdomain: :staging } }` will only quarantine the test when it runs against staging. - return unless ContextSelector.context_matches?(quarantine_tag[:only]) - end + if should_skip_when_focused?(example.metadata, included_filters) + example.metadata[:skip] = "Only running tests tagged with :quarantine and any of #{included_filters.keys}" + end + elsif example.metadata.key?(:quarantine) + quarantine_tag = example.metadata[:quarantine] - skip(quarantine_message(quarantine_tag)) + if quarantine_tag.is_a?(Hash) && quarantine_tag&.key?(:only) && !ContextSelector.context_matches?(quarantine_tag[:only]) + # If the :quarantine hash contains :only, we respect that. + # For instance `quarantine: { only: { subdomain: :staging } }` will only quarantine the test when it runs against staging. + return end + + example.metadata[:skip] = quarantine_message(quarantine_tag) end end @@ -64,7 +44,7 @@ module QA end def quarantine_message(quarantine_tag) - quarantine_message = %w(In quarantine) + quarantine_message = %w[In quarantine] quarantine_message << case quarantine_tag when String ": #{quarantine_tag}" diff --git a/qa/qa/specs/helpers/quarantine_formatter.rb b/qa/qa/specs/helpers/quarantine_formatter.rb new file mode 100644 index 00000000000..c42debee07c --- /dev/null +++ b/qa/qa/specs/helpers/quarantine_formatter.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'rspec/core' +require "rspec/core/formatters/base_formatter" + +module QA + module Specs + module Helpers + class QuarantineFormatter < ::RSpec::Core::Formatters::BaseFormatter + include Quarantine + + ::RSpec::Core::Formatters.register( + self, + :example_group_started, + :example_started + ) + + # Starts example group + # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification + # @return [void] + def example_group_started(example_group_notification) + group = example_group_notification.group + + skip_or_run_quarantined_tests_or_contexts(filters, group) + end + + # Starts example + # @param [RSpec::Core::Notifications::ExampleNotification] example_notification + # @return [void] + def example_started(example_notification) + example = example_notification.example + + # if skip propagated from example_group, do not reset skip metadata + skip_or_run_quarantined_tests_or_contexts(filters, example) unless example.metadata[:skip] + end + + private + + def filters + @filters ||= ::RSpec.configuration.inclusion_filter.rules + end + end + end + end +end diff --git a/qa/qa/specs/helpers/rspec.rb b/qa/qa/specs/helpers/rspec.rb index f49e556b0d9..853dfbfd1b6 100644 --- a/qa/qa/specs/helpers/rspec.rb +++ b/qa/qa/specs/helpers/rspec.rb @@ -19,8 +19,10 @@ module QA # expanding into the global state # See: https://github.com/rspec/rspec-core/issues/2603 def describe_successfully(*args, &describe_body) + reporter = ::RSpec.configuration.reporter + example_group = RSpec.describe(*args, &describe_body) - ran_successfully = example_group.run RaiseOnFailuresReporter + ran_successfully = example_group.run reporter expect(ran_successfully).to eq true example_group end diff --git a/qa/qa/support/allure_metadata_formatter.rb b/qa/qa/support/allure_metadata_formatter.rb new file mode 100644 index 00000000000..8a18eeca839 --- /dev/null +++ b/qa/qa/support/allure_metadata_formatter.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'rspec/core' +require "rspec/core/formatters/base_formatter" + +module QA + module Support + class AllureMetadataFormatter < ::RSpec::Core::Formatters::BaseFormatter + ::RSpec::Core::Formatters.register( + self, + :example_started + ) + + # Starts example + # @param [RSpec::Core::Notifications::ExampleNotification] example_notification + # @return [void] + def example_started(example_notification) + example = example_notification.example + + testcase = example.metadata[:testcase] + example.tms('Testcase', testcase) if testcase + + quarantine_issue = example.metadata.dig(:quarantine, :issue) + example.issue('Quarantine issue', quarantine_issue) if quarantine_issue + + spec_file = example.file_path.split('/').last + example.issue( + 'Failure issues', + "https://gitlab.com/gitlab-org/gitlab/-/issues?scope=all&state=opened&search=#{spec_file}" + ) + return unless Runtime::Env.running_in_ci? + + example.add_link(name: "Job(#{Runtime::Env.ci_job_name})", url: Runtime::Env.ci_job_url) + end + end + end +end diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb index c4da85d75b0..0df7b94b894 100644 --- a/qa/spec/spec_helper.rb +++ b/qa/spec/spec_helper.rb @@ -26,8 +26,8 @@ Dir[::File.join(__dir__, "support/shared_examples/*.rb")].sort.each { |f| requir RSpec.configure do |config| config.include ::Matchers - QA::Specs::Helpers::Quarantine.configure_rspec - QA::Specs::Helpers::ContextSelector.configure_rspec + config.add_formatter QA::Specs::Helpers::ContextFormatter + config.add_formatter QA::Specs::Helpers::QuarantineFormatter config.before do |example| QA::Runtime::Logger.debug("\nStarting test: #{example.full_description}\n") diff --git a/qa/spec/specs/allure_report_spec.rb b/qa/spec/specs/allure_report_spec.rb index 67ae0712260..27bc0dd3d1d 100644 --- a/qa/spec/specs/allure_report_spec.rb +++ b/qa/spec/specs/allure_report_spec.rb @@ -5,21 +5,7 @@ require 'allure-rspec' describe QA::Runtime::AllureReport do include Helpers::StubENV - let(:rspec_config) { double('RSpec::Core::Configuration', 'formatter=': nil, after: nil) } - let(:rspec_example) do - double( - 'RSpec::Core::Example', - tms: nil, - issue: nil, - add_link: nil, - attempts: 0, - file_path: 'file/path/spec.rb', - metadata: { - testcase: 'testcase', - quarantine: { issue: 'issue' } - } - ) - end + let(:rspec_config) { double('RSpec::Core::Configuration', 'add_formatter': nil, after: nil) } let(:png_path) { 'png_path' } let(:html_path) { 'html_path' } @@ -36,7 +22,6 @@ describe QA::Runtime::AllureReport do allow(AllureRspec).to receive(:configure).and_yield(allure_config) allow(RSpec).to receive(:configure).and_yield(rspec_config) - allow(rspec_config).to receive(:after).and_yield(rspec_example) allow(Capybara::Screenshot).to receive(:after_save_screenshot).and_yield(png_path) allow(Capybara::Screenshot).to receive(:after_save_html).and_yield(html_path) end @@ -62,12 +47,10 @@ describe QA::Runtime::AllureReport do let(:png_file) { 'png-file' } let(:html_file) { 'html-file' } let(:ci_job) { 'ee:relative 5' } - let(:ci_job_url) { 'url' } before do stub_env('CI', 'true') stub_env('CI_JOB_NAME', ci_job) - stub_env('CI_JOB_URL', ci_job_url) allow(Allure).to receive(:add_attachment) allow(File).to receive(:open).with(png_path) { png_file } @@ -85,20 +68,9 @@ describe QA::Runtime::AllureReport do end end - it 'adds rspec formatter' do - expect(rspec_config).to have_received(:formatter=).with(AllureRspecFormatter) - end - - it 'configures after block' do - aggregate_failures do - expect(rspec_example).to have_received(:tms).with('Testcase', 'testcase') - expect(rspec_example).to have_received(:issue).with('Quarantine issue', 'issue') - expect(rspec_example).to have_received(:add_link).with(name: "Job(#{ci_job})", url: ci_job_url) - expect(rspec_example).to have_received(:issue).with( - 'Failure issues', - 'https://gitlab.com/gitlab-org/gitlab/-/issues?scope=all&state=opened&search=spec.rb' - ) - end + it 'adds rspec and metadata formatter' do + expect(rspec_config).to have_received(:add_formatter).with(AllureRspecFormatter).ordered + expect(rspec_config).to have_received(:add_formatter).with(QA::Support::AllureMetadataFormatter).ordered end it 'configures screenshot saving' do diff --git a/qa/spec/specs/helpers/context_selector_spec.rb b/qa/spec/specs/helpers/context_selector_spec.rb index f0250103008..cbdbe6698ae 100644 --- a/qa/spec/specs/helpers/context_selector_spec.rb +++ b/qa/spec/specs/helpers/context_selector_spec.rb @@ -2,29 +2,25 @@ require 'rspec/core/sandbox' -RSpec.configure do |c| - c.around do |ex| +RSpec.describe QA::Specs::Helpers::ContextSelector do + include Helpers::StubENV + include QA::Specs::Helpers::RSpec + + around do |ex| + QA::Runtime::Scenario.define(:gitlab_address, 'https://staging.gitlab.com') + RSpec::Core::Sandbox.sandboxed do |config| + config.formatter = QA::Specs::Helpers::ContextFormatter + # If there is an example-within-an-example, we want to make sure the inner example # does not get a reference to the outer example (the real spec) if it calls # something like `pending` config.before(:context) { RSpec.current_example = nil } - config.color_mode = :off ex.run end end -end - -RSpec.describe QA::Specs::Helpers::ContextSelector do - include Helpers::StubENV - include QA::Specs::Helpers::RSpec - - before do - QA::Runtime::Scenario.define(:gitlab_address, 'https://staging.gitlab.com') - described_class.configure_rspec - end describe '.context_matches?' do it 'returns true when url has .com' do @@ -104,7 +100,6 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do context 'with different environment set' do before do QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.com') - described_class.configure_rspec end it 'does not run against production' do @@ -239,7 +234,6 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do context 'without CI_PROJECT_NAME set' do before do stub_env('CI_PROJECT_NAME', nil) - described_class.configure_rspec end it 'runs on any pipeline' do @@ -273,7 +267,6 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do context 'when a pipeline triggered from the default branch runs in gitlab-qa' do before do stub_env('CI_PROJECT_NAME', 'gitlab-qa') - described_class.configure_rspec end it 'runs on default branch pipelines' do @@ -310,7 +303,6 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do context 'with CI_PROJECT_NAME set' do before do stub_env('CI_PROJECT_NAME', 'NIGHTLY') - described_class.configure_rspec end it 'runs on designated pipeline' do @@ -353,7 +345,6 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do context 'without CI_JOB_NAME set' do before do stub_env('CI_JOB_NAME', nil) - described_class.configure_rspec end context 'when excluding contexts' do @@ -396,7 +387,6 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do context 'with CI_JOB_NAME set' do before do stub_env('CI_JOB_NAME', 'ee:instance-image') - described_class.configure_rspec end context 'when excluding contexts' do diff --git a/qa/spec/specs/helpers/quarantine_spec.rb b/qa/spec/specs/helpers/quarantine_spec.rb index 45754a09b17..548a8510988 100644 --- a/qa/spec/specs/helpers/quarantine_spec.rb +++ b/qa/spec/specs/helpers/quarantine_spec.rb @@ -2,9 +2,14 @@ require 'rspec/core/sandbox' -RSpec.configure do |c| - c.around do |ex| +RSpec.describe QA::Specs::Helpers::Quarantine do + include Helpers::StubENV + include QA::Specs::Helpers::RSpec + + around do |ex| RSpec::Core::Sandbox.sandboxed do |config| + config.formatter = QA::Specs::Helpers::QuarantineFormatter + # If there is an example-within-an-example, we want to make sure the inner example # does not get a reference to the outer example (the real spec) if it calls # something like `pending` @@ -15,18 +20,9 @@ RSpec.configure do |c| ex.run end end -end - -RSpec.describe QA::Specs::Helpers::Quarantine do - include Helpers::StubENV - include QA::Specs::Helpers::RSpec describe '.skip_or_run_quarantined_contexts' do context 'with no tag focused' do - before do - described_class.configure_rspec - end - it 'skips before hooks of quarantined contexts' do executed_hooks = [] @@ -66,7 +62,6 @@ RSpec.describe QA::Specs::Helpers::Quarantine do context 'with :quarantine focused' do before do - described_class.configure_rspec RSpec.configure do |c| c.filter_run :quarantine end @@ -110,10 +105,6 @@ RSpec.describe QA::Specs::Helpers::Quarantine do describe '.skip_or_run_quarantined_tests_or_contexts' do context 'with no tag focused' do - before do - described_class.configure_rspec - end - it 'skips quarantined tests' do group = describe_successfully do it('is pending', :quarantine) {} @@ -135,7 +126,6 @@ RSpec.describe QA::Specs::Helpers::Quarantine do context 'with environment set' do before do QA::Runtime::Scenario.define(:gitlab_address, 'https://staging.gitlab.com') - described_class.configure_rspec end context 'no pipeline specified' do @@ -168,7 +158,6 @@ RSpec.describe QA::Specs::Helpers::Quarantine do shared_examples 'skipped in project' do |project| before do stub_env('CI_PROJECT_NAME', project) - described_class.configure_rspec end it "is skipped in #{project}" do @@ -209,7 +198,6 @@ RSpec.describe QA::Specs::Helpers::Quarantine do context 'with :quarantine focused' do before do - described_class.configure_rspec RSpec.configure do |c| c.filter_run :quarantine end @@ -234,7 +222,6 @@ RSpec.describe QA::Specs::Helpers::Quarantine do context 'with a non-quarantine tag focused' do before do - described_class.configure_rspec RSpec.configure do |c| c.filter_run :foo end @@ -277,7 +264,6 @@ RSpec.describe QA::Specs::Helpers::Quarantine do context 'with :quarantine and non-quarantine tags focused' do before do - described_class.configure_rspec RSpec.configure do |c| c.filter_run :foo, :bar, :quarantine end diff --git a/qa/spec/support/allure_metadata_formatter_spec.rb b/qa/spec/support/allure_metadata_formatter_spec.rb new file mode 100644 index 00000000000..cb208642716 --- /dev/null +++ b/qa/spec/support/allure_metadata_formatter_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +describe QA::Support::AllureMetadataFormatter do + include Helpers::StubENV + + let(:formatter) { described_class.new(StringIO.new) } + + let(:rspec_example_notification) { double('RSpec::Core::Notifications::ExampleNotification', example: rspec_example) } + let(:rspec_example) do + double( + 'RSpec::Core::Example', + tms: nil, + issue: nil, + add_link: nil, + attempts: 0, + file_path: 'file/path/spec.rb', + metadata: { + testcase: 'testcase', + quarantine: { issue: 'issue' } + } + ) + end + + let(:ci_job) { 'ee:relative 5' } + let(:ci_job_url) { 'url' } + + before do + stub_env('CI', 'true') + stub_env('CI_JOB_NAME', ci_job) + stub_env('CI_JOB_URL', ci_job_url) + end + + it "adds additional data to report" do + formatter.example_started(rspec_example_notification) + + aggregate_failures do + expect(rspec_example).to have_received(:tms).with('Testcase', 'testcase') + expect(rspec_example).to have_received(:issue).with('Quarantine issue', 'issue') + expect(rspec_example).to have_received(:add_link).with(name: "Job(#{ci_job})", url: ci_job_url) + expect(rspec_example).to have_received(:issue).with( + 'Failure issues', + 'https://gitlab.com/gitlab-org/gitlab/-/issues?scope=all&state=opened&search=spec.rb' + ) + end + end +end diff --git a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js index 8738924f717..6ab828efebe 100644 --- a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js +++ b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js @@ -144,23 +144,6 @@ describe('RelatedIssuableItem', () => { expect(wrapper.find(IssueDueDate).props('closed')).toBe(true); }); - - it('should not contain the `.text-danger` css class for overdue issue that is closed', async () => { - mountComponent({ - props: { - ...props, - closedAt: '2018-12-01T00:00:00.00Z', - }, - }); - await wrapper.vm.$nextTick(); - - expect(wrapper.find(IssueDueDate).find('.board-card-info-icon').classes('text-danger')).toBe( - false, - ); - expect(wrapper.find(IssueDueDate).find('.board-card-info-text').classes('text-danger')).toBe( - false, - ); - }); }); describe('token assignees', () => { |