From 311e3902e9ffe1218a01ed90b455e878a555e67d Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Apr 2024 12:15:12 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .gitlab/ci/frontend.gitlab-ci.yml | 1 + .gitlab/ci/rules.gitlab-ci.yml | 2 +- .gitlab/ci/test-on-gdk/main.gitlab-ci.yml | 2 +- .rubocop_todo/gitlab/namespaced_class.yml | 1 - .rubocop_todo/layout/line_length.yml | 1 - .rubocop_todo/rspec/feature_category.yml | 1 - .rubocop_todo/rspec/verified_doubles.yml | 1 - GITALY_SERVER_VERSION | 2 +- Rakefile | 2 + .../selective_code_owner_removals_updated.yml | 10 ++ ...e_vulnerability_jira_issue_via_graphql.yml | 8 -- ...eprecation-project_page_group_settings.yml | 18 +++ doc/administration/audit_event_types.md | 1 + doc/administration/logs/index.md | 1 - doc/administration/raketasks/github_import.md | 55 +------- .../blueprints/cloud_connector/index.md | 2 +- doc/update/deprecations.md | 20 +++ .../github_import/sequential_importer.rb | 74 ---------- lib/tasks/import.rake | 133 ------------------ scripts/verify-tff-mapping | 6 - spec/lib/gitlab/git/repository_spec.rb | 17 ++- .../github_import/sequential_importer_spec.rb | 64 --------- .../helpers/user_with_namespace_shim.yml | 1 - spec/support/rspec_order_todo.yml | 1 - spec/tasks/import_rake_spec.rb | 112 --------------- 25 files changed, 71 insertions(+), 465 deletions(-) create mode 100644 config/audit_events/types/selective_code_owner_removals_updated.yml delete mode 100644 config/feature_flags/development/create_vulnerability_jira_issue_via_graphql.yml create mode 100644 data/deprecations/18-0-deprecation-project_page_group_settings.yml delete mode 100644 lib/gitlab/github_import/sequential_importer.rb delete mode 100644 lib/tasks/import.rake delete mode 100644 spec/lib/gitlab/github_import/sequential_importer_spec.rb delete mode 100644 spec/tasks/import_rake_spec.rb diff --git a/.gitlab/ci/frontend.gitlab-ci.yml b/.gitlab/ci/frontend.gitlab-ci.yml index ff0c0b40a5e..2eb6e9428b3 100644 --- a/.gitlab/ci/frontend.gitlab-ci.yml +++ b/.gitlab/ci/frontend.gitlab-ci.yml @@ -251,6 +251,7 @@ graphql-schema-dump: .vue3: variables: VUE_VERSION: 3 + NODE_OPTIONS: --max-old-space-size=7680 allow_failure: true .jest-base: diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 756aebe646f..a61357488ba 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -3268,7 +3268,7 @@ when: never - <<: *if-merge-request-labels-pipeline-expedite when: never - - !reference [".releases:rules:canonical-dot-com-gitlab-stable-branch-only-setup-test-env", rules] + - !reference [".releases:rules:canonical-dot-com-gitlab-stable-branch-only", rules] ################### # Benchmark rules # diff --git a/.gitlab/ci/test-on-gdk/main.gitlab-ci.yml b/.gitlab/ci/test-on-gdk/main.gitlab-ci.yml index 0b96d8c875f..179460b1a2b 100644 --- a/.gitlab/ci/test-on-gdk/main.gitlab-ci.yml +++ b/.gitlab/ci/test-on-gdk/main.gitlab-ci.yml @@ -75,7 +75,7 @@ include: - echo -e "\e[0Ksection_start:`date +%s`:install_gems[collapsed=true]\r\e[0KInstall gems" - source scripts/utils.sh - source scripts/rspec_helpers.sh - - cd qa && bundle config set --local without 'development' && bundle install + - cd qa && bundle install - echo -e "\e[0Ksection_end:`date +%s`:install_gems\r\e[0K" script: - export QA_COMMAND="bundle exec bin/qa ${QA_SCENARIO:=Test::Instance::All} $GDK_URL $GITLAB_QA_OPTS -- $QA_TESTS --order random --force-color --format documentation --format QA::Support::JsonFormatter --out tmp/rspec-${CI_JOB_ID}-\${QA_RSPEC_RETRIED:-false}.json" diff --git a/.rubocop_todo/gitlab/namespaced_class.yml b/.rubocop_todo/gitlab/namespaced_class.yml index f4b41938e71..d2a9b32270a 100644 --- a/.rubocop_todo/gitlab/namespaced_class.yml +++ b/.rubocop_todo/gitlab/namespaced_class.yml @@ -1223,7 +1223,6 @@ Gitlab/NamespacedClass: - 'lib/gitlab/workhorse.rb' - 'lib/gitlab/zoom_link_extractor.rb' - 'lib/tasks/gitlab/seed/group_seed.rake' - - 'lib/tasks/import.rake' - 'lib/tasks/tokens.rake' - 'lib/uploaded_file.rb' - 'lib/version_check.rb' diff --git a/.rubocop_todo/layout/line_length.yml b/.rubocop_todo/layout/line_length.yml index 65c36a16a58..d6be482ef94 100644 --- a/.rubocop_todo/layout/line_length.yml +++ b/.rubocop_todo/layout/line_length.yml @@ -2702,7 +2702,6 @@ Layout/LineLength: - 'lib/tasks/gitlab/usage_data.rake' - 'lib/tasks/gitlab/user_management.rake' - 'lib/tasks/gitlab/workhorse.rake' - - 'lib/tasks/import.rake' - 'lib/tasks/migrate/schema_check.rake' - 'lib/tasks/tanuki_emoji.rake' - 'lib/tasks/test.rake' diff --git a/.rubocop_todo/rspec/feature_category.yml b/.rubocop_todo/rspec/feature_category.yml index 6baa1cbeba2..8fdcc7a4b5d 100644 --- a/.rubocop_todo/rspec/feature_category.yml +++ b/.rubocop_todo/rspec/feature_category.yml @@ -3407,7 +3407,6 @@ RSpec/FeatureCategory: - 'spec/lib/gitlab/github_import/representation/to_hash_spec.rb' - 'spec/lib/gitlab/github_import/representation/user_spec.rb' - 'spec/lib/gitlab/github_import/representation_spec.rb' - - 'spec/lib/gitlab/github_import/sequential_importer_spec.rb' - 'spec/lib/gitlab/github_import/settings_spec.rb' - 'spec/lib/gitlab/github_import/single_endpoint_notes_importing_spec.rb' - 'spec/lib/gitlab/github_import/user_finder_spec.rb' diff --git a/.rubocop_todo/rspec/verified_doubles.yml b/.rubocop_todo/rspec/verified_doubles.yml index 5435a5fd641..367d0c31ca1 100644 --- a/.rubocop_todo/rspec/verified_doubles.yml +++ b/.rubocop_todo/rspec/verified_doubles.yml @@ -533,7 +533,6 @@ RSpec/VerifiedDoubles: - 'spec/lib/gitlab/github_import/parallel_scheduling_spec.rb' - 'spec/lib/gitlab/github_import/representation/diff_note_spec.rb' - 'spec/lib/gitlab/github_import/representation/to_hash_spec.rb' - - 'spec/lib/gitlab/github_import/sequential_importer_spec.rb' - 'spec/lib/gitlab/github_import/user_finder_spec.rb' - 'spec/lib/gitlab/github_import_spec.rb' - 'spec/lib/gitlab/gon_helper_spec.rb' diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 247ca1ebb6c..8cbe6e7c2e3 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -0f9df77f1f480d5f4087cc9400c13dcbab2e174e +68c90c5cfa83c24cd706a206d13ff1e5be1c4f44 diff --git a/Rakefile b/Rakefile index 36176721e13..6b9a357fb7d 100755 --- a/Rakefile +++ b/Rakefile @@ -21,3 +21,5 @@ Knapsack.load_tasks if defined?(Knapsack) require 'gitlab-dangerfiles' Gitlab::Dangerfiles.load_tasks + +require 'rainbow/ext/string' diff --git a/config/audit_events/types/selective_code_owner_removals_updated.yml b/config/audit_events/types/selective_code_owner_removals_updated.yml new file mode 100644 index 00000000000..06cf99cf38e --- /dev/null +++ b/config/audit_events/types/selective_code_owner_removals_updated.yml @@ -0,0 +1,10 @@ +--- +name: selective_code_owner_removals_updated +description: Event triggered when selective code owner removal is updated +introduced_by_issue: https://gitlab.com/gitlab-org/gitlab/-/issues/327562 +introduced_by_mr: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148743 +feature_category: code_review_workflow +milestone: '17.0' +saved_to_database: true +streamed: true +scope: [Project] diff --git a/config/feature_flags/development/create_vulnerability_jira_issue_via_graphql.yml b/config/feature_flags/development/create_vulnerability_jira_issue_via_graphql.yml deleted file mode 100644 index 2198a905d2d..00000000000 --- a/config/feature_flags/development/create_vulnerability_jira_issue_via_graphql.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: create_vulnerability_jira_issue_via_graphql -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60593 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329780 -milestone: '13.12' -type: development -group: group::threat insights -default_enabled: true diff --git a/data/deprecations/18-0-deprecation-project_page_group_settings.yml b/data/deprecations/18-0-deprecation-project_page_group_settings.yml new file mode 100644 index 00000000000..09c3cedfe33 --- /dev/null +++ b/data/deprecations/18-0-deprecation-project_page_group_settings.yml @@ -0,0 +1,18 @@ +- title: "Project page in group settings is deprecated" + announcement_milestone: "17.0" + end_of_support_milestone: "17.9" + removal_milestone: "18.0" + breaking_change: false + reporter: lohrc + stage: data_stores + issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/443347 + impact: [low] + scope: [group] + tiers: [core, premium, ultimate] + body: | # (required) Don't change this line. + Group owners can access a project page in the group settings that lists the projects the group contains, with options to create, edit or delete a project, as well as a link to the Members page for each project. + All of this functionality is available on the group overview page and the respective Member pages of the projects. + Due to low usage of the project page in the group settings and its limited accessibility, this page will be deprecated. + This change affects only the user interface. The underlying API will remain available, so project creation, edits, and deletions can still be performed using the [Projects API](https://docs.gitlab.com/ee/api/projects.html). + In 17.9, we will implement a redirect to the group overview page from this page. + The project page will be removed entirely from the group settings in 18.0. diff --git a/doc/administration/audit_event_types.md b/doc/administration/audit_event_types.md index e40fa7f619f..43a49732e82 100644 --- a/doc/administration/audit_event_types.md +++ b/doc/administration/audit_event_types.md @@ -108,6 +108,7 @@ Audit event types belong to the following product categories. | [`project_merge_requests_template_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/84624) | Whenever a MR template is updated for a project, this audit event is created| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [15.0](https://gitlab.com/gitlab-org/gitlab/-/issues/355805) | Project | | [`project_remove_source_branch_after_merge_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/83922) | Create this audit event whenever a project has its setting to remove branches after merges modified| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [14.10](https://gitlab.com/gitlab-org/gitlab/-/issues/301124) | Project | | [`project_reset_approvals_on_push_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66234) | Create this audit event whenever a project has its setting on whether approvals are reset on a push is updated| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [14.2](https://gitlab.com/gitlab-org/gitlab/-/issues/336211) | Project | +| [`selective_code_owner_removals_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148743) | Event triggered when selective code owner removal is updated| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [17.0](https://gitlab.com/gitlab-org/gitlab/-/issues/327562) | Project | ### Code suggestions diff --git a/doc/administration/logs/index.md b/doc/administration/logs/index.md index 5e1a85801c1..06750b6c3f6 100644 --- a/doc/administration/logs/index.md +++ b/doc/administration/logs/index.md @@ -62,7 +62,6 @@ Some of these services have their own environment variables to override the log | GitLab Cleanup | `INFO` | `DEBUG` | | GitLab Doctor | `INFO` | `VERBOSE` | | GitLab Export | `INFO` | `EXPORT_DEBUG` | -| GitLab Geo | `INFO` | | | GitLab Import | `INFO` | `IMPORT_DEBUG` | | GitLab QA Runtime | `INFO` | `QA_LOG_LEVEL` | | Google APIs | `INFO` | | diff --git a/doc/administration/raketasks/github_import.md b/doc/administration/raketasks/github_import.md index 69b8912fcd5..296dd95ef7a 100644 --- a/doc/administration/raketasks/github_import.md +++ b/doc/administration/raketasks/github_import.md @@ -4,7 +4,7 @@ group: Distribution info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments --- -# GitHub import Rake task (deprecated) +# GitHub import Rake task (removed) DETAILS: **Tier:** Free, Premium, Ultimate @@ -13,55 +13,4 @@ DETAILS: > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/390690) in GitLab 15.9, Rake task no longer automatically creates namespaces or groups that don't exist. > - Requirement for Maintainer role instead of Developer role introduced in GitLab 16.0 and backported to GitLab 15.11.1 and GitLab 15.10.5. -WARNING: -This feature was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/428225) in GitLab 16.6 and is planned for -removal in GitLab 17.0. Use the [GitHub import feature](../../user/project/import/github.md) instead. - -To retrieve and import GitHub repositories, you need a [GitHub personal access token](https://github.com/settings/tokens). -A username should be passed as the second argument to the Rake task, -which becomes the owner of the project. You can resume an import -with the same command. - -Bear in mind that the syntax is very specific. Remove any spaces in the argument block and -before/after the brackets. Also, some shells (for example, Zsh) can interpret the open/close brackets -(`[]`) separately. You may want to either escape the brackets or use double quotes. - -You can only import repositories that are in the namespace of the owner of the GitHub personal access token being used to import. For more information, see -[issue 424105](https://gitlab.com/gitlab-org/gitlab/-/issues/424105). - -Prerequisites: - -- At least the Maintainer role on the destination group to import to. - -## Rate limit - -If the GitHub [rate limit](https://docs.github.com/en/rest/rate-limit) is reached while -importing, the importing process waits (`sleep()`) until it can continue importing. - -## Importing multiple projects - -To import a project from the list of your GitHub projects available: - -```shell -# Omnibus installations -sudo gitlab-rake "import:github[access_token,root,foo/bar]" - -# Installations from source -bundle exec rake "import:github[access_token,root,foo/bar]" RAILS_ENV=production -``` - -In this case, `access_token` is your GitHub personal access token, `root` -is your GitLab username, and `foo/bar` is the new GitLab namespace/project -created from your GitHub project. Subgroups are also possible: `foo/foo/bar`. - -## Importing a single project - -To import a specific GitHub project (named `foo/github_repo` here): - -```shell -# Omnibus installations -sudo gitlab-rake "import:github[access_token,root,foo/bar,foo/github_repo]" - -# Installations from source -bundle exec rake "import:github[access_token,root,foo/bar,foo/github_repo]" RAILS_ENV=production -``` +This feature was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/134296) in GitLab 16.6 and [removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147182) in GitLab 17.0. Use the [GitHub import feature](../../user/project/import/github.md) instead. diff --git a/doc/architecture/blueprints/cloud_connector/index.md b/doc/architecture/blueprints/cloud_connector/index.md index 70f9b19f37d..3df8b9cd57a 100644 --- a/doc/architecture/blueprints/cloud_connector/index.md +++ b/doc/architecture/blueprints/cloud_connector/index.md @@ -1,5 +1,5 @@ --- -status: ongoing +status: implemented creation-date: "2023-09-28" authors: [ "@mkaeppler" ] coach: "@ayufan" diff --git a/doc/update/deprecations.md b/doc/update/deprecations.md index 87a2f3aaae2..77be4e3d1b8 100644 --- a/doc/update/deprecations.md +++ b/doc/update/deprecations.md @@ -231,6 +231,26 @@ Offset-based pagination for the [List registry repository tags](https://docs.git +
+ +### Project page in group settings is deprecated + +
+- Announced in GitLab 17.0 +- End of Support in GitLab 17.9 +- Removal in GitLab 18.0 +- To discuss this change or learn more, see the [deprecation issue](https://gitlab.com/gitlab-org/gitlab/-/issues/443347). +
+ +Group owners can access a project page in the group settings that lists the projects the group contains, with options to create, edit or delete a project, as well as a link to the Members page for each project. +All of this functionality is available on the group overview page and the respective Member pages of the projects. +Due to low usage of the project page in the group settings and its limited accessibility, this page will be deprecated. +This change affects only the user interface. The underlying API will remain available, so project creation, edits, and deletions can still be performed using the [Projects API](https://docs.gitlab.com/ee/api/projects.html). +In 17.9, we will implement a redirect to the group overview page from this page. +The project page will be removed entirely from the group settings in 18.0. + +
+
### Registration tokens and server-side runner arguments in `POST /api/v4/runners` endpoint diff --git a/lib/gitlab/github_import/sequential_importer.rb b/lib/gitlab/github_import/sequential_importer.rb deleted file mode 100644 index ab37bc92ee7..00000000000 --- a/lib/gitlab/github_import/sequential_importer.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module GithubImport - # The SequentialImporter imports a GitHub project in a single thread, - # without using Sidekiq. This makes it useful for testing purposes as well - # as Rake tasks, but it should be avoided for anything else in favour of the - # parallel importer. - class SequentialImporter - attr_reader :project, :client - - SEQUENTIAL_IMPORTERS = [ - Importer::LabelsImporter, - Importer::MilestonesImporter, - Importer::ReleasesImporter - ].freeze - - PARALLEL_IMPORTERS = [ - Importer::ProtectedBranchesImporter, - Importer::PullRequestsImporter, - Importer::IssuesImporter, - Importer::DiffNotesImporter, - Importer::NotesImporter, - Importer::LfsObjectsImporter - ].freeze - - # project - The project to import the data into. - # token - The token to use for the GitHub API. - # host - The GitHub hostname. If nil, github.com will be used. - def initialize(project, token: nil, host: nil) - @project = project - @client = GithubImport - .new_client_for(project, token: token, host: host, parallel: false) - end - - def execute - metrics.track_start_import - - begin - Importer::RepositoryImporter.new(project, client).execute - - SEQUENTIAL_IMPORTERS.each do |klass| - klass.new(project, client).execute - end - - rescue StandardError => e - Gitlab::Import::ImportFailureService.track( - project_id: project.id, - error_source: self.class.name, - exception: e, - fail_import: true, - metrics: true - ) - - raise(e) - end - - PARALLEL_IMPORTERS.each do |klass| - klass.new(project, client, parallel: false).execute - end - - metrics.track_finished_import - - true - end - - private - - def metrics - @metrics ||= Gitlab::Import::Metrics.new(:github_importer, project) - end - end - end -end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake deleted file mode 100644 index e59aa409d58..00000000000 --- a/lib/tasks/import.rake +++ /dev/null @@ -1,133 +0,0 @@ -# frozen_string_literal: true - -class GithubImport - def self.run!(...) - new(...).run! - end - - def initialize(token, gitlab_username, project_path, extras) - @options = { token: token } - @project_path = project_path - @current_user = UserFinder.new(gitlab_username).find_by_username - - raise "GitLab user #{gitlab_username} not found. Please specify a valid username." unless @current_user - - @github_repo = extras.empty? ? nil : extras.first - end - - def run! - @repo = GithubRepos - .new(@options[:token], @current_user, @github_repo) - .choose_one! - - raise 'No repo found!' unless @repo - - show_warning! - - @project = Project.find_by_full_path(@project_path) || new_project - - import! - end - - private - - def show_warning! - puts "This will import GitHub #{@repo[:full_name].bright} into GitLab #{@project_path.bright} as #{@current_user.name}" - puts 'Permission checks are ignored. Press any key to continue.'.color(:red) - - $stdin.getch - - puts 'Starting the import (this could take a while)'.color(:green) - end - - def import! - @project.import_state.force_start - - timings = Benchmark.measure do - Gitlab::GithubImport::SequentialImporter - .new(@project, token: @options[:token]) - .execute - end - - @project.after_import - puts "Import finished. Timings: #{timings}".color(:green) - end - - def new_project - namespace_path, _sep, project_name = @project_path.rpartition('/') - target_namespace = Namespace.find_by_full_path(namespace_path) - - raise s_('GithubImport|Namespace or group to import repository into does not exist.') unless target_namespace - - Project.transaction do - project = Projects::CreateService.new( - @current_user, - name: project_name, - path: project_name, - description: @repo[:description], - namespace_id: target_namespace.id, - visibility_level: visibility_level, - skip_wiki: @repo[:has_wiki] - ).execute - - project.update!( - import_type: 'github', - import_source: @repo[:full_name], - import_url: @repo[:clone_url].sub('://', "://#{@options[:token]}@") - ) - - project - end - end - - def visibility_level - @repo[:private] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.current_application_settings.default_project_visibility - end -end - -class GithubRepos - def initialize(token, current_user, github_repo) - @client = Gitlab::GithubImport::Client.new(token) - @client.octokit.auto_paginate = true - - @current_user = current_user - @github_repo = github_repo - end - - def choose_one! - return found_github_repo if @github_repo - - repos.each do |repo| - print "ID: #{repo[:id].to_s.bright}".color(:green) - print "\tName: #{repo[:full_name]}\n".color(:green) - end - - print 'ID? '.bright - - repos.find { |repo| repo[:id] == repo_id } - end - - def found_github_repo - repos.find { |repo| repo[:full_name] == @github_repo } - end - - def repo_id - @repo_id ||= $stdin.gets.chomp.to_i - end - - def repos - @repos ||= @client.repos - end -end - -namespace :import do - require 'benchmark' - require 'rainbow/ext/string' - - desc 'GitLab | Import | Import a GitHub project - Example: import:github[ToKeN,root,root/blah,my/github_repo] (optional my/github_repo)' - task :github, [:token, :gitlab_username, :project_path] => :environment do |_t, args| - abort 'Project path must be: namespace(s)/project_name'.color(:red) unless args.project_path.include?('/') - - GithubImport.run!(args.token, args.gitlab_username, args.project_path, args.extras) - end -end diff --git a/scripts/verify-tff-mapping b/scripts/verify-tff-mapping index 3b7cd42b611..9a8f48aa402 100755 --- a/scripts/verify-tff-mapping +++ b/scripts/verify-tff-mapping @@ -259,12 +259,6 @@ tests = [ ] }, - { - explanation: 'Map FOSS rake tasks', - changed_file: 'lib/tasks/import.rake', - expected: ['spec/tasks/import_rake_spec.rb'] - }, - { explanation: 'Map EE rake tasks', changed_file: 'ee/lib/tasks/geo.rake', diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 932c557eab3..e37f5524de4 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -2556,9 +2556,13 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen end it 'can still access objects in the object pool' do - object_pool.link(repository) - new_commit_id = object_pool.repository.commit_files( - project.owner, + # Create a commit into a separate repository and fetch it into the object pool. + # Writing directly to an object pool fails as we don't support them in the + # authorization checks. Gitaly's pre-receive hook fails as a gl_repository is + # not set object pools. + source_project = create(:project, :repository) + new_commit_id = source_project.repository.commit_files( + source_project.owner, branch_name: object_pool.repository.root_ref, message: 'Add a file', actions: [{ @@ -2566,7 +2570,12 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen file_path: 'a.file', content: 'This is a file.' }] - ).newrev + ) + + # Fetch the new object into the object pool + Gitlab::GitalyClient::ObjectPoolService.new(object_pool).fetch(source_project.repository) + + object_pool.link(repository) expect(repository.commit(new_commit_id).id).to eq(new_commit_id) diff --git a/spec/lib/gitlab/github_import/sequential_importer_spec.rb b/spec/lib/gitlab/github_import/sequential_importer_spec.rb deleted file mode 100644 index 2b76f0e27c9..00000000000 --- a/spec/lib/gitlab/github_import/sequential_importer_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::GithubImport::SequentialImporter do - describe '#execute' do - let_it_be(:project) do - create(:project, import_url: 'http://t0ken@github.another-domain.com/repo-org/repo.git', import_type: 'github') - end - - subject(:importer) { described_class.new(project, token: 'foo') } - - it 'imports a project in sequence' do - expect_next_instance_of(Gitlab::Import::Metrics) do |instance| - expect(instance).to receive(:track_start_import) - expect(instance).to receive(:track_finished_import) - end - - expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance| - expect(instance).to receive(:execute) - end - - described_class::SEQUENTIAL_IMPORTERS.each do |klass| - instance = double(:instance) - - expect(klass).to receive(:new) - .with(project, importer.client) - .and_return(instance) - - expect(instance).to receive(:execute) - end - - described_class::PARALLEL_IMPORTERS.each do |klass| - instance = double(:instance) - - expect(klass).to receive(:new) - .with(project, importer.client, parallel: false) - .and_return(instance) - - expect(instance).to receive(:execute) - end - - expect(importer.execute).to eq(true) - end - - it 'raises an error' do - exception = StandardError.new('_some_error_') - - expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |importer| - expect(importer).to receive(:execute).and_raise(exception) - end - expect(Gitlab::Import::ImportFailureService).to receive(:track) - .with( - project_id: project.id, - exception: exception, - error_source: described_class.name, - fail_import: true, - metrics: true - ).and_call_original - - expect { importer.execute }.to raise_error(StandardError) - end - end -end diff --git a/spec/support/helpers/user_with_namespace_shim.yml b/spec/support/helpers/user_with_namespace_shim.yml index aaf2b99f7ef..5f7f69f9407 100644 --- a/spec/support/helpers/user_with_namespace_shim.yml +++ b/spec/support/helpers/user_with_namespace_shim.yml @@ -977,7 +977,6 @@ - spec/services/work_items/update_service_spec.rb - spec/tasks/gitlab/backup_rake_spec.rb - spec/tasks/gitlab/check_rake_spec.rb -- spec/tasks/import_rake_spec.rb - spec/views/layouts/header/_new_dropdown.haml_spec.rb - spec/views/layouts/profile.html.haml_spec.rb - spec/views/profiles/preferences/show.html.haml_spec.rb diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml index c103a96552a..069c8cc6375 100644 --- a/spec/support/rspec_order_todo.yml +++ b/spec/support/rspec_order_todo.yml @@ -6020,7 +6020,6 @@ - './spec/lib/gitlab/github_import/representation_spec.rb' - './spec/lib/gitlab/github_import/representation/to_hash_spec.rb' - './spec/lib/gitlab/github_import/representation/user_spec.rb' -- './spec/lib/gitlab/github_import/sequential_importer_spec.rb' - './spec/lib/gitlab/github_import/single_endpoint_notes_importing_spec.rb' - './spec/lib/gitlab/github_import_spec.rb' - './spec/lib/gitlab/github_import/user_finder_spec.rb' diff --git a/spec/tasks/import_rake_spec.rb b/spec/tasks/import_rake_spec.rb deleted file mode 100644 index ecc5a27d732..00000000000 --- a/spec/tasks/import_rake_spec.rb +++ /dev/null @@ -1,112 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'import:github rake tasks', feature_category: :importers do - before do - Rake.application.rake_require 'tasks/import' - end - - describe ':import' do - let(:user) { create(:user) } - let(:user_name) { user.username } - let(:github_repo) { 'github_user/repo' } - let(:target_namespace) { user.namespace_path } - let(:project_path) { "#{target_namespace}/project_name" } - - before do - allow($stdin).to receive(:getch) - - stub_request(:get, 'https://api.github.com/user/repos?per_page=100') - .to_return( - status: 200, - body: [{ id: 1, full_name: 'github_user/repo', clone_url: 'https://github.com/user/repo.git' }].to_json, - headers: { 'Content-Type' => 'application/json' } - ) - end - - context 'when importing a single project' do - subject(:import_task) { run_rake_task('import:github', 'token', user_name, project_path, github_repo) } - - context 'when all inputs are correct' do - it 'imports a repository' do - expect_next_instance_of(Gitlab::GithubImport::SequentialImporter) do |importer| - expect(importer).to receive(:execute) - end - - expect_next_instance_of(Project) do |project| - expect(project).to receive(:after_import) - end - - import_task - end - end - - context 'when project path is invalid' do - let(:project_path) { target_namespace } - - it 'aborts with an error' do - expect { import_task }.to raise_error(SystemExit, 'Project path must be: namespace(s)/project_name') - end - end - - context 'when user is not found' do - let(:user_name) { 'unknown_user' } - - it 'aborts with an error' do - expect { import_task }.to raise_error("GitLab user #{user_name} not found. Please specify a valid username.") - end - end - - context 'when github repo is not found' do - let(:github_repo) { 'github_user/unknown_repo' } - - it 'aborts with an error' do - expect { import_task }.to raise_error('No repo found!') - end - end - - context 'when namespace to import repo into does not exists' do - let(:target_namespace) { 'unknown_namespace_path' } - - it 'aborts with an error' do - expect do - import_task - end.to raise_error(s_('GithubImport|Namespace or group to import repository into does not exist.')) - end - end - end - - context 'when importing multiple projects' do - subject(:import_task) { run_rake_task('import:github', 'token', user_name, project_path) } - - context 'when user enters github repo id that exists' do - before do - allow($stdin).to receive(:gets).and_return("1\n") - end - - it 'imports a repository' do - expect_next_instance_of(Gitlab::GithubImport::SequentialImporter) do |importer| - expect(importer).to receive(:execute) - end - - expect_next_instance_of(Project) do |project| - expect(project).to receive(:after_import) - end - - import_task - end - end - - context 'when user enters github repo id that does not exists' do - before do - allow($stdin).to receive(:gets).and_return("2\n") - end - - it 'aborts with an error' do - expect { import_task }.to raise_error('No repo found!') - end - end - end - end -end