From ae192a2f1410b5f71397a64df76238b9d3b0afbe Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 8 Jun 2022 06:08:10 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .gitlab/ci/qa.gitlab-ci.yml | 30 +++- .../lint/redundant_cop_disable_directive.yml | 16 --- .rubocop_todo/rails/file_path.yml | 1 - .rubocop_todo/rails/pluck.yml | 3 - .rubocop_todo/rails/redundant_foreign_key.yml | 1 - .../rails/skips_model_validations.yml | 11 -- .rubocop_todo/rails/time_zone.yml | 22 --- app/assets/javascripts/merge_request_tabs.js | 3 + app/controllers/admin/dashboard_controller.rb | 2 - .../concerns/integrations/actions.rb | 2 - app/controllers/concerns/issues_calendar.rb | 2 - app/controllers/concerns/snippets_actions.rb | 2 - app/controllers/concerns/wiki_actions.rb | 2 +- app/controllers/import/fogbugz_controller.rb | 2 - app/controllers/import/github_controller.rb | 2 - app/controllers/projects/issues_controller.rb | 4 +- app/controllers/projects/jobs_controller.rb | 2 - .../projects/pipeline_schedules_controller.rb | 2 - .../projects/pipelines/tests_controller.rb | 2 - app/controllers/search_controller.rb | 2 - app/controllers/sessions_controller.rb | 2 - app/helpers/form_helper.rb | 15 ++ app/views/admin/dashboard/index.html.haml | 6 +- app/views/ci/variables/_index.html.haml | 2 +- .../projects/merge_requests/show.html.haml | 2 +- doc/ci/cloud_deployment/index.md | 130 +++++++++--------- doc/topics/autodevops/requirements.md | 2 +- .../ci/templates/Deploy-ECS.gitlab-ci.yml | 4 +- lib/gitlab/regex.rb | 6 +- lib/gitlab/usage_data.rb | 15 +- lib/gitlab/usage_data_queries.rb | 10 ++ spec/frontend/merge_request_tabs_spec.js | 22 +++ spec/helpers/form_helper_spec.rb | 37 +++++ spec/lib/gitlab/regex_spec.rb | 6 +- .../gitlab/usage/service_ping_report_spec.rb | 5 + spec/lib/gitlab/usage_data_queries_spec.rb | 21 +++ .../destination/objectstore/multipart.go | 4 +- 37 files changed, 233 insertions(+), 169 deletions(-) diff --git a/.gitlab/ci/qa.gitlab-ci.yml b/.gitlab/ci/qa.gitlab-ci.yml index 1ebc408e0d4..c93aa6c4d19 100644 --- a/.gitlab/ci/qa.gitlab-ci.yml +++ b/.gitlab/ci/qa.gitlab-ci.yml @@ -52,7 +52,6 @@ qa:nightly-auto-quarantine-dequarantine: - bundle exec confiner -r .confiner/nightly.yml allow_failure: true - qa:selectors-as-if-foss: extends: - qa:selectors @@ -68,6 +67,28 @@ update-qa-cache: script: - echo "Cache has been updated and ready to be uploaded." +populate-qa-tests-var: + image: ${GITLAB_DEPENDENCY_PROXY}ruby:2.7-alpine + stage: prepare + script: + - tooling/bin/qa/check_if_qa_only_spec_changes ${CHANGES_FILE} ${ONLY_QA_CHANGES_FILE} + - '[ -f $ONLY_QA_CHANGES_FILE ] && export QA_TESTS="`cat $ONLY_QA_CHANGES_FILE`"' + - 'echo "QA_TESTS=$QA_TESTS" >> qa_tests_var.env' + - 'echo "QA_TESTS: $QA_TESTS"' + artifacts: + expire_in: 2d + reports: + dotenv: qa_tests_var.env + paths: + - ${CHANGES_FILE} + - ${ONLY_QA_CHANGES_FILE} + - qa_tests_var.env + variables: + CHANGES_FILE: tmp/changed_files.txt + ONLY_QA_CHANGES_FILE: tmp/qa_only_changed_files.txt + needs: + - detect-tests + .package-and-qa-base: image: ${GITLAB_DEPENDENCY_PROXY}ruby:2.7-alpine stage: qa @@ -77,8 +98,6 @@ update-qa-cache: - install_gitlab_gem - tooling/bin/find_change_diffs ${CHANGES_DIFFS_DIR} script: - - tooling/bin/qa/check_if_qa_only_spec_changes ${CHANGES_FILE} ${ONLY_QA_CHANGES_FILE} - - '[ -f $ONLY_QA_CHANGES_FILE ] && export QA_TESTS="`cat $ONLY_QA_CHANGES_FILE`"' - 'echo "QA_TESTS: $QA_TESTS"' - exit_code=0 && tooling/bin/qa/package_and_qa_check ${CHANGES_DIFFS_DIR} || exit_code=$? - echo $exit_code @@ -99,16 +118,13 @@ update-qa-cache: artifacts: false - job: build-assets-image artifacts: false + - job: populate-qa-tests-var - detect-tests artifacts: expire_in: 7d paths: - - ${CHANGES_FILE} - - ${ONLY_QA_CHANGES_FILE} - ${CHANGES_DIFFS_DIR}/* variables: - CHANGES_FILE: tmp/changed_files.txt - ONLY_QA_CHANGES_FILE: tmp/qa_only_changed_files.txt CHANGES_DIFFS_DIR: tmp/diffs ALLURE_JOB_NAME: $CI_JOB_NAME diff --git a/.rubocop_todo/lint/redundant_cop_disable_directive.yml b/.rubocop_todo/lint/redundant_cop_disable_directive.yml index 83901a6843e..d058e23109b 100644 --- a/.rubocop_todo/lint/redundant_cop_disable_directive.yml +++ b/.rubocop_todo/lint/redundant_cop_disable_directive.yml @@ -6,22 +6,6 @@ Lint/RedundantCopDisableDirective: # REVEAL_RUBOCOP_TODO environment variable. Enabled: false Exclude: - - 'app/controllers/admin/dashboard_controller.rb' - - 'app/controllers/concerns/enforces_two_factor_authentication.rb' - - 'app/controllers/concerns/integrations/actions.rb' - - 'app/controllers/concerns/issues_calendar.rb' - - 'app/controllers/concerns/snippets_actions.rb' - - 'app/controllers/concerns/wiki_actions.rb' - - 'app/controllers/groups/autocomplete_sources_controller.rb' - - 'app/controllers/groups/labels_controller.rb' - - 'app/controllers/import/fogbugz_controller.rb' - - 'app/controllers/import/github_controller.rb' - - 'app/controllers/projects/issues_controller.rb' - - 'app/controllers/projects/jobs_controller.rb' - - 'app/controllers/projects/pipeline_schedules_controller.rb' - - 'app/controllers/projects/pipelines/tests_controller.rb' - - 'app/controllers/search_controller.rb' - - 'app/controllers/sessions_controller.rb' - 'app/finders/autocomplete/acts_as_taggable_on/tags_finder.rb' - 'app/finders/autocomplete/move_to_project_finder.rb' - 'app/finders/autocomplete/routes_finder.rb' diff --git a/.rubocop_todo/rails/file_path.yml b/.rubocop_todo/rails/file_path.yml index e91d3df22bb..1c442dcdec7 100644 --- a/.rubocop_todo/rails/file_path.yml +++ b/.rubocop_todo/rails/file_path.yml @@ -45,7 +45,6 @@ Rails/FilePath: - 'ee/spec/requests/api/experiments_spec.rb' - 'ee/spec/services/ee/merge_requests/refresh_service_spec.rb' - 'ee/spec/support/factory_bot.rb' - - 'ee/spec/uploaders/every_gitlab_uploader_spec.rb' - 'ee/spec/validators/json_schema_validator_spec.rb' - 'lib/api/api.rb' - 'lib/error_tracking/collector/payload_validator.rb' diff --git a/.rubocop_todo/rails/pluck.yml b/.rubocop_todo/rails/pluck.yml index 608801085d4..860b772d913 100644 --- a/.rubocop_todo/rails/pluck.yml +++ b/.rubocop_todo/rails/pluck.yml @@ -15,13 +15,10 @@ Rails/Pluck: - 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb' - 'app/services/feature_flags/update_service.rb' - 'app/services/pod_logs/base_service.rb' - - 'app/services/prometheus/create_default_alerts_service.rb' - 'ee/app/graphql/mutations/incident_management/oncall_rotation/base.rb' - 'ee/app/models/boards/epic_list.rb' - - 'ee/app/models/vulnerabilities/finding.rb' - 'ee/app/services/concerns/incident_management/oncall_rotations/shared_rotation_logic.rb' - 'ee/app/workers/geo/container_repository_sync_dispatch_worker.rb' - - 'ee/app/workers/geo/file_download_dispatch_worker.rb' - 'ee/app/workers/geo/registry_sync_worker.rb' - 'ee/app/workers/geo/repository_shard_sync_worker.rb' - 'ee/app/workers/geo/repository_verification/secondary/shard_worker.rb' diff --git a/.rubocop_todo/rails/redundant_foreign_key.yml b/.rubocop_todo/rails/redundant_foreign_key.yml index 6b2300ba792..db6e6cedc89 100644 --- a/.rubocop_todo/rails/redundant_foreign_key.yml +++ b/.rubocop_todo/rails/redundant_foreign_key.yml @@ -52,7 +52,6 @@ Rails/RedundantForeignKey: - 'ee/app/models/incident_management/oncall_shift.rb' - 'ee/app/models/incident_management/pending_escalations/alert.rb' - 'ee/app/models/incident_management/pending_escalations/issue.rb' - - 'ee/app/models/incident_management/timeline_event.rb' - 'ee/app/models/issuable_metric_image.rb' - 'ee/app/models/security/orchestration_policy_configuration.rb' - 'ee/app/models/security/orchestration_policy_rule_schedule.rb' diff --git a/.rubocop_todo/rails/skips_model_validations.yml b/.rubocop_todo/rails/skips_model_validations.yml index f84d00a8628..75a0d49862e 100644 --- a/.rubocop_todo/rails/skips_model_validations.yml +++ b/.rubocop_todo/rails/skips_model_validations.yml @@ -103,11 +103,9 @@ Rails/SkipsModelValidations: - 'app/services/keys/last_used_service.rb' - 'app/services/labels/promote_service.rb' - 'app/services/labels/transfer_service.rb' - - 'app/services/merge_requests/base_service.rb' - 'app/services/merge_requests/bulk_remove_attention_requested_service.rb' - 'app/services/merge_requests/cleanup_refs_service.rb' - 'app/services/merge_requests/ff_merge_service.rb' - - 'app/services/merge_requests/handle_assignees_change_service.rb' - 'app/services/merge_requests/merge_service.rb' - 'app/services/merge_requests/rebase_service.rb' - 'app/services/merge_requests/reopen_service.rb' @@ -222,7 +220,6 @@ Rails/SkipsModelValidations: - 'ee/app/services/ee/users/migrate_to_ghost_user_service.rb' - 'ee/app/services/epics/strategies/due_date_inherited_strategy.rb' - 'ee/app/services/epics/strategies/start_date_inherited_strategy.rb' - - 'ee/app/services/geo/job_artifact_deleted_event_store.rb' - 'ee/app/services/geo/repository_verification_reset.rb' - 'ee/app/services/incident_management/oncall_rotations/edit_service.rb' - 'ee/app/services/incident_management/oncall_rotations/remove_participant_service.rb' @@ -291,9 +288,6 @@ Rails/SkipsModelValidations: - 'ee/spec/lib/gitlab/custom_file_templates_spec.rb' - 'ee/spec/lib/gitlab/geo/geo_tasks_spec.rb' - 'ee/spec/lib/gitlab/geo/jwt_request_decoder_spec.rb' - - 'ee/spec/lib/gitlab/geo/replication/file_downloader_spec.rb' - - 'ee/spec/lib/gitlab/geo/replication/file_transfer_spec.rb' - - 'ee/spec/lib/gitlab/geo/replication/job_artifact_downloader_spec.rb' - 'ee/spec/lib/gitlab/geo/signed_data_spec.rb' - 'ee/spec/lib/gitlab/git_access_spec.rb' - 'ee/spec/models/application_setting_spec.rb' @@ -305,7 +299,6 @@ Rails/SkipsModelValidations: - 'ee/spec/models/ee/groups/feature_setting_spec.rb' - 'ee/spec/models/ee/iteration_spec.rb' - 'ee/spec/models/ee/iterations/cadence_spec.rb' - - 'ee/spec/models/ee/key_spec.rb' - 'ee/spec/models/ee/namespace_limit_spec.rb' - 'ee/spec/models/ee/vulnerability_spec.rb' - 'ee/spec/models/geo_node_spec.rb' @@ -348,7 +341,6 @@ Rails/SkipsModelValidations: - 'ee/spec/services/epic_issues/update_service_spec.rb' - 'ee/spec/services/epics/issue_promote_service_spec.rb' - 'ee/spec/services/epics/update_service_spec.rb' - - 'ee/spec/services/geo/file_download_service_spec.rb' - 'ee/spec/services/geo/file_registry_removal_service_spec.rb' - 'ee/spec/services/geo/hashed_storage_migration_service_spec.rb' - 'ee/spec/services/groups/create_service_spec.rb' @@ -379,7 +371,6 @@ Rails/SkipsModelValidations: - 'ee/spec/workers/import_software_licenses_worker_spec.rb' - 'ee/spec/workers/iterations/roll_over_issues_worker_spec.rb' - 'ee/spec/workers/iterations_update_status_worker_spec.rb' - - 'ee/spec/workers/network_policy_metrics_worker_spec.rb' - 'ee/spec/workers/security/orchestration_policy_rule_schedule_namespace_worker_spec.rb' - 'ee/spec/workers/security/orchestration_policy_rule_schedule_worker_spec.rb' - 'ee/spec/workers/update_all_mirrors_worker_spec.rb' @@ -484,9 +475,7 @@ Rails/SkipsModelValidations: - 'spec/features/projects/diffs/diff_show_spec.rb' - 'spec/features/projects/features_visibility_spec.rb' - 'spec/features/projects/fork_spec.rb' - - 'spec/features/projects/jobs/user_browses_jobs_spec.rb' - 'spec/features/projects/jobs_spec.rb' - - 'spec/features/projects/members/invite_group_spec.rb' - 'spec/features/projects/milestones/milestone_spec.rb' - 'spec/features/projects/pipeline_schedules_spec.rb' - 'spec/features/projects/pipelines/pipeline_spec.rb' diff --git a/.rubocop_todo/rails/time_zone.yml b/.rubocop_todo/rails/time_zone.yml index ff97dfeb444..48e559312f8 100644 --- a/.rubocop_todo/rails/time_zone.yml +++ b/.rubocop_todo/rails/time_zone.yml @@ -6,7 +6,6 @@ Rails/TimeZone: - ee/lib/delay.rb - ee/lib/gitlab/elastic/helper.rb - ee/lib/gitlab/elastic/indexer.rb - - ee/lib/gitlab/geo/base_request.rb - ee/lib/gitlab/geo/event_gap_tracking.rb - ee/lib/gitlab/geo/log_cursor/events/design_repository_updated_event.rb - ee/lib/gitlab/geo/log_cursor/events/repository_updated_event.rb @@ -17,11 +16,9 @@ Rails/TimeZone: - ee/spec/lib/ee/gitlab/ci/pipeline/quota/job_activity_spec.rb - ee/spec/lib/gitlab/analytics/cycle_analytics/data_collector_spec.rb - ee/spec/lib/gitlab/analytics/cycle_analytics/summary/group/stage_summary_spec.rb - - ee/spec/lib/gitlab/analytics/cycle_analytics/summary/group/stage_time_summary_spec.rb - ee/spec/lib/gitlab/auth/ldap/access_spec.rb - ee/spec/lib/gitlab/auth/smartcard/san_extension_spec.rb - ee/spec/lib/gitlab/auth/smartcard/session_spec.rb - - ee/spec/lib/gitlab/background_migration/fix_orphan_promoted_issues_spec.rb - ee/spec/lib/gitlab/ci/pipeline/chain/limit/job_activity_spec.rb - ee/spec/lib/gitlab/elastic/client_spec.rb - ee/spec/lib/gitlab/geo/base_request_spec.rb @@ -31,8 +28,6 @@ Rails/TimeZone: - ee/spec/lib/gitlab/geo/log_cursor/events/event_spec.rb - ee/spec/lib/gitlab/geo/log_cursor/events/hashed_storage_attachments_event_spec.rb - ee/spec/lib/gitlab/geo/log_cursor/events/hashed_storage_migrated_event_spec.rb - - ee/spec/lib/gitlab/geo/log_cursor/events/job_artifact_deleted_event_spec.rb - - ee/spec/lib/gitlab/geo/log_cursor/events/lfs_object_deleted_event_spec.rb - ee/spec/lib/gitlab/geo/log_cursor/events/repositories_changed_event_spec.rb - ee/spec/lib/gitlab/geo/log_cursor/events/repository_created_event_spec.rb - ee/spec/lib/gitlab/geo/log_cursor/events/repository_deleted_event_spec.rb @@ -51,23 +46,17 @@ Rails/TimeZone: - lib/gitlab/auth/ldap/access.rb - lib/gitlab/chaos.rb - lib/gitlab/checks/timed_logger.rb - - lib/gitlab/ci/ansi2json/line.rb - - lib/gitlab/ci/pipeline/chain/sequence.rb - lib/gitlab/ci/pipeline/duration.rb - - lib/gitlab/cycle_analytics/summary/deployment_frequency.rb - lib/gitlab/database.rb - lib/gitlab/external_authorization/access.rb - lib/gitlab/external_authorization/cache.rb - lib/gitlab/gitaly_client.rb - lib/gitlab/gitaly_client/ref_service.rb - lib/gitlab/github_import/representation.rb - - lib/gitlab/grape_logging/loggers/queue_duration_logger.rb - lib/gitlab/health_checks/base_abstract_check.rb - lib/gitlab/import_export.rb - lib/gitlab/instrumentation/elasticsearch_transport.rb - - lib/gitlab/instrumentation/redis_interceptor.rb - lib/gitlab/instrumentation_helper.rb - - lib/gitlab/kubernetes/helm/certificate.rb - lib/gitlab/lfs_token.rb - lib/gitlab/loop_helpers.rb - lib/gitlab/phabricator_import/representation/task.rb @@ -80,8 +69,6 @@ Rails/TimeZone: - lib/json_web_token/token.rb - lib/object_storage/direct_upload.rb - lib/quality/seeders/issues.rb - - tooling/rspec_flaky/flaky_example.rb - - tooling/rspec_flaky/report.rb - lib/tasks/gitlab/assets.rake - lib/tasks/gitlab/backup.rake - lib/tasks/gitlab/cleanup.rake @@ -91,14 +78,11 @@ Rails/TimeZone: - spec/lib/gitlab/app_json_logger_spec.rb - spec/lib/gitlab/app_text_logger_spec.rb - spec/lib/gitlab/auth/current_user_mode_spec.rb - - spec/lib/gitlab/background_migration/recalculate_project_authorizations_spec.rb - - spec/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer_spec.rb - spec/lib/gitlab/bitbucket_import/importer_spec.rb - spec/lib/gitlab/bitbucket_server_import/importer_spec.rb - spec/lib/gitlab/checks/timed_logger_spec.rb - spec/lib/gitlab/ci/cron_parser_spec.rb - spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb - - spec/lib/gitlab/cycle_analytics/usage_data_spec.rb - spec/lib/gitlab/data_builder/note_spec.rb - spec/lib/gitlab/database/background_migration_job_spec.rb - spec/lib/gitlab/database_spec.rb @@ -111,7 +95,6 @@ Rails/TimeZone: - spec/lib/gitlab/git/commit_spec.rb - spec/lib/gitlab/git/repository_spec.rb - spec/lib/gitlab/git_access_spec.rb - - spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb - spec/lib/gitlab/github_import/importer/issue_importer_spec.rb - spec/lib/gitlab/github_import/importer/issues_importer_spec.rb - spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb @@ -132,19 +115,14 @@ Rails/TimeZone: - spec/lib/gitlab/lfs_token_spec.rb - spec/lib/gitlab/log_timestamp_formatter_spec.rb - spec/lib/gitlab/middleware/rails_queue_duration_spec.rb - - spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb - spec/lib/gitlab/phabricator_import/issues/task_importer_spec.rb - spec/lib/gitlab/phabricator_import/representation/task_spec.rb - spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb - spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb - spec/lib/gitlab/prometheus/queries/validate_query_spec.rb - spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb - - spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb - spec/lib/gitlab/updated_notes_paginator_spec.rb - spec/lib/gitlab/utils/json_size_estimator_spec.rb - spec/lib/gitlab/x509/signature_spec.rb - spec/lib/grafana/time_window_spec.rb - spec/lib/json_web_token/hmac_token_spec.rb - - spec/tooling/rspec_flaky/flaky_example_spec.rb - - spec/tooling/rspec_flaky/listener_spec.rb - - spec/tooling/rspec_flaky/report_spec.rb diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index e02109d1fd1..94041d77bb0 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -177,6 +177,7 @@ export default class MergeRequestTabs { this.peek = document.getElementById('js-peek'); this.sidebar = document.querySelector('.js-right-sidebar'); this.pageLayout = document.querySelector('.layout-page'); + this.expandSidebar = document.querySelector('.js-expand-sidebar'); this.paddingTop = 16; this.scrollPositions = {}; @@ -281,6 +282,8 @@ export default class MergeRequestTabs { const tab = this.mergeRequestTabs.querySelector(`.${action}-tab`); if (tab) tab.classList.add('active'); + this.expandSidebar?.classList.toggle('gl-display-none!', action !== 'show'); + if (action === 'commits') { this.loadCommits(href); // this.hideSidebar(); diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 20e36e5fd84..8fe106249c3 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -7,7 +7,6 @@ class Admin::DashboardController < Admin::ApplicationController feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned - # rubocop: disable CodeReuse/ActiveRecord def index @counts = Gitlab::Database::Count.approximate_counts(COUNTED_ITEMS) @projects = Project.order_id_desc.without_deleted.with_route.limit(10) @@ -24,7 +23,6 @@ class Admin::DashboardController < Admin::ApplicationController Gitlab::Redis::Sessions ].map(&:version).uniq end - # rubocop: enable CodeReuse/ActiveRecord def stats @users_statistics = UsersStatistics.latest diff --git a/app/controllers/concerns/integrations/actions.rb b/app/controllers/concerns/integrations/actions.rb index 1f788860c8f..e0a12555e11 100644 --- a/app/controllers/concerns/integrations/actions.rb +++ b/app/controllers/concerns/integrations/actions.rb @@ -51,11 +51,9 @@ module Integrations::Actions private - # rubocop:disable Gitlab/ModuleWithInstanceVariables def integration @integration ||= find_or_initialize_non_project_specific_integration(params[:id]) end - # rubocop:enable Gitlab/ModuleWithInstanceVariables def success_message if integration.active? diff --git a/app/controllers/concerns/issues_calendar.rb b/app/controllers/concerns/issues_calendar.rb index 1fdfde4c869..51d6d3cf05a 100644 --- a/app/controllers/concerns/issues_calendar.rb +++ b/app/controllers/concerns/issues_calendar.rb @@ -4,7 +4,6 @@ module IssuesCalendar extend ActiveSupport::Concern # rubocop:disable Gitlab/ModuleWithInstanceVariables - # rubocop: disable CodeReuse/ActiveRecord def render_issues_calendar(issuables) @issues = issuables .non_archived @@ -23,6 +22,5 @@ module IssuesCalendar end end end - # rubocop: enable CodeReuse/ActiveRecord # rubocop:enable Gitlab/ModuleWithInstanceVariables end diff --git a/app/controllers/concerns/snippets_actions.rb b/app/controllers/concerns/snippets_actions.rb index 0ee8d0c9307..1bb81a46e50 100644 --- a/app/controllers/concerns/snippets_actions.rb +++ b/app/controllers/concerns/snippets_actions.rb @@ -75,7 +75,6 @@ module SnippetsActions private - # rubocop:disable Gitlab/ModuleWithInstanceVariables def blob @blob ||= blobs.first end @@ -87,7 +86,6 @@ module SnippetsActions snippet.blobs end end - # rubocop:enable Gitlab/ModuleWithInstanceVariables def convert_line_endings(content) params[:line_ending] == 'raw' ? content : content.gsub(/\r\n/, "\n") diff --git a/app/controllers/concerns/wiki_actions.rb b/app/controllers/concerns/wiki_actions.rb index 9fc8886aaee..83447744013 100644 --- a/app/controllers/concerns/wiki_actions.rb +++ b/app/controllers/concerns/wiki_actions.rb @@ -167,7 +167,7 @@ module WikiActions render 'shared/wikis/diff' end - # rubocop:disable Gitlab/ModuleWithInstanceVariables + # rubocop:enable Gitlab/ModuleWithInstanceVariables # rubocop:disable Gitlab/ModuleWithInstanceVariables def destroy diff --git a/app/controllers/import/fogbugz_controller.rb b/app/controllers/import/fogbugz_controller.rb index 9a457cf673c..b949a99c250 100644 --- a/app/controllers/import/fogbugz_controller.rb +++ b/app/controllers/import/fogbugz_controller.rb @@ -44,7 +44,6 @@ class Import::FogbugzController < Import::BaseController redirect_to status_import_fogbugz_path end - # rubocop: disable CodeReuse/ActiveRecord def status unless client.valid? return redirect_to new_import_fogbugz_path @@ -52,7 +51,6 @@ class Import::FogbugzController < Import::BaseController super end - # rubocop: enable CodeReuse/ActiveRecord def create credentials = { uri: session[:fogbugz_uri], token: session[:fogbugz_token] } diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb index 9bd8f893614..8dd40b6254e 100644 --- a/app/controllers/import/github_controller.rb +++ b/app/controllers/import/github_controller.rb @@ -76,12 +76,10 @@ class Import::GithubController < Import::BaseController protected - # rubocop: disable CodeReuse/ActiveRecord override :importable_repos def importable_repos client_repos.to_a end - # rubocop: enable CodeReuse/ActiveRecord override :incompatible_repos def incompatible_repos diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 3f4337a5dd9..54b9f4eff27 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -251,8 +251,8 @@ class Projects::IssuesController < Projects::ApplicationController end def service_desk - @issues = @issuables # rubocop:disable Gitlab/ModuleWithInstanceVariables - @users.push(User.support_bot) # rubocop:disable Gitlab/ModuleWithInstanceVariables + @issues = @issuables + @users.push(User.support_bot) end protected diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index c7e983d3960..9574c5d5849 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -42,7 +42,6 @@ class Projects::JobsController < Projects::ApplicationController @builds = @builds.page(params[:page]).per(30).without_count end - # rubocop: disable CodeReuse/ActiveRecord def show respond_to do |format| format.html @@ -55,7 +54,6 @@ class Projects::JobsController < Projects::ApplicationController end end end - # rubocop: enable CodeReuse/ActiveRecord def trace @build.trace.being_watched! if @build.running? diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index fa38fb209f0..a23d7fb3e6b 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -14,13 +14,11 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController feature_category :continuous_integration urgency :low - # rubocop: disable CodeReuse/ActiveRecord def index @scope = params[:scope] @all_schedules = Ci::PipelineSchedulesFinder.new(@project).execute @schedules = Ci::PipelineSchedulesFinder.new(@project).execute(scope: params[:scope]) end - # rubocop: enable CodeReuse/ActiveRecord def new @schedule = project.pipeline_schedules.new diff --git a/app/controllers/projects/pipelines/tests_controller.rb b/app/controllers/projects/pipelines/tests_controller.rb index fd9dbb49497..e5b2dd14f69 100644 --- a/app/controllers/projects/pipelines/tests_controller.rb +++ b/app/controllers/projects/pipelines/tests_controller.rb @@ -36,7 +36,6 @@ module Projects private - # rubocop: disable CodeReuse/ActiveRecord def builds @builds ||= pipeline.latest_builds.id_in(build_ids).presence || render_404 end @@ -56,7 +55,6 @@ module Projects suite end - # rubocop: enable CodeReuse/ActiveRecord end end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index d50390cac53..7d251ba555c 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -72,7 +72,6 @@ class SearchController < ApplicationController render json: { count: count } end - # rubocop: disable CodeReuse/ActiveRecord def autocomplete term = params[:term] @@ -81,7 +80,6 @@ class SearchController < ApplicationController render json: search_autocomplete_opts(term).to_json end - # rubocop: enable CodeReuse/ActiveRecord def opensearch end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d9d73cb7f80..9000e9c39de 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -183,7 +183,6 @@ class SessionsController < Devise::SessionsController # Handle an "initial setup" state, where there's only one user, it's an admin, # and they require a password change. - # rubocop: disable CodeReuse/ActiveRecord def check_initial_setup return unless User.limit(2).count == 1 # Count as much 2 to know if we have exactly one @@ -198,7 +197,6 @@ class SessionsController < Devise::SessionsController redirect_to edit_user_password_path(reset_password_token: @token), notice: _("Please create a password for your new account.") end - # rubocop: enable CodeReuse/ActiveRecord def ensure_password_authentication_enabled! render_403 unless Gitlab::CurrentSettings.password_authentication_enabled_for_web? diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 3a5dcb4e664..7bf80fa8f92 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -23,6 +23,7 @@ module FormHelper message = html_escape_once(errors.full_message(attribute, message)).html_safe message = tag.span(message, class: 'str-truncated-100') if truncate.include?(attribute) + message = append_help_page_link(message, error.options) if error.options[:help_page_url].present? tag.li(message) end @@ -120,6 +121,20 @@ module FormHelper private + def append_help_page_link(message, options) + help_page_url = options[:help_page_url] + help_link_text = options[:help_link_text] || _('Learn more.') + + help_link = link_to( + help_link_text, + help_page_url, + target: '_blank', + rel: 'noopener noreferrer' + ) + + message + " #{help_link}".html_safe + end + def multiple_assignees_dropdown_options(options) new_options = options.dup diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 75613827ed9..2d1a120b9d3 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -36,7 +36,7 @@ = c.footer do .d-flex.align-items-center = link_to(s_('AdminArea|View latest projects'), admin_projects_path) - = sprite_icon('angle-right', size: 12, css_class: 'gl-text-gray-700 gl-ml-2') + = sprite_icon('chevron-right', size: 12, css_class: 'gl-text-gray-700 gl-ml-2') .col-md-4.gl-mb-6 = render Pajamas::CardComponent.new(**component_params) do |c| = c.body do @@ -59,7 +59,7 @@ = c.footer do .d-flex.align-items-center = link_to(s_('AdminArea|View latest users'), admin_users_path) - = sprite_icon('angle-right', size: 12, css_class: 'gl-text-gray-700 gl-ml-2') + = sprite_icon('chevron-right', size: 12, css_class: 'gl-text-gray-700 gl-ml-2') .col-md-4.gl-mb-6 = render Pajamas::CardComponent.new(**component_params) do |c| = c.body do @@ -72,7 +72,7 @@ = c.footer do .d-flex.align-items-center = link_to(s_('AdminArea|View latest groups'), admin_groups_path) - = sprite_icon('angle-right', size: 12, css_class: 'gl-text-gray-700 gl-ml-2') + = sprite_icon('chevron-right', size: 12, css_class: 'gl-text-gray-700 gl-ml-2') .row .col-md-4.gl-mb-6 #js-admin-statistics-container diff --git a/app/views/ci/variables/_index.html.haml b/app/views/ci/variables/_index.html.haml index 26d1bb7c0d9..9ef2599a2a6 100644 --- a/app/views/ci/variables/_index.html.haml +++ b/app/views/ci/variables/_index.html.haml @@ -13,7 +13,7 @@ maskable_regex: ci_variable_maskable_regex, protected_by_default: ci_variable_protected_by_default?.to_s, aws_logo_svg_path: image_path('aws_logo.svg'), - aws_tip_deploy_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'deploy-your-application-to-the-amazon-elastic-container-service-ecs'), + aws_tip_deploy_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'deploy-your-application-to-ecs'), aws_tip_commands_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'use-an-image-to-run-aws-commands'), aws_tip_learn_link: help_page_path('ci/cloud_deployment/index.md'), contains_variable_reference_link: help_page_path('ci/variables/index', anchor: 'use-variables-in-other-variables'), diff --git a/app/views/projects/merge_requests/show.html.haml b/app/views/projects/merge_requests/show.html.haml index 9672dca7616..604c7ecb6ee 100644 --- a/app/views/projects/merge_requests/show.html.haml +++ b/app/views/projects/merge_requests/show.html.haml @@ -42,7 +42,7 @@ = _("Changes") = gl_badge_tag @diffs_count, { size: :sm } - if Feature.enabled?(:moved_mr_sidebar, @project) - .gl-ml-auto.gl-align-items-center.gl-display-none.gl-md-display-flex{ class: "gl-lg-display-none!" } + .gl-ml-auto.gl-align-items-center.gl-display-none.gl-md-display-flex.js-expand-sidebar{ class: "gl-lg-display-none!" } %button.btn.btn-default.gl-button.btn-sm.js-sidebar-toggle{ type: 'button' } = sprite_icon('angle-double-left', size: 12, css_class: 'gl-mr-2') = _('Expand') diff --git a/doc/ci/cloud_deployment/index.md b/doc/ci/cloud_deployment/index.md index 0844857162a..82c940a1c6d 100644 --- a/doc/ci/cloud_deployment/index.md +++ b/doc/ci/cloud_deployment/index.md @@ -63,7 +63,7 @@ Alternately, you can use an [Amazon Elastic Container Registry (ECR)](https://aw You can also use an image from any third-party registry. -## Deploy your application to the Amazon Elastic Container Service (ECS) +## Deploy your application to ECS > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/207962) in GitLab 12.9. > - The `Deploy-ECS.gitlab-ci.yml` template was [moved](https://gitlab.com/gitlab-org/gitlab/-/issues/220821) to `AWS/Deploy-ECS.gitlab-ci.yml` in GitLab 13.2. @@ -133,47 +133,49 @@ used only with the main template. They may move or change unexpectedly. Also, th these templates may change. Do not override these job names in your own pipeline, because the override stops working when the name changes. -## Deploy your application to Amazon EC2 +## Deploy your application to EC2 > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/201742) in GitLab 13.5. -You can use the `AWS/CF-Provision-and-Deploy-EC2` CI template to perform the -following actions within the same pipeline: +GitLab provides a template, called `AWS/CF-Provision-and-Deploy-EC2`, +to assist you in deploying to Amazon EC2. -1. **Create stack**: Provision your own infrastructure by leveraging the [AWS CloudFormation](https://aws.amazon.com/cloudformation/) API. -1. **Push to S3**: Push your previously-built artifact to an [AWS S3](https://aws.amazon.com/s3/) bucket. -1. **Deploy to EC2**: Deploy this pushed content onto an [AWS EC2](https://aws.amazon.com/ec2/) instance. +When you configure related JSON objects and use the template, the pipeline: + +1. **Creates the stack**: Your infrastructure is provisioned by using + the [AWS CloudFormation](https://aws.amazon.com/cloudformation/) API. +1. **Pushes to an S3 bucket**: When your build runs, it creates an artifact. + The artifact is pushed to an [AWS S3](https://aws.amazon.com/s3/) bucket. +1. **Deploys to EC2**: The content is deployed on an [AWS EC2](https://aws.amazon.com/ec2/) instance. ![CF-Provision-and-Deploy-EC2 diagram](../img/cf_ec2_diagram_v13_5.png) -### Run the `AWS/CF-Provision-and-Deploy-EC2.gitlab-ci.yml` template +### Configure the template and JSON -To run the `AWS/CF-Provision-and-Deploy-EC2.gitlab-ci.yml` template, you must -pass three JSON input objects, based on existing templates: +To deploy to EC2, complete the following steps. -1. The AWS documentation provides templates for the _Create stack_ and _Deploy to EC2_ steps (links - below). We provide the template for the remaining step, _Push to S3_: +1. Create JSON for your stack. Use the [AWS template](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html). +1. Create JSON to push to S3. Include the following details. - - [Template for the _Create stack_ step on AWS](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html). - - Template for the _Push to S3_ step. Note that `source` is where a preceding `build` job built - your application, exporting the build through [`artifacts:paths`](../yaml/index.md#artifactspaths): + ```json + { + "applicationName": "string", + "source": "string", + "s3Location": "s3://your/bucket/project_built_file...]" + } + ``` - ```json - { - "applicationName": "string", - "source": "string", - "s3Location": "s3://your/bucket/project_built_file...]" - } - ``` + The `source` is the location where a `build` job built your application. + The build is saved to [`artifacts:paths`](../yaml/index.md#artifactspaths). - - [Template for the _Deploy to EC2_ step on AWS](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeployment.html). +1. Create JSON to deploy to EC2. Use the [AWS template](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeployment.html). +1. Make the JSON objects accessible to your pipeline: + - If you want these JSON objects saved in your repository, save the objects as three + separate files. -1. After you have completed these three templates based on your requirements, you - have two ways to pass in these JSON objects: - - - They can be three actual files located in your project. You must specify their path relative to - your project root in your `.gitlab-ci.yml` file, using the following CI/CD variables. For example, if - your files are in a `/aws` folder: + In your `.gitlab-ci.yml` file, add [CI/CD variables](../variables/index.md) + that point to the file paths relative to the project root. For example, + if your JSON files are in a `/aws` folder: ```yaml variables: @@ -182,67 +184,65 @@ pass three JSON input objects, based on existing templates: CI_AWS_EC2_DEPLOYMENT_FILE: 'aws/create_deployment.json' ``` - - Alternatively, you can provide these JSON objects as [file-typed CI/CD variables](../variables/index.md#cicd-variable-types). - In your project, go to **Settings > CI/CD > Variables** and add - the three variables listed above as file-typed CI/CD variables. - For each variable, set the value to its corresponding JSON object. + - If you do not want these JSON objects saved in your repository, add each object + as a separate [file type CI/CD variable](../variables/index.md#cicd-variable-types) + in the project settings. Use the same variable names as above. -1. Provide the name of the stack you're creating and/or targeting, as a CI/CD variable: +1. In your `.gitlab-ci.yml` file, create a CI/CD variable for the name of the stack. For example: ```yaml variables: CI_AWS_CF_STACK_NAME: 'YourStackName' ``` -1. Add this CI template to your `.gitlab-ci.yml`: +1. In your `.gitlab-ci.yml` file, add the CI template: ```yaml include: - template: AWS/CF-Provision-and-Deploy-EC2.gitlab-ci.yml ``` -When running your project pipeline at this point: +1. Run the pipeline. -- Your AWS CloudFormation stack is created based on the content of your - `CI_AWS_CF_CREATE_STACK_FILE` file/variable. - If your stack already exists, this step is skipped, but the `provision` job it belongs to still - runs. -- Your built application is pushed to your S3 bucket then and deployed to your EC2 instance, based - on the related JSON object's content. The deployment job finishes whenever the deployment to EC2 - is done or has failed. + - Your AWS CloudFormation stack is created based on the content of your + `CI_AWS_CF_CREATE_STACK_FILE` variable. + If your stack already exists, this step is skipped, but the `provision` + job it belongs to still runs. + - Your built application is pushed to your S3 bucket then and deployed to your EC2 instance, based + on the related JSON object's content. The deployment job finishes when the deployment to EC2 + is done or has failed. -### Custom build job for Auto DevOps +## Use Auto DevOps to deploy to EC2 > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/216008) in GitLab 13.6. -To leverage [Auto DevOps](../../topics/autodevops/index.md) for your project when deploying to -AWS EC2, first you must define [your AWS credentials as CI/CD variables](#authenticate-gitlab-with-aws). +To use [Auto DevOps](../../topics/autodevops/index.md) to deploy to EC2: -Next, define a job for the `build` stage. To do so, you must reference the -`Auto-DevOps.gitlab-ci.yml` template and include a job named `build_artifact` in your -`.gitlab-ci.yml` file. For example: +1. Define [your AWS credentials as CI/CD variables](#authenticate-gitlab-with-aws). +1. In your `.gitlab-ci.yml` file, reference the `Auto-Devops.gitlab-ci.yml` template. +1. Define a job for the `build` stage named `build_artifact`. For example: -```yaml -# .gitlab-ci.yml + ```yaml + # .gitlab-ci.yml -include: - - template: Auto-DevOps.gitlab-ci.yml + include: + - template: Auto-DevOps.gitlab-ci.yml -variables: - AUTO_DEVOPS_PLATFORM_TARGET: EC2 + variables: + AUTO_DEVOPS_PLATFORM_TARGET: EC2 -build_artifact: - stage: build - script: - - - artifacts: - paths: - - -``` + build_artifact: + stage: build + script: + - + artifacts: + paths: + - + ``` -For a video walkthrough of this configuration process, see [Auto Deploy to EC2](https://www.youtube.com/watch?v=4B-qSwKnacA). +For a video walkthrough of this process, view [Auto Deploy to EC2](https://www.youtube.com/watch?v=4B-qSwKnacA). -### Deploy to Amazon EKS +## Use Auto DevOps to deploy to EKS - [Deploy your application to a GitLab-managed Amazon EKS cluster with Auto DevOps](https://about.gitlab.com/blog/2020/05/05/deploying-application-eks/) diff --git a/doc/topics/autodevops/requirements.md b/doc/topics/autodevops/requirements.md index bd0d1ef5c57..92804b750fe 100644 --- a/doc/topics/autodevops/requirements.md +++ b/doc/topics/autodevops/requirements.md @@ -214,7 +214,7 @@ You can target [AWS EC2](../../ci/cloud_deployment/index.md) as a deployment platform instead of Kubernetes. To use Auto DevOps with AWS EC2, you must add a specific CI/CD variable. -For more details, see [Custom build job for Auto DevOps](../../ci/cloud_deployment/index.md#custom-build-job-for-auto-devops) +For more details, see [Custom build job for Auto DevOps](../../ci/cloud_deployment/index.md#use-auto-devops-to-deploy-to-ec2) for deployments to AWS EC2. ## Auto DevOps requirements for bare metal diff --git a/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml index c1815baf7e6..ab4c9b701d0 100644 --- a/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml @@ -11,7 +11,7 @@ # # -------------------- # -# Documentation: https://docs.gitlab.com/ee/ci/cloud_deployment/#deploy-your-application-to-the-aws-elastic-container-service-ecs +# Documentation: https://docs.gitlab.com/ee/ci/cloud_deployment/#deploy-your-application-to-ecs stages: - build @@ -23,5 +23,5 @@ stages: "error: Template has moved": stage: deploy script: - - echo "Deploy-ECS.gitlab-ci.yml has been moved to AWS/Deploy-ECS.gitlab-ci.yml, see https://docs.gitlab.com/ee/ci/cloud_deployment/#deploy-your-application-to-the-aws-elastic-container-service-ecs for more details." + - echo "Deploy-ECS.gitlab-ci.yml has been moved to AWS/Deploy-ECS.gitlab-ci.yml, see https://docs.gitlab.com/ee/ci/cloud_deployment/#deploy-your-application-to-ecs for more details." - exit 1 diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 50ac90cb449..c37cb9305ad 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -119,9 +119,9 @@ module Gitlab # See official parser: https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/parsehelp.c?id=9e0c88ec09475f4d1addde9cdba1ad7849720356#n205 @debian_version_regex ||= %r{ \A(?: - (?:([0-9]{1,9}):)? (?# epoch) - ([0-9][0-9a-z\.+~-]*) (?# version) - (?:(-[0-0a-z\.+~]+))? (?# revision) + (?:([0-9]{1,9}):)? (?# epoch) + ([0-9][0-9a-z\.+~]*-?){1,15} (?# version-revision) + (? { expect(window.scrollTo.mock.calls[0]).toEqual([0, 39]); }); + it.each` + tab | hides | hidesText + ${'show'} | ${false} | ${'shows'} + ${'diffs'} | ${true} | ${'hides'} + ${'commits'} | ${true} | ${'hides'} + `('it $hidesText expand button on $tab tab', ({ tab, hides }) => { + const expandButton = document.createElement('div'); + expandButton.classList.add('js-expand-sidebar'); + + const tabsContainer = document.createElement('div'); + tabsContainer.innerHTML = + '
'; + tabsContainer.classList.add('merge-request-tabs-container'); + tabsContainer.appendChild(expandButton); + document.body.appendChild(tabsContainer); + + testContext.class = new MergeRequestTabs({ stubLocation }); + testContext.class.tabShown(tab, 'foobar'); + + expect(testContext.class.expandSidebar.classList.contains('gl-display-none!')).toBe(hides); + }); + describe('when switching tabs', () => { const SCROLL_TOP = 100; diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index 79c96e65a0e..7d5ecbf7a57 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -58,6 +58,43 @@ RSpec.describe FormHelper do end end + it 'renders help page links' do + stubbed_errors = ActiveModel::Errors.new(double).tap do |errors| + errors.add(:base, 'No text.', help_page_url: 'http://localhost/doc/user/index.html') + errors.add( + :base, + 'With text.', + help_link_text: 'Documentation page title.', + help_page_url: 'http://localhost/doc/administration/index.html' + ) + errors.add( + :base, + 'With HTML text.', + help_link_text: '', + help_page_url: 'http://localhost/doc/security/index.html' + ) + end + + model = double(errors: stubbed_errors) + + errors = helper.form_errors(model) + + aggregate_failures do + expect(errors).to include( + '
  • No text. Learn more.
  • ' + ) + expect(errors).to include( + '
  • With text. Documentation page title.
  • ' + ) + expect(errors).to include( + '
  • With HTML text. <foo>
  • ' + ) + end + end + def errors_stub(*messages) ActiveModel::Errors.new(double).tap do |errors| messages.each { |msg| errors.add(:base, msg) } diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 73d41575c65..d48e8183650 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -570,8 +570,7 @@ RSpec.describe Gitlab::Regex do # nothing after colon in version number it { is_expected.not_to match('2:') } # revision number is empty - # Note: we are less strict here - # it { is_expected.not_to match('1.0-') } + it { is_expected.not_to match('1.0-') } # version number is empty it { is_expected.not_to match('-1') } it { is_expected.not_to match('2:-1') } @@ -593,6 +592,9 @@ RSpec.describe Gitlab::Regex do it { is_expected.not_to match('1.0 ') } # dpkg accepts multiple colons it { is_expected.not_to match('1:2:3') } + # we limit the number of dashes + it { is_expected.to match('1-2-3-4-5-6-7-8-9-10-11-12-13-14-15') } + it { is_expected.not_to match('1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16') } end end diff --git a/spec/lib/gitlab/usage/service_ping_report_spec.rb b/spec/lib/gitlab/usage/service_ping_report_spec.rb index e007554df4a..1e8f9db4dea 100644 --- a/spec/lib/gitlab/usage/service_ping_report_spec.rb +++ b/spec/lib/gitlab/usage/service_ping_report_spec.rb @@ -155,6 +155,11 @@ RSpec.describe Gitlab::Usage::ServicePingReport, :use_clean_rails_memory_store_c memoized_constatns += Gitlab::UsageData::EE_MEMOIZED_VALUES if defined? Gitlab::UsageData::EE_MEMOIZED_VALUES memoized_constatns.each { |v| Gitlab::UsageData.clear_memoization(v) } stub_database_flavor_check('Cloud SQL for PostgreSQL') + + # in_product_marketing_email metrics values are extracted from a single group by query + # to check if the queries for individual metrics return the same value as group by when the value is non-zero + create(:in_product_marketing_email, track: :create, series: 0, cta_clicked_at: Time.current) + create(:in_product_marketing_email, track: :verify, series: 0) end let(:service_ping_payload) { described_class.for(output: :all_metrics_values) } diff --git a/spec/lib/gitlab/usage_data_queries_spec.rb b/spec/lib/gitlab/usage_data_queries_spec.rb index 7c64a31c499..2fe43c11d27 100644 --- a/spec/lib/gitlab/usage_data_queries_spec.rb +++ b/spec/lib/gitlab/usage_data_queries_spec.rb @@ -105,4 +105,25 @@ RSpec.describe Gitlab::UsageDataQueries do expect(described_class.maximum_id(Project)).to eq(nil) end end + + describe 'sent_in_product_marketing_email_count' do + it 'returns sql query that returns correct value' do + expect(described_class.sent_in_product_marketing_email_count(nil, 0, 0)).to eq( + 'SELECT COUNT("in_product_marketing_emails"."id") ' \ + 'FROM "in_product_marketing_emails" ' \ + 'WHERE "in_product_marketing_emails"."track" = 0 AND "in_product_marketing_emails"."series" = 0' + ) + end + end + + describe 'clicked_in_product_marketing_email_count' do + it 'returns sql query that returns correct value' do + expect(described_class.clicked_in_product_marketing_email_count(nil, 0, 0)).to eq( + 'SELECT COUNT("in_product_marketing_emails"."id") ' \ + 'FROM "in_product_marketing_emails" ' \ + 'WHERE "in_product_marketing_emails"."track" = 0 AND "in_product_marketing_emails"."series" = 0 ' \ + 'AND "in_product_marketing_emails"."cta_clicked_at" IS NOT NULL' + ) + end + end end diff --git a/workhorse/internal/upload/destination/objectstore/multipart.go b/workhorse/internal/upload/destination/objectstore/multipart.go index 4c5b64b27ee..77e36e74e03 100644 --- a/workhorse/internal/upload/destination/objectstore/multipart.go +++ b/workhorse/internal/upload/destination/objectstore/multipart.go @@ -100,12 +100,12 @@ func (m *Multipart) readAndUploadOnePart(ctx context.Context, partURL string, pu defer file.Close() if err := os.Remove(file.Name()); err != nil { - return nil, err + return nil, fmt.Errorf("remove temporary buffer file: %v", err) } n, err := io.Copy(file, src) if err != nil { - return nil, err + return nil, fmt.Errorf("copy to temporary buffer file: %v", err) } if n == 0 { return nil, nil