diff options
79 files changed, 925 insertions, 208 deletions
diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index df81d05eec1..ea4feb3552e 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -173,7 +173,7 @@ /.gitlab/CODEOWNERS @gl-quality/eng-prod Dangerfile @gl-quality/eng-prod /danger/ @gl-quality/eng-prod -/lib/gitlab/danger/ @gl-quality/eng-prod +/tooling/danger/ @gl-quality/eng-prod /scripts/ @gl-quality/eng-prod /scripts/frontend/ @gl-quality/eng-prod @gitlab-org/maintainers/frontend /scripts/review_apps/seed-dast-test-data.sh @dappelt @ngeorge1 @gl-quality/eng-prod diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml index a2a16424f4a..6de8cdfd9b0 100644 --- a/.gitlab/ci/rails.gitlab-ci.yml +++ b/.gitlab/ci/rails.gitlab-ci.yml @@ -433,6 +433,8 @@ rspec:deprecations: variables: SETUP_DB: "false" script: + - grep -h -R "keyword" deprecations/ | awk '{$1=$1};1' | sort | uniq -c | sort + - grep -R "keyword" deprecations/ | wc - run_timed_command "bundle exec rubocop --only Lint/LastKeywordArgument --parallel" artifacts: expire_in: 31d diff --git a/.rubocop.yml b/.rubocop.yml index 4a0cd9579e6..7a4b53b5aa5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -78,21 +78,7 @@ Style/AccessModifierDeclarations: # Frozen String Literal Style/FrozenStringLiteralComment: Enabled: true - Exclude: - - 'config.ru' - - 'Dangerfile' - - 'Gemfile' - - 'Rakefile' - - 'app/views/**/*' - - 'config/**/*' - - 'danger/**/*' - - 'db/**/*' - - 'ee/db/**/*' - - 'ee/lib/tasks/**/*' - - 'lib/tasks/**/*' - - 'qa/**/*' - - 'rubocop/**/*' - - 'scripts/**/*' + EnforcedStyle: always_true RSpec/FilePath: Exclude: @@ -256,7 +242,7 @@ Gitlab/Json: - 'scripts/**/*' - 'lib/rspec_flaky/**/*' - 'lib/quality/**/*' - - 'lib/gitlab/danger/**/*' + - 'tooling/danger/**/*' Gitlab/AvoidUploadedFileFromParams: Enabled: true diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index dc8aee88665..d88d705a012 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -2721,3 +2721,315 @@ Gitlab/NamespacedClass: - 'spec/support/sidekiq_middleware.rb' - 'spec/tasks/gitlab/task_helpers_spec.rb' - 'spec/uploaders/object_storage_spec.rb' + +# WIP: https://gitlab.com/gitlab-org/gitlab/-/issues/299105 +Style/FrozenStringLiteralComment: + Exclude: + - 'Gemfile' + - 'Rakefile' + - 'app/views/dashboard/issues.atom.builder' + - 'app/views/dashboard/projects/index.atom.builder' + - 'app/views/events/_event.atom.builder' + - 'app/views/groups/issues.atom.builder' + - 'app/views/groups/show.atom.builder' + - 'app/views/issues/_issue.atom.builder' + - 'app/views/issues/_issues_calendar.ics.ruby' + - 'app/views/layouts/xml.atom.builder' + - 'app/views/projects/commits/_commit.atom.builder' + - 'app/views/projects/commits/show.atom.builder' + - 'app/views/projects/issues/index.atom.builder' + - 'app/views/projects/show.atom.builder' + - 'app/views/projects/tags/_tag.atom.builder' + - 'app/views/projects/tags/index.atom.builder' + - 'app/views/users/show.atom.builder' + - 'bin/secpick' + - 'config.ru' + - 'config/boot.rb' + - 'config/environment.rb' + - 'config/environments/development.rb' + - 'config/environments/production.rb' + - 'config/environments/test.rb' + - 'config/initializers/01_secret_token.rb' + - 'config/initializers/0_acts_as_taggable.rb' + - 'config/initializers/0_inject_feature_flags.rb' + - 'config/initializers/0_post_deployment_migrations.rb' + - 'config/initializers/1_settings.rb' + - 'config/initializers/2_gitlab.rb' + - 'config/initializers/5_backend.rb' + - 'config/initializers/6_validations.rb' + - 'config/initializers/7_prometheus_metrics.rb' + - 'config/initializers/7_redis.rb' + - 'config/initializers/8_devise.rb' + - 'config/initializers/8_gitaly.rb' + - 'config/initializers/9_fast_gettext.rb' + - 'config/initializers/action_dispatch_http_mime_negotiation.rb' + - 'config/initializers/action_mailer_hooks.rb' + - 'config/initializers/active_record_data_types.rb' + - 'config/initializers/active_record_ping.rb' + - 'config/initializers/active_record_preloader.rb' + - 'config/initializers/active_record_schema_ignore_tables.rb' + - 'config/initializers/active_record_table_definition.rb' + - 'config/initializers/ar_speed_up_migration_checking.rb' + - 'config/initializers/asset_proxy_settings.rb' + - 'config/initializers/attr_encrypted_no_db_connection.rb' + - 'config/initializers/backtrace_silencers.rb' + - 'config/initializers/batch_loader.rb' + - 'config/initializers/bootstrap_form.rb' + - 'config/initializers/bullet.rb' + - 'config/initializers/cluster_events_before_phased_restart.rb' + - 'config/initializers/console_message.rb' + - 'config/initializers/cookies_serializer.rb' + - 'config/initializers/date_time_formats.rb' + - 'config/initializers/default_url_options.rb' + - 'config/initializers/deprecations.rb' + - 'config/initializers/direct_upload_support.rb' + - 'config/initializers/doorkeeper.rb' + - 'config/initializers/doorkeeper_openid_connect.rb' + - 'config/initializers/etag_caching.rb' + - 'config/initializers/fill_shards.rb' + - 'config/initializers/fix_local_cache_middleware.rb' + - 'config/initializers/fog_google_https_private_urls.rb' + - 'config/initializers/forbid_sidekiq_in_transactions.rb' + - 'config/initializers/gettext_rails_i18n_patch.rb' + - 'config/initializers/gitlab_kas_secret.rb' + - 'config/initializers/gitlab_shell_secret_token.rb' + - 'config/initializers/gitlab_workhorse_secret.rb' + - 'config/initializers/go_get.rb' + - 'config/initializers/grpc.rb' + - 'config/initializers/hamlit.rb' + - 'config/initializers/health_check.rb' + - 'config/initializers/http_hostname_override.rb' + - 'config/initializers/kaminari_active_record_relation_methods_with_limit.rb' + - 'config/initializers/kaminari_config.rb' + - 'config/initializers/lograge.rb' + - 'config/initializers/mail_encoding_patch.rb' + - 'config/initializers/mime_types.rb' + - 'config/initializers/mini_magick.rb' + - 'config/initializers/new_framework_defaults.rb' + - 'config/initializers/octokit.rb' + - 'config/initializers/omniauth.rb' + - 'config/initializers/peek.rb' + - 'config/initializers/postgresql_cte.rb' + - 'config/initializers/premailer.rb' + - 'config/initializers/query_limiting.rb' + - 'config/initializers/rack_lineprof.rb' + - 'config/initializers/relative_naming_ci_namespace.rb' + - 'config/initializers/request_context.rb' + - 'config/initializers/request_profiler.rb' + - 'config/initializers/routing_draw.rb' + - 'config/initializers/sentry.rb' + - 'config/initializers/server_uptime.rb' + - 'config/initializers/session_store.rb' + - 'config/initializers/sherlock.rb' + - 'config/initializers/sprockets.rb' + - 'config/initializers/static_files.rb' + - 'config/initializers/time_zone.rb' + - 'config/initializers/trusted_proxies.rb' + - 'config/initializers/warden.rb' + - 'config/initializers/workhorse_multipart.rb' + - 'config/initializers/wrap_parameters.rb' + - 'config/initializers/zz_metrics.rb' + - 'config/initializers_before_autoloader/000_inflections.rb' + - 'config/object_store_settings.rb' + - 'config/routes.rb' + - 'config/routes/admin.rb' + - 'config/routes/api.rb' + - 'config/routes/dashboard.rb' + - 'config/routes/development.rb' + - 'config/routes/explore.rb' + - 'config/routes/git_http.rb' + - 'config/routes/google_api.rb' + - 'config/routes/help.rb' + - 'config/routes/import.rb' + - 'config/routes/legacy_builds.rb' + - 'config/routes/repository.rb' + - 'config/routes/sherlock.rb' + - 'config/routes/sidekiq.rb' + - 'config/routes/snippets.rb' + - 'config/routes/uploads.rb' + - 'config/routes/wiki.rb' + - 'config/smime_signature_settings.rb' + - 'config/spring.rb' + - 'danger/changes_size/Dangerfile' + - 'danger/metadata/Dangerfile' + - 'db/migrate/20190325080727_truncate_user_fullname.rb' + - 'db/migrate/20190828110802_add_not_null_constraints_to_prometheus_metrics_y_label_and_unit.rb' + - 'db/migrate/20190828172831_create_package_tag.rb' + - 'db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb' + - 'db/migrate/20191003195620_add_pendo_url_to_application_settings.rb' + - 'db/migrate/20191120200015_add_index_to_grafana_integrations.rb' + - 'db/migrate/20200229171700_create_custom_emojis.rb' + - 'db/migrate/20201004163918_remove_project_id_and_id_index_from_vulnerabilities_table.rb' + - 'db/migrate/20201214000000_change_mr_allow_maintainer_to_push_default.rb' + - 'db/optional_migrations/composite_primary_keys.rb' + - 'db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb' + - 'db/post_migrate/20201030121314_schedule_update_existing_users_that_require_two_factor_auth.rb' + - 'ee/db/fixtures/development/20_burndown.rb' + - 'ee/db/fixtures/development/20_vulnerabilities.rb' + - 'ee/db/fixtures/development/22_epics.rb' + - 'ee/db/geo/migrate/20170206203234_create_project_registry.rb' + - 'ee/db/geo/migrate/20170223033541_create_file_registry.rb' + - 'ee/db/geo/migrate/20170302005747_add_index_to_project_id_on_project_registry.rb' + - 'ee/db/geo/migrate/20170526214010_convert_file_bytes_to_int64.rb' + - 'ee/db/geo/migrate/20170605154253_create_event_log_state.rb' + - 'ee/db/geo/migrate/20170606155045_add_needs_resync_to_project_registry.rb' + - 'ee/db/geo/migrate/20170614201943_add_last_wiki_synced_at_to_project_registry.rb' + - 'ee/db/geo/migrate/20170627195211_add_index_to_project_registry.rb' + - 'ee/db/geo/migrate/20170906174622_remove_duplicates_from_project_registry.rb' + - 'ee/db/geo/migrate/20170906182752_add_unique_index_to_project_id_on_project_registry.rb' + - 'ee/db/geo/migrate/20171005045404_remove_file_uploads_from_registry.rb' + - 'ee/db/geo/migrate/20171009162208_add_file_registry_success.rb' + - 'ee/db/geo/migrate/20171009162209_add_file_registry_success_index.rb' + - 'ee/db/geo/migrate/20171101105200_add_retry_count_fields_to_registries.rb' + - 'ee/db/geo/migrate/20171115143841_add_last_sync_failure_to_project_registry.rb' + - 'ee/db/geo/migrate/20180201154345_add_repository_verification_to_project_registry.rb' + - 'ee/db/geo/migrate/20180314175612_add_partial_index_to_project_registy_verification_failure_columns.rb' + - 'ee/db/geo/migrate/20180315222132_add_partial_index_to_project_registy_checksum_columns.rb' + - 'ee/db/geo/migrate/20180321144947_change_repository_verification_checksum_to_sha.rb' + - 'ee/db/geo/migrate/20180322062741_migrate_ci_job_artifacts_to_separate_registry.rb' + - 'ee/db/geo/migrate/20180323182105_add_missing_on_primary_to_file_registry.rb' + - 'ee/db/geo/migrate/20180327071612_add_partial_index_to_project_registy_checksum_sha_columns.rb' + - 'ee/db/geo/migrate/20180402170913_add_missing_on_primary_to_job_artifact_registry..rb' + - 'ee/db/geo/migrate/20180405074130_add_partial_index_project_repository_verification.rb' + - 'ee/db/geo/migrate/20180412213305_add_index_to_artifact_id_on_job_artifact_registry.rb' + - 'ee/db/geo/migrate/20180419174834_add_checksum_mismatch_fields_to_project_registry.rb' + - 'ee/db/geo/migrate/20180419192603_add_indexes_to_checksum_mismatch_fields_on_project_registry.rb' + - 'ee/db/geo/migrate/20180427114641_add_repository_check_to_geo_project_registry.rb' + - 'ee/db/geo/migrate/20180510223634_set_resync_flag_for_retried_projects.rb' + - 'ee/db/geo/migrate/20180613184349_add_resync_was_scheduled_at_to_project_registry.rb' + - 'ee/db/geo/post_migrate/20180320011914_remove_last_verification_failed_columns_from_geo_project_registry.rb' + - 'ee/db/geo/post_migrate/20180320013929_remove_last_verification_at_columns_from_geo_project_registry.rb' + - 'ee/db/geo/post_migrate/20180326171626_remove_old_repository_verification_checksum_from_geo_project_registry.rb' + - 'ee/db/geo/post_migrate/20180331055706_delete_job_artifacts_from_file_registry.rb' + - 'ee/lib/tasks/geo.rake' + - 'ee/lib/tasks/geo/git.rake' + - 'ee/lib/tasks/geo/replication.rake' + - 'ee/lib/tasks/gitlab/db.rake' + - 'ee/lib/tasks/gitlab/elastic.rake' + - 'ee/lib/tasks/gitlab/elastic/test.rake' + - 'ee/lib/tasks/gitlab/geo.rake' + - 'ee/lib/tasks/gitlab/indexer.rake' + - 'ee/lib/tasks/gitlab/ldap.rake' + - 'ee/lib/tasks/gitlab/seed/insights.rake' + - 'ee/lib/tasks/gitlab/seed/metrics.rake' + - 'ee/lib/tasks/migrate/ldap.rake' + - 'lib/tasks/brakeman.rake' + - 'lib/tasks/cache.rake' + - 'lib/tasks/ci/cleanup.rake' + - 'lib/tasks/cleanup.rake' + - 'lib/tasks/config_lint.rake' + - 'lib/tasks/db_obsolete_ignored_columns.rake' + - 'lib/tasks/dev.rake' + - 'lib/tasks/downtime_check.rake' + - 'lib/tasks/eslint.rake' + - 'lib/tasks/file_hooks.rake' + - 'lib/tasks/frontend.rake' + - 'lib/tasks/gemojione.rake' + - 'lib/tasks/gitlab/artifacts/check.rake' + - 'lib/tasks/gitlab/artifacts/migrate.rake' + - 'lib/tasks/gitlab/backup.rake' + - 'lib/tasks/gitlab/bulk_add_permission.rake' + - 'lib/tasks/gitlab/check.rake' + - 'lib/tasks/gitlab/container_registry.rake' + - 'lib/tasks/gitlab/db.rake' + - 'lib/tasks/gitlab/doctor/secrets.rake' + - 'lib/tasks/gitlab/exclusive_lease.rake' + - 'lib/tasks/gitlab/external_diffs.rake' + - 'lib/tasks/gitlab/features.rake' + - 'lib/tasks/gitlab/generate_sample_prometheus_data.rake' + - 'lib/tasks/gitlab/git.rake' + - 'lib/tasks/gitlab/gitaly.rake' + - 'lib/tasks/gitlab/helpers.rake' + - 'lib/tasks/gitlab/import.rake' + - 'lib/tasks/gitlab/import_export.rake' + - 'lib/tasks/gitlab/info.rake' + - 'lib/tasks/gitlab/ldap.rake' + - 'lib/tasks/gitlab/lfs/check.rake' + - 'lib/tasks/gitlab/lfs/migrate.rake' + - 'lib/tasks/gitlab/list_repos.rake' + - 'lib/tasks/gitlab/packages/events.rake' + - 'lib/tasks/gitlab/packages/migrate.rake' + - 'lib/tasks/gitlab/pages.rake' + - 'lib/tasks/gitlab/praefect.rake' + - 'lib/tasks/gitlab/seed.rake' + - 'lib/tasks/gitlab/setup.rake' + - 'lib/tasks/gitlab/shell.rake' + - 'lib/tasks/gitlab/storage.rake' + - 'lib/tasks/gitlab/tcp_check.rake' + - 'lib/tasks/gitlab/test.rake' + - 'lib/tasks/gitlab/two_factor.rake' + - 'lib/tasks/gitlab/update_templates.rake' + - 'lib/tasks/gitlab/uploads/check.rake' + - 'lib/tasks/gitlab/uploads/migrate.rake' + - 'lib/tasks/gitlab/uploads/sanitize.rake' + - 'lib/tasks/gitlab/usage_data.rake' + - 'lib/tasks/gitlab/user_management.rake' + - 'lib/tasks/gitlab/web_hook.rake' + - 'lib/tasks/gitlab/workhorse.rake' + - 'lib/tasks/gitlab/x509/update.rake' + - 'lib/tasks/gitlab_danger.rake' + - 'lib/tasks/grape.rake' + - 'lib/tasks/haml-lint.rake' + - 'lib/tasks/import.rake' + - 'lib/tasks/karma.rake' + - 'lib/tasks/lint.rake' + - 'lib/tasks/migrate/composite_primary_keys.rake' + - 'lib/tasks/migrate/migrate_iids.rake' + - 'lib/tasks/migrate/setup_postgresql.rake' + - 'lib/tasks/pngquant.rake' + - 'lib/tasks/rubocop.rake' + - 'lib/tasks/scss-lint.rake' + - 'lib/tasks/setup.rake' + - 'lib/tasks/test.rake' + - 'lib/tasks/tokens.rake' + - 'qa/Gemfile' + - 'qa/Rakefile' + - 'qa/bin/qa' + - 'qa/bin/rubymine' + - 'qa/qa/fixtures/auto_devops_rack/Gemfile' + - 'qa/qa/fixtures/auto_devops_rack/Rakefile' + - 'qa/qa/fixtures/auto_devops_rack/config.ru' + - 'qa/qa/page/page_concern.rb' + - 'rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers.rb' + - 'rubocop/cop/gitlab/finder_with_find_by.rb' + - 'rubocop/cop/gitlab/keys-first-and-values-first.rb' + - 'rubocop/cop/gitlab/module_with_instance_variables.rb' + - 'rubocop/cop/gitlab/predicate_memoization.rb' + - 'rubocop/cop/migration/add_concurrent_foreign_key.rb' + - 'rubocop/cop/migration/add_concurrent_index.rb' + - 'rubocop/cop/migration/add_index.rb' + - 'rubocop/cop/migration/add_timestamps.rb' + - 'rubocop/cop/migration/datetime.rb' + - 'rubocop/cop/migration/hash_index.rb' + - 'rubocop/cop/migration/remove_column.rb' + - 'rubocop/cop/migration/remove_concurrent_index.rb' + - 'rubocop/cop/migration/remove_index.rb' + - 'rubocop/cop/migration/safer_boolean_column.rb' + - 'rubocop/cop/migration/timestamps.rb' + - 'rubocop/cop/migration/update_column_in_batches.rb' + - 'rubocop/cop/project_path_helper.rb' + - 'rubocop/migration_helpers.rb' + - 'rubocop/qa_helpers.rb' + - 'scripts/flaky_examples/detect-new-flaky-examples' + - 'scripts/flaky_examples/prune-old-flaky-examples' + - 'scripts/gather-test-memory-data' + - 'scripts/generate-gems-memory-metrics-static' + - 'scripts/generate-gems-size-metrics-static' + - 'scripts/generate-memory-metrics-on-boot' + - 'scripts/generate-test-mapping' + - 'scripts/gitaly-test-build' + - 'scripts/gitaly-test-spawn' + - 'scripts/gitaly_test.rb' + - 'scripts/insert-rspec-profiling-data' + - 'scripts/lint-rugged' + - 'scripts/merge-html-reports' + - 'scripts/merge-reports' + - 'scripts/merge-simplecov' + - 'scripts/no-ee-check' + - 'scripts/pack-test-mapping' + - 'scripts/static-analysis' + - 'scripts/sync-reports' + - 'scripts/unpack-test-mapping' + - 'scripts/update-feature-categories' + - 'scripts/used-feature-flags' + - 'scripts/verify-tff-mapping' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d60ab9b2fcc..92f4414d815 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -141,7 +141,7 @@ Lint/BinaryOperatorWithIdenticalOperands: - 'ee/spec/lib/ee/gitlab/application_context_spec.rb' - 'spec/helpers/visibility_level_helper_spec.rb' - 'spec/lib/gitlab/conan_token_spec.rb' - - 'spec/lib/gitlab/danger/sidekiq_queues_spec.rb' + - 'spec/tooling/danger/sidekiq_queues_spec.rb' - 'spec/lib/gitlab/git/conflict/parser_spec.rb' - 'spec/lib/gitlab/graphql/lazy_spec.rb' - 'spec/models/ci/build_trace_chunk_spec.rb' @@ -185,8 +185,8 @@ Lint/EmptyFile: # Cop supports --auto-correct. Lint/IdentityComparison: Exclude: - - 'spec/lib/gitlab/danger/weightage/maintainers_spec.rb' - - 'spec/lib/gitlab/danger/weightage/reviewers_spec.rb' + - 'spec/tooling/danger/weightage/maintainers_spec.rb' + - 'spec/tooling/danger/weightage/reviewers_spec.rb' # Offense count: 184 # Configuration parameters: MaximumRangeSize. @@ -263,7 +263,7 @@ Metrics/CyclomaticComplexity: - 'lib/banzai/filter/abstract_reference_filter.rb' - 'lib/declarative_policy/runner.rb' - 'lib/gitlab/conflict/file.rb' - - 'lib/gitlab/danger/roulette.rb' + - 'tooling/danger/roulette.rb' - 'lib/gitlab/diff/parser.rb' - 'lib/gitlab/rack_attack.rb' - 'lib/gitlab/sidekiq_cluster/cli.rb' @@ -285,7 +285,7 @@ Metrics/PerceivedComplexity: - 'lib/banzai/renderer.rb' - 'lib/declarative_policy/runner.rb' - 'lib/gitlab/conflict/file.rb' - - 'lib/gitlab/danger/roulette.rb' + - 'tooling/danger/roulette.rb' - 'lib/gitlab/rack_attack.rb' - 'lib/gitlab/sidekiq_cluster/cli.rb' - 'lib/gitlab/utils/merge_hash.rb' @@ -629,7 +629,7 @@ Rails/IndexBy: - 'ee/lib/gitlab/analytics/type_of_work/tasks_by_type.rb' - 'ee/lib/gitlab/elastic/document_reference.rb' - 'ee/lib/gitlab/group_plans_preloader.rb' - - 'lib/gitlab/danger/sidekiq_queues.rb' + - 'tooling/danger/sidekiq_queues.rb' - 'lib/gitlab/database/count/reltuples_count_strategy.rb' - 'lib/gitlab/language_detection.rb' diff --git a/Dangerfile b/Dangerfile index cba7226d4b9..103e38fdd33 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'lib/gitlab_danger' -require_relative 'lib/gitlab/danger/request_helper' +require_relative 'tooling/gitlab_danger' +require_relative 'tooling/danger/request_helper' danger.import_plugin('danger/plugins/helper.rb') danger.import_plugin('danger/plugins/roulette.rb') diff --git a/app/assets/javascripts/packages_and_registries/settings/group/bundle.js b/app/assets/javascripts/packages_and_registries/settings/group/bundle.js index a3d507180c6..b2ff75fe1bd 100644 --- a/app/assets/javascripts/packages_and_registries/settings/group/bundle.js +++ b/app/assets/javascripts/packages_and_registries/settings/group/bundle.js @@ -1,5 +1,6 @@ import Vue from 'vue'; import Translate from '~/vue_shared/translate'; +import { parseBoolean } from '~/lib/utils/common_utils'; import SettingsApp from './components/group_settings_app.vue'; import { apolloProvider } from './graphql'; @@ -13,6 +14,10 @@ export default () => { return new Vue({ el, apolloProvider, + provide: { + defaultExpanded: parseBoolean(el.dataset.defaultExpanded), + groupPath: el.dataset.groupPath, + }, render(createElement) { return createElement(SettingsApp); }, diff --git a/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue b/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue index 6bcecf43a13..31abdc730f8 100644 --- a/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue +++ b/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue @@ -1,9 +1,75 @@ <script> +import { GlSprintf, GlLink } from '@gitlab/ui'; +import SettingsBlock from '~/vue_shared/components/settings/settings_block.vue'; + +import { + PACKAGE_SETTINGS_HEADER, + PACKAGE_SETTINGS_DESCRIPTION, + PACKAGES_DOCS_PATH, +} from '../constants'; +import getGroupPackagesSettingsQuery from '../graphql/queries/get_group_packages_settings.query.graphql'; + export default { name: 'GroupSettingsApp', + i18n: { + PACKAGE_SETTINGS_HEADER, + PACKAGE_SETTINGS_DESCRIPTION, + }, + links: { + PACKAGES_DOCS_PATH, + }, + components: { + GlSprintf, + GlLink, + SettingsBlock, + }, + inject: { + defaultExpanded: { + type: Boolean, + default: false, + required: true, + }, + groupPath: { + type: String, + required: true, + }, + }, + apollo: { + packageSettings: { + query: getGroupPackagesSettingsQuery, + variables() { + return { + fullPath: this.groupPath, + }; + }, + update(data) { + return data.group?.packageSettings; + }, + }, + }, + data() { + return { + packageSettings: {}, + }; + }, }; </script> <template> - <section></section> + <div> + <settings-block :default-expanded="defaultExpanded"> + <template #title> {{ $options.i18n.PACKAGE_SETTINGS_HEADER }}</template> + <template #description> + <span data-testid="description"> + <gl-sprintf :message="$options.i18n.PACKAGE_SETTINGS_DESCRIPTION"> + <template #link="{ content }"> + <gl-link :href="$options.links.PACKAGES_DOCS_PATH" target="_blank">{{ + content + }}</gl-link> + </template> + </gl-sprintf> + </span> + </template> + </settings-block> + </div> </template> diff --git a/app/assets/javascripts/packages_and_registries/settings/group/constants.js b/app/assets/javascripts/packages_and_registries/settings/group/constants.js new file mode 100644 index 00000000000..b0c4bf821f9 --- /dev/null +++ b/app/assets/javascripts/packages_and_registries/settings/group/constants.js @@ -0,0 +1,9 @@ +import { s__ } from '~/locale'; +import { helpPagePath } from '~/helpers/help_page_helper'; + +export const PACKAGE_SETTINGS_HEADER = s__('PackageRegistry|Package Registry'); +export const PACKAGE_SETTINGS_DESCRIPTION = s__( + 'PackageRegistry|GitLab Packages allows organizations to utilize GitLab as a private repository for a variety of common package formats. %{linkStart}More Information%{linkEnd}', +); + +export const PACKAGES_DOCS_PATH = helpPagePath('user/packages'); diff --git a/app/assets/javascripts/packages_and_registries/settings/group/graphql/mutations/update_group_packages_settings.mutation.graphql b/app/assets/javascripts/packages_and_registries/settings/group/graphql/mutations/update_group_packages_settings.mutation.graphql new file mode 100644 index 00000000000..1fc59bd3496 --- /dev/null +++ b/app/assets/javascripts/packages_and_registries/settings/group/graphql/mutations/update_group_packages_settings.mutation.graphql @@ -0,0 +1,9 @@ +mutation updateNamespacePackageSettings($input: UpdateNamespacePackageSettingsInput!) { + updateNamespacePackageSettings(input: $input) { + packageSettings { + mavenDuplicatesAllowed + mavenDuplicateExceptionRegex + } + errors + } +} diff --git a/app/assets/javascripts/packages_and_registries/settings/group/graphql/queries/get_group_packages_settings.query.graphql b/app/assets/javascripts/packages_and_registries/settings/group/graphql/queries/get_group_packages_settings.query.graphql new file mode 100644 index 00000000000..2011659887d --- /dev/null +++ b/app/assets/javascripts/packages_and_registries/settings/group/graphql/queries/get_group_packages_settings.query.graphql @@ -0,0 +1,8 @@ +query getGroupPackagesSettings($fullPath: ID!) { + group(fullPath: $fullPath) { + packageSettings { + mavenDuplicatesAllowed + mavenDuplicateExceptionRegex + } + } +} diff --git a/app/assets/javascripts/vue_shared/components/settings/settings_block.vue b/app/assets/javascripts/vue_shared/components/settings/settings_block.vue new file mode 100644 index 00000000000..31094b985a2 --- /dev/null +++ b/app/assets/javascripts/vue_shared/components/settings/settings_block.vue @@ -0,0 +1,45 @@ +<script> +import { GlButton } from '@gitlab/ui'; +import { __ } from '~/locale'; + +export default { + components: { GlButton }, + props: { + defaultExpanded: { + type: Boolean, + default: false, + required: false, + }, + }, + data() { + return { + sectionExpanded: false, + }; + }, + computed: { + expanded() { + return this.defaultExpanded || this.sectionExpanded; + }, + toggleText() { + return this.expanded ? __('Collapse') : __('Expand'); + }, + }, +}; +</script> + +<template> + <section class="settings no-animate" :class="{ expanded }"> + <div class="settings-header"> + <h4><slot name="title"></slot></h4> + <gl-button @click="sectionExpanded = !sectionExpanded"> + {{ toggleText }} + </gl-button> + <p> + <slot name="description"></slot> + </p> + </div> + <div class="settings-content"> + <slot></slot> + </div> + </section> +</template> diff --git a/app/views/groups/settings/packages_and_registries/index.html.haml b/app/views/groups/settings/packages_and_registries/index.html.haml index 33719d56af1..b6bd16d51a6 100644 --- a/app/views/groups/settings/packages_and_registries/index.html.haml +++ b/app/views/groups/settings/packages_and_registries/index.html.haml @@ -2,4 +2,4 @@ - page_title _('Packages & Registries') - @content_class = 'limit-container-width' unless fluid_layout -%section#js-packages-and-registries-settings +%section#js-packages-and-registries-settings{ data: { default_expanded: expanded_by_default?.to_s, group_path: @group.path } } diff --git a/app/workers/merge_request_cleanup_refs_worker.rb b/app/workers/merge_request_cleanup_refs_worker.rb index 6b991a2253f..fbd62ac0a91 100644 --- a/app/workers/merge_request_cleanup_refs_worker.rb +++ b/app/workers/merge_request_cleanup_refs_worker.rb @@ -7,6 +7,8 @@ class MergeRequestCleanupRefsWorker idempotent! def perform(merge_request_id) + return unless Feature.enabled?(:merge_request_refs_cleanup, default_enabled: false) + merge_request = MergeRequest.find_by_id(merge_request_id) unless merge_request diff --git a/app/workers/schedule_merge_request_cleanup_refs_worker.rb b/app/workers/schedule_merge_request_cleanup_refs_worker.rb index 59b8993f78f..967032f99e5 100644 --- a/app/workers/schedule_merge_request_cleanup_refs_worker.rb +++ b/app/workers/schedule_merge_request_cleanup_refs_worker.rb @@ -16,6 +16,7 @@ class ScheduleMergeRequestCleanupRefsWorker def perform return if Gitlab::Database.read_only? + return unless Feature.enabled?(:merge_request_refs_cleanup, default_enabled: false) ids = MergeRequest::CleanupSchedule.scheduled_merge_request_ids(LIMIT).map { |id| [id] } diff --git a/changelogs/unreleased/yo-master-patch-87785.yml b/changelogs/unreleased/yo-master-patch-87785.yml new file mode 100644 index 00000000000..fc4578b621a --- /dev/null +++ b/changelogs/unreleased/yo-master-patch-87785.yml @@ -0,0 +1,5 @@ +--- +title: Apply GitLab UI button styles to button _blank_state_ee_trial +merge_request: 51778 +author: Yogi (@yo) +type: other diff --git a/config/feature_flags/development/api_json_content_type.yml b/config/feature_flags/development/api_always_use_application_json.yml index 5653a834e62..4405ef64012 100644 --- a/config/feature_flags/development/api_json_content_type.yml +++ b/config/feature_flags/development/api_always_use_application_json.yml @@ -1,5 +1,5 @@ --- -name: api_json_content_type +name: api_always_use_application_json introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42229 rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/270067 milestone: '13.6' diff --git a/config/feature_flags/development/merge_request_refs_cleanup.yml b/config/feature_flags/development/merge_request_refs_cleanup.yml new file mode 100644 index 00000000000..79ea3c8b7a7 --- /dev/null +++ b/config/feature_flags/development/merge_request_refs_cleanup.yml @@ -0,0 +1,8 @@ +--- +name: merge_request_refs_cleanup +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51558 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/296874 +milestone: '13.8' +type: development +group: group::code review +default_enabled: false diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile index 816d7384a2d..96a0c08c184 100644 --- a/danger/commit_messages/Dangerfile +++ b/danger/commit_messages/Dangerfile @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative File.expand_path('../../lib/gitlab/danger/commit_linter', __dir__) -require_relative File.expand_path('../../lib/gitlab/danger/merge_request_linter', __dir__) +require_relative File.expand_path('../../tooling/danger/commit_linter', __dir__) +require_relative File.expand_path('../../tooling/danger/merge_request_linter', __dir__) COMMIT_MESSAGE_GUIDELINES = "https://docs.gitlab.com/ee/development/contributing/merge_request_workflow.html#commit-messages-guidelines" MORE_INFO = "For more information, take a look at our [Commit message guidelines](#{COMMIT_MESSAGE_GUIDELINES})." @@ -54,7 +54,7 @@ end # https://github.com/jonallured/danger-commit_lint because its output is not # very helpful, and it doesn't offer the means of ignoring merge commits. def lint_commit(commit) - linter = Gitlab::Danger::CommitLinter.new(commit) + linter = Tooling::Danger::CommitLinter.new(commit) # For now we'll ignore merge commits, as getting rid of those is a problem # separate from enforcing good commit messages. @@ -93,7 +93,7 @@ end def lint_mr_title(mr_title) commit = Struct.new(:message, :sha).new(mr_title) - Gitlab::Danger::MergeRequestLinter.new(commit).lint + Tooling::Danger::MergeRequestLinter.new(commit).lint end def count_non_fixup_commits(commit_linters) diff --git a/danger/frozen_string/Dangerfile b/danger/frozen_string/Dangerfile deleted file mode 100644 index bc598b16463..00000000000 --- a/danger/frozen_string/Dangerfile +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -FILE_EXTENSION = ".rb" -FROZEN_STRING_MAGIC_COMMENT = "# frozen_string_literal: true" -SHEBANG_COMMENT = "#!" - -def get_files_with_no_magic_comment(files) - files.select do |path| - path.end_with?(FILE_EXTENSION) && - !file_has_frozen_string_magic_comment?(path) - end -end - -def file_has_frozen_string_magic_comment?(path) - File.open(path) do |file| - first_line = file.gets - - line_has_frozen_string_magic_comment?(first_line) || - (line_has_shebang?(first_line) && - line_has_frozen_string_magic_comment?(file.gets)) - end -end - -def line_has_frozen_string_magic_comment?(line) - line&.start_with?(FROZEN_STRING_MAGIC_COMMENT) -end - -def line_has_shebang?(line) - line&.start_with?(SHEBANG_COMMENT) -end - -files_to_fix = get_files_with_no_magic_comment(git.added_files) - -if files_to_fix.any? - warn 'This merge request adds files that do not enforce frozen string literal. ' \ - 'See https://gitlab.com/gitlab-org/gitlab-foss/issues/47424 for more information.' - - if GitlabDanger.new(helper.gitlab_helper).ci? - markdown(<<~MARKDOWN) - ## Enable Frozen String Literal - - The following files should have `#{FROZEN_STRING_MAGIC_COMMENT}` on the first line: - - * #{files_to_fix.map { |path| "`#{path}`" }.join("\n* ")} - MARKDOWN - end -end diff --git a/danger/plugins/changelog.rb b/danger/plugins/changelog.rb index 84f399e9e97..fd2dad5932a 100644 --- a/danger/plugins/changelog.rb +++ b/danger/plugins/changelog.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative '../../lib/gitlab/danger/changelog' +require_relative '../../tooling/danger/changelog' module Danger class Changelog < Plugin # Put the helper code somewhere it can be tested - include Gitlab::Danger::Changelog + include Tooling::Danger::Changelog end end diff --git a/danger/plugins/helper.rb b/danger/plugins/helper.rb index 2d7a933e801..8602868d817 100644 --- a/danger/plugins/helper.rb +++ b/danger/plugins/helper.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative '../../lib/gitlab/danger/helper' +require_relative '../../tooling/danger/helper' module Danger - # Common helper functions for our danger scripts. See Gitlab::Danger::Helper + # Common helper functions for our danger scripts. See Tooling::Danger::Helper # for more details class Helper < Plugin # Put the helper code somewhere it can be tested - include Gitlab::Danger::Helper + include Tooling::Danger::Helper end end diff --git a/danger/plugins/roulette.rb b/danger/plugins/roulette.rb index 7c62cff0c92..2aa0132852e 100644 --- a/danger/plugins/roulette.rb +++ b/danger/plugins/roulette.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative '../../lib/gitlab/danger/roulette' +require_relative '../../tooling/danger/roulette' module Danger class Roulette < Plugin # Put the helper code somewhere it can be tested - include Gitlab::Danger::Roulette + include Tooling::Danger::Roulette end end diff --git a/danger/plugins/sidekiq_queues.rb b/danger/plugins/sidekiq_queues.rb index 1edeb6da3d5..dd436e5cb2b 100644 --- a/danger/plugins/sidekiq_queues.rb +++ b/danger/plugins/sidekiq_queues.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative '../../lib/gitlab/danger/sidekiq_queues' +require_relative '../../tooling/danger/sidekiq_queues' module Danger class SidekiqQueues < Plugin # Put the helper code somewhere it can be tested - include Gitlab::Danger::SidekiqQueues + include Tooling::Danger::SidekiqQueues end end diff --git a/danger/product_intelligence/Dangerfile b/danger/product_intelligence/Dangerfile index ec432544977..f324e434a3e 100644 --- a/danger/product_intelligence/Dangerfile +++ b/danger/product_intelligence/Dangerfile @@ -22,10 +22,13 @@ tracking_files = [ 'app/helpers/tracking_helper.rb', 'spec/helpers/tracking_helper_spec.rb', 'app/assets/javascripts/tracking.js', - 'spec/frontend/tracking_spec.js' + 'spec/frontend/tracking_spec.js', + 'generator_templates/usage_metric_definition/metric_definition.yml', + 'lib/generators/rails/usage_metric_definition_generator.rb', + 'spec/lib/generators/usage_metric_definition_generator_spec.rb' ] -usage_data_changed_files = helper.changed_files(/usage_data/) +usage_data_changed_files = helper.changed_files(%r{(usage_data)|(config/metrics)|(ee/config/metrics)}) snowplow_events_changed_files = git.modified_files & tracking_files changed_files = (usage_data_changed_files + snowplow_events_changed_files) diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index 424114a3d33..8289fb599a7 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -35,7 +35,7 @@ UNKNOWN_FILES_MESSAGE = <<MARKDOWN These files couldn't be categorised, so Danger was unable to suggest a reviewer. Please consider creating a merge request to -[add support](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/danger/helper.rb) +[add support](https://gitlab.com/gitlab-org/gitlab/blob/master/tooling/danger/helper.rb) for them. MARKDOWN diff --git a/doc/development/dangerbot.md b/doc/development/dangerbot.md index 59b31437161..413c0a31eec 100644 --- a/doc/development/dangerbot.md +++ b/doc/development/dangerbot.md @@ -105,9 +105,9 @@ minimize the number of lines of code in `danger/`. A non-trivial `Dangerfile` should mostly call plugin code with arguments derived from the methods provided by Danger. The plugin code itself should have unit tests. -At present, we do this by putting the code in a module in `lib/gitlab/danger/...`, +At present, we do this by putting the code in a module in `tooling/danger/...`, and including it in the matching `danger/plugins/...` file. Specs can then be -added in `spec/lib/gitlab/danger/...`. +added in `spec/tooling/danger/...`. To determine if your `Dangerfile` works, push the branch that contains it to GitLab. This can be quite frustrating, as it significantly increases the cycle diff --git a/lib/api/api.rb b/lib/api/api.rb index ada0da28749..95e37f2c418 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -123,13 +123,32 @@ module API format :json formatter :json, Gitlab::Json::GrapeFormatter + content_type :json, 'application/json' + # Remove the `text/plain+deprecated` with `api_always_use_application_json` feature flag # There is a small chance some users depend on the old behavior. # We this change under a feature flag to see if affects GitLab.com users. - if Gitlab::Database.cached_table_exists?('features') && Feature.enabled?(:api_json_content_type) - content_type :json, 'application/json' - else - content_type :txt, 'text/plain' + # The `+deprecated` is added to distinguish content type + # as defined by `API::API` vs ex. `API::Repositories` + content_type :txt, 'text/plain+deprecated' + + before do + # the feature flag workaround is only for `.txt` + api_format = env[Grape::Env::API_FORMAT] + next unless api_format == :txt + + # get all defined content-types for the endpoint + api_endpoint = env[Grape::Env::API_ENDPOINT] + content_types = api_endpoint&.namespace_stackable_with_hash(:content_types).to_h + + # Only overwrite `text/plain+deprecated` + if content_types[api_format] == 'text/plain+deprecated' + if Feature.enabled?(:api_always_use_application_json) + content_type 'application/json' + else + content_type 'text/plain' + end + end end # Ensure the namespace is right, otherwise we might load Grape::API::Helpers diff --git a/lib/api/concerns/packages/conan_endpoints.rb b/lib/api/concerns/packages/conan_endpoints.rb index 6c8b3a1ba4a..1796d51324f 100644 --- a/lib/api/concerns/packages/conan_endpoints.rb +++ b/lib/api/concerns/packages/conan_endpoints.rb @@ -72,6 +72,7 @@ module API namespace 'users' do format :txt + content_type :txt, 'text/plain' desc 'Authenticate user against conan CLI' do detail 'This feature was introduced in GitLab 12.2' diff --git a/lib/api/debian_package_endpoints.rb b/lib/api/debian_package_endpoints.rb index c95c75b7e5c..9aff34933f7 100644 --- a/lib/api/debian_package_endpoints.rb +++ b/lib/api/debian_package_endpoints.rb @@ -32,6 +32,7 @@ module API helpers ::API::Helpers::Packages::BasicAuthHelpers format :txt + content_type :txt, 'text/plain' rescue_from ArgumentError do |e| render_api_error!(e.message, 400) diff --git a/lib/api/jobs.rb b/lib/api/jobs.rb index e14a4a5e680..c09b01f5b4e 100644 --- a/lib/api/jobs.rb +++ b/lib/api/jobs.rb @@ -82,7 +82,8 @@ module API content_type 'text/plain' env['api.format'] = :binary - trace = build.trace.raw + # The trace can be nil bu body method expects a string as an argument. + trace = build.trace.raw || '' body trace end diff --git a/lib/tasks/gitlab_danger.rake b/lib/tasks/gitlab_danger.rake index e75539f048c..deff6484231 100644 --- a/lib/tasks/gitlab_danger.rake +++ b/lib/tasks/gitlab_danger.rake @@ -1,6 +1,6 @@ desc 'Run local Danger rules' task :danger_local do - require 'gitlab_danger' + require_relative '../../tooling/gitlab_danger' require 'gitlab/popen' puts("#{GitlabDanger.local_warning_message}\n") diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 7db9dd0f095..57a5ab17b25 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -20304,6 +20304,9 @@ msgstr "" msgid "PackageRegistry|Generic" msgstr "" +msgid "PackageRegistry|GitLab Packages allows organizations to utilize GitLab as a private repository for a variety of common package formats. %{linkStart}More Information%{linkEnd}" +msgstr "" + msgid "PackageRegistry|If you haven't already done so, you will need to add the below to your %{codeStart}.pypirc%{codeEnd} file." msgstr "" diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb index 6ed204a98d4..72c990cbbc2 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb @@ -13,7 +13,7 @@ module QA issue.visit! end - it 'collapses and expands reply for comments in an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/434' do + it 'collapses and expands reply for comments in an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1163' do Page::Project::Issue::Show.perform do |show| show.select_all_activities_filter show.start_discussion('My first discussion') diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb index 688f42c48c6..19f77b63ba7 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb @@ -9,7 +9,7 @@ module QA Flow::Login.sign_in end - it 'creates an issue', :reliable, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/432' do + it 'creates an issue', :reliable, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1167' do issue = Resource::Issue.fabricate_via_browser_ui! Page::Project::Menu.perform(&:click_issues) diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb index 7c675862e26..ff33f9d4824 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb @@ -13,7 +13,7 @@ module QA end.project.visit! end - it 'shows issue suggestions when creating a new issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/412' do + it 'shows issue suggestions when creating a new issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1175' do Page::Project::Show.perform(&:go_to_new_issue) Page::Project::Issue::New.perform do |new_page| new_page.fill_title("issue") diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb index 5a8c9a4601a..cc815fd0e67 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb @@ -21,7 +21,7 @@ module QA end.visit! end - it 'mentions another user in an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/446' do + it 'mentions another user in an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1166' do Page::Project::Issue::Show.perform do |show| at_username = "@#{user.username}" diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue_boards/focus_mode_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue_boards/focus_mode_spec.rb index 7f60726af0e..8f17a25012b 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue_boards/focus_mode_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue_boards/focus_mode_spec.rb @@ -13,7 +13,7 @@ module QA Flow::Login.sign_in end - it 'focuses on issue board', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/820' do + it 'focuses on issue board', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1176' do project.visit! Page::Project::Menu.perform(&:go_to_boards) diff --git a/qa/qa/specs/features/browser_ui/2_plan/milestone/create_project_milestone_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/milestone/create_project_milestone_spec.rb index 99d547acb26..78d1471f484 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/milestone/create_project_milestone_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/milestone/create_project_milestone_spec.rb @@ -14,7 +14,7 @@ module QA Flow::Login.sign_in end - it 'creates a project milestone', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/901' do + it 'creates a project milestone', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1165' do project_milestone = Resource::ProjectMilestone.fabricate_via_browser_ui! do |milestone| milestone.title = title milestone.description = description diff --git a/qa/qa/specs/features/browser_ui/2_plan/related_issues/related_issues_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/related_issues/related_issues_spec.rb index 6a133540f87..d907cfaab6d 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/related_issues/related_issues_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/related_issues/related_issues_spec.rb @@ -25,7 +25,7 @@ module QA Flow::Login.sign_in end - it 'relates and unrelates one issue to/from another', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/541' do + it 'relates and unrelates one issue to/from another', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1172' do issue_1.visit! Page::Project::Issue::Show.perform do |show| diff --git a/qa/qa/specs/features/browser_ui/6_release/pipeline/parent_child_pipelines_independent_relationship_spec.rb b/qa/qa/specs/features/browser_ui/6_release/pipeline/parent_child_pipelines_independent_relationship_spec.rb index ed8c8baae0e..6c7ab9f2f72 100644 --- a/qa/qa/specs/features/browser_ui/6_release/pipeline/parent_child_pipelines_independent_relationship_spec.rb +++ b/qa/qa/specs/features/browser_ui/6_release/pipeline/parent_child_pipelines_independent_relationship_spec.rb @@ -25,7 +25,7 @@ module QA runner.remove_via_api! end - it 'parent pipelines passes if child passes', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/754' do + it 'parent pipelines passes if child passes', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1161' do add_ci_files(success_child_ci_file) Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed') @@ -35,7 +35,7 @@ module QA end end - it 'parent pipeline passes even if child fails', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/753' do + it 'parent pipeline passes even if child fails', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1162' do add_ci_files(fail_child_ci_file) Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed') diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index e95f20bc26c..cd41aa0ff14 100644 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -6,7 +6,8 @@ export BUNDLE_INSTALL_FLAGS=${BUNDLE_INSTALL_FLAGS:-"--without=production develo if [ "$USE_BUNDLE_INSTALL" != "false" ]; then bundle --version - run_timed_command "bundle install --clean ${BUNDLE_INSTALL_FLAGS}" + bundle config set clean 'true' + run_timed_command "bundle install ${BUNDLE_INSTALL_FLAGS}" run_timed_command "bundle check" # When we test multiple versions of PG in the same pipeline, we have a single `setup-test-env` # job but the `pg` gem needs to be rebuilt since it includes extensions (https://guides.rubygems.org/gems-with-extensions). diff --git a/spec/features/groups/settings/packages_and_registries_spec.rb b/spec/features/groups/settings/packages_and_registries_spec.rb index b8ffd73335d..09b0707492f 100644 --- a/spec/features/groups/settings/packages_and_registries_spec.rb +++ b/spec/features/groups/settings/packages_and_registries_spec.rb @@ -47,6 +47,13 @@ RSpec.describe 'Group Packages & Registries settings' do sidebar = find('.nav-sidebar') expect(sidebar).to have_link _('Packages & Registries') end + + it 'has a Package Registry section', :js do + visit_settings_page + + expect(page).to have_content('Package Registry') + expect(page).to have_button('Collapse') + end end def find_settings_menu diff --git a/spec/frontend/packages_and_registries/settings/group/components/group_settings_app_spec.js b/spec/frontend/packages_and_registries/settings/group/components/group_settings_app_spec.js new file mode 100644 index 00000000000..8a1d5044106 --- /dev/null +++ b/spec/frontend/packages_and_registries/settings/group/components/group_settings_app_spec.js @@ -0,0 +1,99 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { GlSprintf, GlLink } from '@gitlab/ui'; +import VueApollo from 'vue-apollo'; +import createMockApollo from 'helpers/mock_apollo_helper'; +import component from '~/packages_and_registries/settings/group/components/group_settings_app.vue'; +import SettingsBlock from '~/vue_shared/components/settings/settings_block.vue'; +import { + PACKAGE_SETTINGS_HEADER, + PACKAGE_SETTINGS_DESCRIPTION, + PACKAGES_DOCS_PATH, +} from '~/packages_and_registries/settings/group/constants'; + +import getGroupPackagesSettingsQuery from '~/packages_and_registries/settings/group/graphql/queries/get_group_packages_settings.query.graphql'; +import { groupPackageSettingsMock } from '../mock_data'; + +const localVue = createLocalVue(); + +describe('Group Settings App', () => { + let wrapper; + let apolloProvider; + + const defaultProvide = { + defaultExpanded: false, + groupPath: 'foo_group_path', + }; + + const mountComponent = ({ + provide = defaultProvide, + resolver = jest.fn().mockResolvedValue(groupPackageSettingsMock), + } = {}) => { + localVue.use(VueApollo); + + const requestHandlers = [[getGroupPackagesSettingsQuery, resolver]]; + + apolloProvider = createMockApollo(requestHandlers); + + wrapper = shallowMount(component, { + localVue, + apolloProvider, + provide, + stubs: { + GlSprintf, + SettingsBlock, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + const findSettingsBlock = () => wrapper.find(SettingsBlock); + const findDescription = () => wrapper.find('[data-testid="description"'); + const findLink = () => wrapper.find(GlLink); + + it('renders a settings block', () => { + mountComponent(); + + expect(findSettingsBlock().exists()).toBe(true); + }); + + it('passes the correct props to settings block', () => { + mountComponent(); + + expect(findSettingsBlock().props('defaultExpanded')).toBe(false); + }); + + it('has the correct header text', () => { + mountComponent(); + + expect(wrapper.text()).toContain(PACKAGE_SETTINGS_HEADER); + }); + + it('has the correct description text', () => { + mountComponent(); + + expect(findDescription().text()).toMatchInterpolatedText(PACKAGE_SETTINGS_DESCRIPTION); + }); + + it('has the correct link', () => { + mountComponent(); + + expect(findLink().attributes()).toMatchObject({ + href: PACKAGES_DOCS_PATH, + target: '_blank', + }); + expect(findLink().text()).toBe('More Information'); + }); + + it('calls the graphql API with the proper variables', () => { + const resolver = jest.fn().mockResolvedValue(groupPackageSettingsMock); + mountComponent({ resolver }); + + expect(resolver).toHaveBeenCalledWith({ + fullPath: defaultProvide.groupPath, + }); + }); +}); diff --git a/spec/frontend/packages_and_registries/settings/group/mock_data.js b/spec/frontend/packages_and_registries/settings/group/mock_data.js new file mode 100644 index 00000000000..6be43cb4aea --- /dev/null +++ b/spec/frontend/packages_and_registries/settings/group/mock_data.js @@ -0,0 +1,12 @@ +export const groupPackageSettingsMock = { + data: { + group: { + packageSettings: { + mavenDuplicatesAllowed: true, + mavenDuplicateExceptionRegex: '', + __typename: 'PackageSettings', + }, + __typename: 'Group', + }, + }, +}; diff --git a/spec/frontend/vue_shared/components/settings/__snapshots__/settings_block_spec.js.snap b/spec/frontend/vue_shared/components/settings/__snapshots__/settings_block_spec.js.snap new file mode 100644 index 00000000000..51b8aa162bc --- /dev/null +++ b/spec/frontend/vue_shared/components/settings/__snapshots__/settings_block_spec.js.snap @@ -0,0 +1,43 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Settings Block renders the correct markup 1`] = ` +<section + class="settings no-animate" +> + <div + class="settings-header" + > + <h4> + <div + data-testid="title-slot" + /> + </h4> + + <gl-button-stub + buttontextclasses="" + category="primary" + icon="" + size="medium" + variant="default" + > + + Expand + + </gl-button-stub> + + <p> + <div + data-testid="description-slot" + /> + </p> + </div> + + <div + class="settings-content" + > + <div + data-testid="default-slot" + /> + </div> +</section> +`; diff --git a/spec/frontend/vue_shared/components/settings/settings_block_spec.js b/spec/frontend/vue_shared/components/settings/settings_block_spec.js new file mode 100644 index 00000000000..b550c4cfcc3 --- /dev/null +++ b/spec/frontend/vue_shared/components/settings/settings_block_spec.js @@ -0,0 +1,86 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlButton } from '@gitlab/ui'; +import component from '~/vue_shared/components/settings/settings_block.vue'; + +describe('Settings Block', () => { + let wrapper; + + const mountComponent = (propsData) => { + wrapper = shallowMount(component, { + propsData, + slots: { + title: '<div data-testid="title-slot"></div>', + description: '<div data-testid="description-slot"></div>', + default: '<div data-testid="default-slot"></div>', + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + const findDefaultSlot = () => wrapper.find('[data-testid="default-slot"]'); + const findTitleSlot = () => wrapper.find('[data-testid="title-slot"]'); + const findDescriptionSlot = () => wrapper.find('[data-testid="description-slot"]'); + const findExpandButton = () => wrapper.find(GlButton); + + it('renders the correct markup', () => { + mountComponent(); + + expect(wrapper.element).toMatchSnapshot(); + }); + + it('has a default slot', () => { + mountComponent(); + + expect(findDefaultSlot().exists()).toBe(true); + }); + + it('has a title slot', () => { + mountComponent(); + + expect(findTitleSlot().exists()).toBe(true); + }); + + it('has a description slot', () => { + mountComponent(); + + expect(findDescriptionSlot().exists()).toBe(true); + }); + + describe('expanded behaviour', () => { + it('is collapsed by default', () => { + mountComponent(); + + expect(wrapper.classes('expanded')).toBe(false); + }); + + it('adds expanded class when the expand button is clicked', async () => { + mountComponent(); + + expect(wrapper.classes('expanded')).toBe(false); + expect(findExpandButton().text()).toBe('Expand'); + + await findExpandButton().vm.$emit('click'); + + expect(wrapper.classes('expanded')).toBe(true); + expect(findExpandButton().text()).toBe('Collapse'); + }); + + it('is expanded when `defaultExpanded` is true no matter what', async () => { + mountComponent({ defaultExpanded: true }); + + expect(wrapper.classes('expanded')).toBe(true); + + await findExpandButton().vm.$emit('click'); + + expect(wrapper.classes('expanded')).toBe(true); + + await findExpandButton().vm.$emit('click'); + + expect(wrapper.classes('expanded')).toBe(true); + }); + }); +}); diff --git a/spec/requests/api/api_spec.rb b/spec/requests/api/api_spec.rb index 9fd30213133..209ac596ac7 100644 --- a/spec/requests/api/api_spec.rb +++ b/spec/requests/api/api_spec.rb @@ -126,4 +126,34 @@ RSpec.describe API::API do get(api('/users')) end end + + describe 'supported content-types' do + context 'GET /user/:id.txt' do + let_it_be(:user) { create(:user) } + + subject { get api("/users/#{user.id}.txt", user) } + + it 'returns application/json' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response.media_type).to eq('application/json') + expect(response.body).to include('{"id":') + end + + context 'when api_always_use_application_json is disabled' do + before do + stub_feature_flags(api_always_use_application_json: false) + end + + it 'returns text/plain' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response.media_type).to eq('text/plain') + expect(response.body).to include('#<API::Entities::User:') + end + end + end + end end diff --git a/spec/lib/gitlab/danger/base_linter_spec.rb b/spec/tooling/danger/base_linter_spec.rb index 0136a0278ae..54d8f3dc1f7 100644 --- a/spec/lib/gitlab/danger/base_linter_spec.rb +++ b/spec/tooling/danger/base_linter_spec.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true -require 'fast_spec_helper' require 'rspec-parameterized' require_relative 'danger_spec_helper' -require 'gitlab/danger/base_linter' +require_relative '../../../tooling/danger/base_linter' -RSpec.describe Gitlab::Danger::BaseLinter do +RSpec.describe Tooling::Danger::BaseLinter do let(:commit_class) do Struct.new(:message, :sha, :diff_parent) end diff --git a/spec/lib/gitlab/danger/changelog_spec.rb b/spec/tooling/danger/changelog_spec.rb index 04c515f1205..c0eca67ce92 100644 --- a/spec/lib/gitlab/danger/changelog_spec.rb +++ b/spec/tooling/danger/changelog_spec.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -require 'fast_spec_helper' require_relative 'danger_spec_helper' -require 'gitlab/danger/changelog' +require_relative '../../../tooling/danger/changelog' -RSpec.describe Gitlab::Danger::Changelog do +RSpec.describe Tooling::Danger::Changelog do include DangerSpecHelper let(:added_files) { nil } @@ -53,8 +52,8 @@ RSpec.describe Gitlab::Danger::Changelog do describe '#optional?' do let(:category_with_changelog) { :backend } let(:label_with_changelog) { 'frontend' } - let(:category_without_changelog) { Gitlab::Danger::Changelog::NO_CHANGELOG_CATEGORIES.first } - let(:label_without_changelog) { Gitlab::Danger::Changelog::NO_CHANGELOG_LABELS.first } + let(:category_without_changelog) { Tooling::Danger::Changelog::NO_CHANGELOG_CATEGORIES.first } + let(:label_without_changelog) { Tooling::Danger::Changelog::NO_CHANGELOG_LABELS.first } subject { changelog.optional? } diff --git a/spec/lib/gitlab/danger/commit_linter_spec.rb b/spec/tooling/danger/commit_linter_spec.rb index d3d86037a53..694e524af21 100644 --- a/spec/lib/gitlab/danger/commit_linter_spec.rb +++ b/spec/tooling/danger/commit_linter_spec.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true -require 'fast_spec_helper' require 'rspec-parameterized' require_relative 'danger_spec_helper' -require 'gitlab/danger/commit_linter' +require_relative '../../../tooling/danger/commit_linter' -RSpec.describe Gitlab::Danger::CommitLinter do +RSpec.describe Tooling::Danger::CommitLinter do using RSpec::Parameterized::TableSyntax let(:total_files_changed) { 2 } diff --git a/spec/lib/gitlab/danger/danger_spec_helper.rb b/spec/tooling/danger/danger_spec_helper.rb index b1e84b3c13d..b1e84b3c13d 100644 --- a/spec/lib/gitlab/danger/danger_spec_helper.rb +++ b/spec/tooling/danger/danger_spec_helper.rb diff --git a/spec/lib/gitlab/danger/emoji_checker_spec.rb b/spec/tooling/danger/emoji_checker_spec.rb index 6092c751e1c..bbd957b3d00 100644 --- a/spec/lib/gitlab/danger/emoji_checker_spec.rb +++ b/spec/tooling/danger/emoji_checker_spec.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -require 'fast_spec_helper' require 'rspec-parameterized' -require 'gitlab/danger/emoji_checker' +require_relative '../../../tooling/danger/emoji_checker' -RSpec.describe Gitlab::Danger::EmojiChecker do +RSpec.describe Tooling::Danger::EmojiChecker do using RSpec::Parameterized::TableSyntax describe '#includes_text_emoji?' do diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/tooling/danger/helper_spec.rb index bd5c746dd54..69aefddc536 100644 --- a/spec/lib/gitlab/danger/helper_spec.rb +++ b/spec/tooling/danger/helper_spec.rb @@ -4,9 +4,9 @@ require 'fast_spec_helper' require 'rspec-parameterized' require_relative 'danger_spec_helper' -require 'gitlab/danger/helper' +require_relative '../../../tooling/danger/helper' -RSpec.describe Gitlab::Danger::Helper do +RSpec.describe Tooling::Danger::Helper do using RSpec::Parameterized::TableSyntax include DangerSpecHelper @@ -37,7 +37,7 @@ RSpec.describe Gitlab::Danger::Helper do context 'when danger gitlab plugin is not available' do it 'returns nil' do invalid_danger = Class.new do - include Gitlab::Danger::Helper + include Tooling::Danger::Helper end.new expect(invalid_danger.gitlab_helper).to be_nil @@ -289,8 +289,8 @@ RSpec.describe Gitlab::Danger::Helper do '.gitlab/ci/cng.gitlab-ci.yml' | [:engineering_productivity] '.gitlab/ci/ee-specific-checks.gitlab-ci.yml' | [:engineering_productivity] 'scripts/foo' | [:engineering_productivity] - 'lib/gitlab/danger/foo' | [:engineering_productivity] - 'ee/lib/gitlab/danger/foo' | [:engineering_productivity] + 'tooling/danger/foo' | [:engineering_productivity] + 'ee/tooling/danger/foo' | [:engineering_productivity] 'lefthook.yml' | [:engineering_productivity] '.editorconfig' | [:engineering_productivity] 'tooling/bin/find_foss_tests' | [:engineering_productivity] diff --git a/spec/lib/gitlab/danger/merge_request_linter_spec.rb b/spec/tooling/danger/merge_request_linter_spec.rb index 29facc9fdd6..3273b6b3d07 100644 --- a/spec/lib/gitlab/danger/merge_request_linter_spec.rb +++ b/spec/tooling/danger/merge_request_linter_spec.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true -require 'fast_spec_helper' require 'rspec-parameterized' require_relative 'danger_spec_helper' -require 'gitlab/danger/merge_request_linter' +require_relative '../../../tooling/danger/merge_request_linter' -RSpec.describe Gitlab::Danger::MergeRequestLinter do +RSpec.describe Tooling::Danger::MergeRequestLinter do using RSpec::Parameterized::TableSyntax let(:mr_class) do diff --git a/spec/lib/gitlab/danger/roulette_spec.rb b/spec/tooling/danger/roulette_spec.rb index 59ac3b12b6b..9174f812def 100644 --- a/spec/lib/gitlab/danger/roulette_spec.rb +++ b/spec/tooling/danger/roulette_spec.rb @@ -3,10 +3,10 @@ require 'webmock/rspec' require 'timecop' -require 'gitlab/danger/roulette' +require_relative '../../../tooling/danger/roulette' require 'active_support/testing/time_helpers' -RSpec.describe Gitlab::Danger::Roulette do +RSpec.describe Tooling::Danger::Roulette do include ActiveSupport::Testing::TimeHelpers around do |example| @@ -16,7 +16,7 @@ RSpec.describe Gitlab::Danger::Roulette do let(:backend_available) { true } let(:backend_tz_offset_hours) { 2.0 } let(:backend_maintainer) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'backend-maintainer', 'name' => 'Backend maintainer', 'role' => 'Backend engineer', @@ -27,7 +27,7 @@ RSpec.describe Gitlab::Danger::Roulette do end let(:frontend_reviewer) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'frontend-reviewer', 'name' => 'Frontend reviewer', 'role' => 'Frontend engineer', @@ -38,7 +38,7 @@ RSpec.describe Gitlab::Danger::Roulette do end let(:frontend_maintainer) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'frontend-maintainer', 'name' => 'Frontend maintainer', 'role' => 'Frontend engineer', @@ -49,7 +49,7 @@ RSpec.describe Gitlab::Danger::Roulette do end let(:software_engineer_in_test) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'software-engineer-in-test', 'name' => 'Software Engineer in Test', 'role' => 'Software Engineer in Test, Create:Source Code', @@ -60,7 +60,7 @@ RSpec.describe Gitlab::Danger::Roulette do end let(:engineering_productivity_reviewer) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'eng-prod-reviewer', 'name' => 'EP engineer', 'role' => 'Engineering Productivity', @@ -71,7 +71,7 @@ RSpec.describe Gitlab::Danger::Roulette do end let(:ci_template_reviewer) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'ci-template-maintainer', 'name' => 'CI Template engineer', 'role' => '~"ci::templates"', @@ -121,7 +121,7 @@ RSpec.describe Gitlab::Danger::Roulette do let!(:project) { 'gitlab' } let!(:mr_source_branch) { 'a-branch' } let!(:mr_labels) { ['backend', 'devops::create'] } - let!(:author) { Gitlab::Danger::Teammate.new('username' => 'johndoe') } + let!(:author) { Tooling::Danger::Teammate.new('username' => 'johndoe') } let(:timezone_experiment) { false } let(:spins) do # Stub the request at the latest time so that we can modify the raw data, e.g. available fields. @@ -330,7 +330,7 @@ RSpec.describe Gitlab::Danger::Roulette do describe '#spin_for_person' do let(:person_tz_offset_hours) { 0.0 } let(:person1) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'user1', 'available' => true, 'tz_offset_hours' => person_tz_offset_hours @@ -338,21 +338,21 @@ RSpec.describe Gitlab::Danger::Roulette do end let(:person2) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'user2', 'available' => true, 'tz_offset_hours' => person_tz_offset_hours) end let(:author) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'johndoe', 'available' => true, 'tz_offset_hours' => 0.0) end let(:unavailable) do - Gitlab::Danger::Teammate.new( + Tooling::Danger::Teammate.new( 'username' => 'janedoe', 'available' => false, 'tz_offset_hours' => 0.0) diff --git a/spec/lib/gitlab/danger/sidekiq_queues_spec.rb b/spec/tooling/danger/sidekiq_queues_spec.rb index 7dd1a2e6924..c5fc8592621 100644 --- a/spec/lib/gitlab/danger/sidekiq_queues_spec.rb +++ b/spec/tooling/danger/sidekiq_queues_spec.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true -require 'fast_spec_helper' require 'rspec-parameterized' require_relative 'danger_spec_helper' -require 'gitlab/danger/sidekiq_queues' +require_relative '../../../tooling/danger/sidekiq_queues' -RSpec.describe Gitlab::Danger::SidekiqQueues do +RSpec.describe Tooling::Danger::SidekiqQueues do using RSpec::Parameterized::TableSyntax include DangerSpecHelper diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/tooling/danger/teammate_spec.rb index 9c066ba4c1b..7b2c5bbcdc1 100644 --- a/spec/lib/gitlab/danger/teammate_spec.rb +++ b/spec/tooling/danger/teammate_spec.rb @@ -1,12 +1,9 @@ # frozen_string_literal: true -require 'timecop' -require 'rspec-parameterized' - -require 'gitlab/danger/teammate' +require_relative '../../../tooling/danger/teammate' require 'active_support/testing/time_helpers' -RSpec.describe Gitlab::Danger::Teammate do +RSpec.describe Tooling::Danger::Teammate do using RSpec::Parameterized::TableSyntax subject { described_class.new(options) } diff --git a/spec/lib/gitlab/danger/title_linting_spec.rb b/spec/tooling/danger/title_linting_spec.rb index b48d2c5e53d..1677223f0db 100644 --- a/spec/lib/gitlab/danger/title_linting_spec.rb +++ b/spec/tooling/danger/title_linting_spec.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -require 'fast_spec_helper' require 'rspec-parameterized' -require 'gitlab/danger/title_linting' +require_relative '../../../tooling/danger/title_linting' -RSpec.describe Gitlab::Danger::TitleLinting do +RSpec.describe Tooling::Danger::TitleLinting do using RSpec::Parameterized::TableSyntax describe '#sanitize_mr_title' do diff --git a/spec/lib/gitlab/danger/weightage/maintainers_spec.rb b/spec/tooling/danger/weightage/maintainers_spec.rb index 066bb487fa2..b99ffe706a4 100644 --- a/spec/lib/gitlab/danger/weightage/maintainers_spec.rb +++ b/spec/tooling/danger/weightage/maintainers_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require 'gitlab/danger/weightage/maintainers' +require_relative '../../../../tooling/danger/weightage/maintainers' -RSpec.describe Gitlab::Danger::Weightage::Maintainers do - let(:multiplier) { Gitlab::Danger::Weightage::CAPACITY_MULTIPLIER } +RSpec.describe Tooling::Danger::Weightage::Maintainers do + let(:multiplier) { Tooling::Danger::Weightage::CAPACITY_MULTIPLIER } let(:regular_maintainer) { double('Teammate', reduced_capacity: false) } let(:reduced_capacity_maintainer) { double('Teammate', reduced_capacity: true) } let(:maintainers) do @@ -13,8 +13,8 @@ RSpec.describe Gitlab::Danger::Weightage::Maintainers do ] end - let(:maintainer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier } - let(:reduced_capacity_maintainer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT } + let(:maintainer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier } + let(:reduced_capacity_maintainer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT } subject(:weighted_maintainers) { described_class.new(maintainers).execute } diff --git a/spec/lib/gitlab/danger/weightage/reviewers_spec.rb b/spec/tooling/danger/weightage/reviewers_spec.rb index cca81f4d9b5..5693ce7a10c 100644 --- a/spec/lib/gitlab/danger/weightage/reviewers_spec.rb +++ b/spec/tooling/danger/weightage/reviewers_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require 'gitlab/danger/weightage/reviewers' +require_relative '../../../../tooling/danger/weightage/reviewers' -RSpec.describe Gitlab::Danger::Weightage::Reviewers do - let(:multiplier) { Gitlab::Danger::Weightage::CAPACITY_MULTIPLIER } +RSpec.describe Tooling::Danger::Weightage::Reviewers do + let(:multiplier) { Tooling::Danger::Weightage::CAPACITY_MULTIPLIER } let(:regular_reviewer) { double('Teammate', hungry: false, reduced_capacity: false) } let(:hungry_reviewer) { double('Teammate', hungry: true, reduced_capacity: false) } let(:reduced_capacity_reviewer) { double('Teammate', hungry: false, reduced_capacity: true) } @@ -26,11 +26,11 @@ RSpec.describe Gitlab::Danger::Weightage::Reviewers do ] end - let(:hungry_reviewer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier + described_class::DEFAULT_REVIEWER_WEIGHT } + let(:hungry_reviewer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier + described_class::DEFAULT_REVIEWER_WEIGHT } let(:hungry_traintainer_count) { described_class::TRAINTAINER_WEIGHT * multiplier + described_class::DEFAULT_REVIEWER_WEIGHT } - let(:reviewer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier } - let(:traintainer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * described_class::TRAINTAINER_WEIGHT * multiplier } - let(:reduced_capacity_reviewer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT } + let(:reviewer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier } + let(:traintainer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * described_class::TRAINTAINER_WEIGHT * multiplier } + let(:reduced_capacity_reviewer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT } let(:reduced_capacity_traintainer_count) { described_class::TRAINTAINER_WEIGHT } subject(:weighted_reviewers) { described_class.new(reviewers, traintainers).execute } diff --git a/spec/lib/gitlab_danger_spec.rb b/spec/tooling/gitlab_danger_spec.rb index ed668c52a0e..20ac40d1d2a 100644 --- a/spec/lib/gitlab_danger_spec.rb +++ b/spec/tooling/gitlab_danger_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require_relative '../../tooling/gitlab_danger' RSpec.describe GitlabDanger do let(:gitlab_danger_helper) { nil } diff --git a/spec/workers/merge_request_cleanup_refs_worker_spec.rb b/spec/workers/merge_request_cleanup_refs_worker_spec.rb index 88d7322536b..7401c6dd4d7 100644 --- a/spec/workers/merge_request_cleanup_refs_worker_spec.rb +++ b/spec/workers/merge_request_cleanup_refs_worker_spec.rb @@ -17,6 +17,18 @@ RSpec.describe MergeRequestCleanupRefsWorker do subject end end + + context 'when merge_request_refs_cleanup flag is disabled' do + before do + stub_feature_flags(merge_request_refs_cleanup: false) + end + + it 'does not clean up the merge request' do + expect(MergeRequests::CleanupRefsService).not_to receive(:new) + + perform_multiple(1) + end + end end context 'when merge request does not exist' do diff --git a/spec/workers/schedule_merge_request_cleanup_refs_worker_spec.rb b/spec/workers/schedule_merge_request_cleanup_refs_worker_spec.rb index 0dd50efba1c..869818b257e 100644 --- a/spec/workers/schedule_merge_request_cleanup_refs_worker_spec.rb +++ b/spec/workers/schedule_merge_request_cleanup_refs_worker_spec.rb @@ -20,6 +20,18 @@ RSpec.describe ScheduleMergeRequestCleanupRefsWorker do worker.perform end + context 'when merge_request_refs_cleanup flag is disabled' do + before do + stub_feature_flags(merge_request_refs_cleanup: false) + end + + it 'does not schedule any merge request clean ups' do + expect(MergeRequestCleanupRefsWorker).not_to receive(:bulk_perform_in) + + worker.perform + end + end + include_examples 'an idempotent worker' do it 'schedules MergeRequestCleanupRefsWorker to be performed by batch' do expect(MergeRequestCleanupRefsWorker) diff --git a/lib/gitlab/danger/base_linter.rb b/tooling/danger/base_linter.rb index 898434724bd..c58f2d84dc8 100644 --- a/lib/gitlab/danger/base_linter.rb +++ b/tooling/danger/base_linter.rb @@ -2,7 +2,7 @@ require_relative 'title_linting' -module Gitlab +module Tooling module Danger class BaseLinter MIN_SUBJECT_WORDS_COUNT = 3 diff --git a/lib/gitlab/danger/changelog.rb b/tooling/danger/changelog.rb index 4b85775ed98..f7f505f51a6 100644 --- a/lib/gitlab/danger/changelog.rb +++ b/tooling/danger/changelog.rb @@ -2,7 +2,7 @@ require_relative 'title_linting' -module Gitlab +module Tooling module Danger module Changelog NO_CHANGELOG_LABELS = [ diff --git a/lib/gitlab/danger/commit_linter.rb b/tooling/danger/commit_linter.rb index e23f5900433..905031ec881 100644 --- a/lib/gitlab/danger/commit_linter.rb +++ b/tooling/danger/commit_linter.rb @@ -1,17 +1,9 @@ # frozen_string_literal: true -emoji_checker_path = File.expand_path('emoji_checker', __dir__) -base_linter_path = File.expand_path('base_linter', __dir__) - -if defined?(Rails) - require_dependency(base_linter_path) - require_dependency(emoji_checker_path) -else - require_relative(base_linter_path) - require_relative(emoji_checker_path) -end +require_relative 'base_linter' +require_relative 'emoji_checker' -module Gitlab +module Tooling module Danger class CommitLinter < BaseLinter MAX_CHANGED_FILES_IN_COMMIT = 3 @@ -151,7 +143,7 @@ module Gitlab end def emoji_checker - @emoji_checker ||= Gitlab::Danger::EmojiChecker.new + @emoji_checker ||= Tooling::Danger::EmojiChecker.new end end end diff --git a/lib/gitlab/danger/emoji_checker.rb b/tooling/danger/emoji_checker.rb index e31a6ae5011..9d8ff93037c 100644 --- a/lib/gitlab/danger/emoji_checker.rb +++ b/tooling/danger/emoji_checker.rb @@ -2,11 +2,11 @@ require 'json' -module Gitlab +module Tooling module Danger class EmojiChecker - DIGESTS = File.expand_path('../../../fixtures/emojis/digests.json', __dir__) - ALIASES = File.expand_path('../../../fixtures/emojis/aliases.json', __dir__) + DIGESTS = File.expand_path('../../fixtures/emojis/digests.json', __dir__) + ALIASES = File.expand_path('../../fixtures/emojis/aliases.json', __dir__) # A regex that indicates a piece of text _might_ include an Emoji. The regex # alone is not enough, as we'd match `:foo:bar:baz`. Instead, we use this diff --git a/lib/gitlab/danger/helper.rb b/tooling/danger/helper.rb index 09e013e24b8..e50d5af3b6f 100644 --- a/lib/gitlab/danger/helper.rb +++ b/tooling/danger/helper.rb @@ -3,7 +3,7 @@ require_relative 'teammate' require_relative 'title_linting' -module Gitlab +module Tooling module Danger module Helper RELEASE_TOOLS_BOT = 'gitlab-release-tools-bot' @@ -171,7 +171,7 @@ module Gitlab %r{\Alefthook.yml\z} => :engineering_productivity, %r{\A\.editorconfig\z} => :engineering_productivity, %r{Dangerfile\z} => :engineering_productivity, - %r{\A(ee/)?(danger/|lib/gitlab/danger/)} => :engineering_productivity, + %r{\A(ee/)?(danger/|tooling/danger/)} => :engineering_productivity, %r{\A(ee/)?scripts/} => :engineering_productivity, %r{\Atooling/} => :engineering_productivity, %r{(CODEOWNERS)} => :engineering_productivity, @@ -213,7 +213,7 @@ module Gitlab }.freeze def new_teammates(usernames) - usernames.map { |u| Gitlab::Danger::Teammate.new('username' => u) } + usernames.map { |u| Tooling::Danger::Teammate.new('username' => u) } end def draft_mr? diff --git a/lib/gitlab/danger/merge_request_linter.rb b/tooling/danger/merge_request_linter.rb index ed354bfc68d..ddeb9cc2981 100644 --- a/lib/gitlab/danger/merge_request_linter.rb +++ b/tooling/danger/merge_request_linter.rb @@ -1,14 +1,8 @@ # frozen_string_literal: true -base_linter_path = File.expand_path('base_linter', __dir__) +require_relative 'base_linter' -if defined?(Rails) - require_dependency(base_linter_path) -else - require_relative(base_linter_path) -end - -module Gitlab +module Tooling module Danger class MergeRequestLinter < BaseLinter alias_method :lint, :lint_subject diff --git a/lib/gitlab/danger/request_helper.rb b/tooling/danger/request_helper.rb index 06da4ed9ad3..d6b99f562f9 100644 --- a/lib/gitlab/danger/request_helper.rb +++ b/tooling/danger/request_helper.rb @@ -3,7 +3,7 @@ require 'net/http' require 'json' -module Gitlab +module Tooling module Danger module RequestHelper HTTPError = Class.new(RuntimeError) diff --git a/lib/gitlab/danger/roulette.rb b/tooling/danger/roulette.rb index 21feda2cf20..c58130ae804 100644 --- a/lib/gitlab/danger/roulette.rb +++ b/tooling/danger/roulette.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true require_relative 'teammate' -require_relative 'request_helper' unless defined?(Gitlab::Danger::RequestHelper) +require_relative 'request_helper' require_relative 'weightage/reviewers' require_relative 'weightage/maintainers' -module Gitlab +module Tooling module Danger module Roulette ROULETTE_DATA_URL = 'https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json' @@ -72,8 +72,8 @@ module Gitlab def team @team ||= begin - data = Gitlab::Danger::RequestHelper.http_get_json(ROULETTE_DATA_URL) - data.map { |hash| ::Gitlab::Danger::Teammate.new(hash) } + data = Tooling::Danger::RequestHelper.http_get_json(ROULETTE_DATA_URL) + data.map { |hash| ::Tooling::Danger::Teammate.new(hash) } rescue JSON::ParserError raise "Failed to parse JSON response from #{ROULETTE_DATA_URL}" end diff --git a/lib/gitlab/danger/sidekiq_queues.rb b/tooling/danger/sidekiq_queues.rb index 726b6134abf..ae32b128682 100644 --- a/lib/gitlab/danger/sidekiq_queues.rb +++ b/tooling/danger/sidekiq_queues.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Gitlab +module Tooling module Danger module SidekiqQueues def changed_queue_files diff --git a/lib/gitlab/danger/teammate.rb b/tooling/danger/teammate.rb index 911b84d93ec..beeb508e9f9 100644 --- a/lib/gitlab/danger/teammate.rb +++ b/tooling/danger/teammate.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Gitlab +module Tooling module Danger class Teammate attr_reader :options, :username, :name, :role, :projects, :available, :hungry, :reduced_capacity, :tz_offset_hours diff --git a/lib/gitlab/danger/title_linting.rb b/tooling/danger/title_linting.rb index db1ccaaf9a9..0cff16f4c6b 100644 --- a/lib/gitlab/danger/title_linting.rb +++ b/tooling/danger/title_linting.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Gitlab +module Tooling module Danger module TitleLinting DRAFT_REGEX = /\A*#{Regexp.union(/(?i)(\[WIP\]\s*|WIP:\s*|WIP$)/, /(?i)(\[draft\]|\(draft\)|draft:|draft\s\-\s|draft$)/)}+\s*/i.freeze diff --git a/lib/gitlab/danger/weightage.rb b/tooling/danger/weightage.rb index 67fade27573..cf8d17410dc 100644 --- a/lib/gitlab/danger/weightage.rb +++ b/tooling/danger/weightage.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Gitlab +module Tooling module Danger module Weightage CAPACITY_MULTIPLIER = 2 # change this number to change what it means to be a reduced capacity reviewer 1/this number diff --git a/lib/gitlab/danger/weightage/maintainers.rb b/tooling/danger/weightage/maintainers.rb index cc0eb370e7a..068b24e7913 100644 --- a/lib/gitlab/danger/weightage/maintainers.rb +++ b/tooling/danger/weightage/maintainers.rb @@ -2,7 +2,7 @@ require_relative '../weightage' -module Gitlab +module Tooling module Danger module Weightage class Maintainers diff --git a/lib/gitlab/danger/weightage/reviewers.rb b/tooling/danger/weightage/reviewers.rb index c8019be716e..e74fce37187 100644 --- a/lib/gitlab/danger/weightage/reviewers.rb +++ b/tooling/danger/weightage/reviewers.rb @@ -2,7 +2,7 @@ require_relative '../weightage' -module Gitlab +module Tooling module Danger module Weightage # Weights after (current multiplier of 2) diff --git a/lib/gitlab_danger.rb b/tooling/gitlab_danger.rb index b0974e02edd..ca62e93a59d 100644 --- a/lib/gitlab_danger.rb +++ b/tooling/gitlab_danger.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true +# rubocop:todo Gitlab/NamespacedClass class GitlabDanger LOCAL_RULES ||= %w[ changes_size documentation - frozen_string duplicate_yarn_dependencies prettier eslint |