diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 18:09:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 18:09:35 +0000 |
commit | 5bfb8d1fad825eec90b0af688c7cd1b352c9056e (patch) | |
tree | 385411919c4186d11a769385ad8dafeef6cc36a7 | |
parent | aaf59610548d9b0fd01acfd50e831cbe519ecba2 (diff) | |
download | gitlab-ce-5bfb8d1fad825eec90b0af688c7cd1b352c9056e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
72 files changed, 375 insertions, 221 deletions
diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml index f9074adeaba..82ce9310ee8 100644 --- a/.gitlab/ci/rails.gitlab-ci.yml +++ b/.gitlab/ci/rails.gitlab-ci.yml @@ -204,8 +204,25 @@ gitlab:setup: rspec:coverage: extends: - .rails-job-base - - .rails:rules:ee-and-foss + - .rails:rules:ee-only stage: post-test + # We cannot use needs since it would mean needing 84 jobs (since most are parallelized) + # so we use `dependencies` here. + dependencies: + - setup-test-env + - rspec migration pg9 + - rspec unit pg9 + - rspec integration pg9 + - rspec system pg9 + - rspec-ee migration pg9 + - rspec-ee unit pg9 + - rspec-ee integration pg9 + - rspec-ee system pg9 + - rspec-ee unit pg9 geo + - rspec-ee integration pg9 geo + - rspec-ee system pg9 geo + - memory-static + - memory-on-boot variables: SETUP_DB: "false" cache: diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 3ef28e02e9d..26138532f46 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -291,6 +291,8 @@ ############### .pages:rules: rules: + - <<: *if-not-ee + when: never - <<: *if-dot-com-gitlab-org-master changes: *code-backstage-qa-patterns when: on_success diff --git a/.gitlab/issue_templates/Security developer workflow.md b/.gitlab/issue_templates/Security developer workflow.md index 56be0453b33..2c80360d32d 100644 --- a/.gitlab/issue_templates/Security developer workflow.md +++ b/.gitlab/issue_templates/Security developer workflow.md @@ -21,7 +21,7 @@ Set the title to: `Description of the original issue` - [ ] Create a merge request targeting `master` on `gitlab.com/gitlab-org/security` and use the [Security Release merge request template]. - [ ] Follow the same [code review process]: Assign to a reviewer, then to a maintainer. -After your merge request has being approved according to our [approval guidelines], you're ready to prepare the backports +After your merge request has been approved according to our [approval guidelines], you're ready to prepare the backports ## Backports @@ -87,7 +87,7 @@ gem 'grape-entity', '~> 0.7.1' gem 'rack-cors', '~> 1.0.6', require: 'rack/cors' # GraphQL API -gem 'graphql', '~> 1.9.19' +gem 'graphql', '~> 1.10.5' # NOTE: graphiql-rails v1.5+ doesn't work: https://gitlab.com/gitlab-org/gitlab/issues/31771 # TODO: remove app/views/graphiql/rails/editors/show.html.erb when https://github.com/rmosolgo/graphiql-rails/pull/71 is released: # https://gitlab.com/gitlab-org/gitlab/issues/31747 diff --git a/Gemfile.lock b/Gemfile.lock index 3bbe3020b70..e96a38ccf22 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -456,7 +456,7 @@ GEM graphiql-rails (1.4.10) railties sprockets-rails - graphql (1.9.19) + graphql (1.10.5) graphql-docs (1.6.0) commonmarker (~> 0.16) escape_utils (~> 1.2) @@ -1252,7 +1252,7 @@ DEPENDENCIES grape-path-helpers (~> 1.2) grape_logging (~> 1.7) graphiql-rails (~> 1.4.10) - graphql (~> 1.9.19) + graphql (~> 1.10.5) graphql-docs (~> 1.6.0) grpc (~> 1.24.0) gssapi diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb index 03eb7462ece..03841917bbf 100644 --- a/app/models/audit_event.rb +++ b/app/models/audit_event.rb @@ -13,11 +13,18 @@ class AuditEvent < ApplicationRecord scope :by_entity_type, -> (entity_type) { where(entity_type: entity_type) } scope :by_entity_id, -> (entity_id) { where(entity_id: entity_id) } - scope :order_by_id_desc, -> { order(id: :desc) } - scope :order_by_id_asc, -> { order(id: :asc) } after_initialize :initialize_details + def self.order_by(method) + case method.to_s + when 'created_asc' + order(id: :asc) + else + order(id: :desc) + end + end + def initialize_details self.details = {} if details.nil? end diff --git a/changelogs/unreleased/issue_11391_2.yml b/changelogs/unreleased/issue_11391_2.yml new file mode 100644 index 00000000000..c59ac2d9ae4 --- /dev/null +++ b/changelogs/unreleased/issue_11391_2.yml @@ -0,0 +1,5 @@ +--- +title: Index issues on sent_notifications table +merge_request: 27034 +author: +type: performance diff --git a/changelogs/unreleased/sh-feature-flag-persisted-process-cache.yml b/changelogs/unreleased/sh-feature-flag-persisted-process-cache.yml new file mode 100644 index 00000000000..d1ef2424b15 --- /dev/null +++ b/changelogs/unreleased/sh-feature-flag-persisted-process-cache.yml @@ -0,0 +1,5 @@ +--- +title: Move feature flag list into process cache +merge_request: 27511 +author: +type: performance diff --git a/db/migrate/20181016141739_add_status_to_deployments.rb b/db/migrate/20181016141739_add_status_to_deployments.rb index 7aaf029b69c..103bd9cc56d 100644 --- a/db/migrate/20181016141739_add_status_to_deployments.rb +++ b/db/migrate/20181016141739_add_status_to_deployments.rb @@ -14,14 +14,18 @@ class AddStatusToDeployments < ActiveRecord::Migration[4.2] # Ideally, `status` column should not have default value because it should be leveraged by state machine (i.e. application level). # However, we have to use the default value for avoiding `NOT NULL` violation during the transition period. # The default value should be removed in the future release. + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up - add_column_with_default(:deployments, # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default(:deployments, :status, :integer, limit: 2, default: DEPLOYMENT_STATUS_SUCCESS, allow_null: false) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:deployments, :status) diff --git a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb index 60d4c2554f7..2488cff38af 100644 --- a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb +++ b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb @@ -7,10 +7,12 @@ class AddMergeTrainEnabledToCiCdSettings < ActiveRecord::Migration[5.1] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false end + # rubocop:enable Migration/AddColumnWithDefault # rubocop:enable Migration/UpdateLargeTable def down diff --git a/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb b/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb index aa3002a3dcd..1a4439da5bf 100644 --- a/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb +++ b/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb @@ -7,9 +7,13 @@ class AddVariableTypeToCiPipelineVariables < ActiveRecord::Migration[5.0] DOWNTIME = false ENV_VAR_VARIABLE_TYPE = 1 + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up - add_column_with_default(:ci_pipeline_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default(:ci_pipeline_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:ci_pipeline_variables, :variable_type) diff --git a/db/migrate/20190426180107_add_deployment_events_to_services.rb b/db/migrate/20190426180107_add_deployment_events_to_services.rb index 1fb137fb5f9..61339ea7506 100644 --- a/db/migrate/20190426180107_add_deployment_events_to_services.rb +++ b/db/migrate/20190426180107_add_deployment_events_to_services.rb @@ -7,9 +7,13 @@ class AddDeploymentEventsToServices < ActiveRecord::Migration[5.0] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default(:services, :deployment_events, :boolean, default: false, allow_null: false) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:services, :deployment_events) diff --git a/db/migrate/20191023093207_add_comment_actions_to_services.rb b/db/migrate/20191023093207_add_comment_actions_to_services.rb index f3fc12ac7c7..46d4bdf9500 100644 --- a/db/migrate/20191023093207_add_comment_actions_to_services.rb +++ b/db/migrate/20191023093207_add_comment_actions_to_services.rb @@ -7,9 +7,13 @@ class AddCommentActionsToServices < ActiveRecord::Migration[5.2] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default(:services, :comment_on_event_enabled, :boolean, default: true) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:services, :comment_on_event_enabled) diff --git a/db/migrate/20200310132654_add_instance_to_services.rb b/db/migrate/20200310132654_add_instance_to_services.rb index 85b16a4094c..5f3c3e8616b 100644 --- a/db/migrate/20200310132654_add_instance_to_services.rb +++ b/db/migrate/20200310132654_add_instance_to_services.rb @@ -7,9 +7,13 @@ class AddInstanceToServices < ActiveRecord::Migration[6.0] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default(:services, :instance, :boolean, default: false) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:services, :instance) diff --git a/db/post_migrate/20200212052620_readd_template_column_to_services.rb b/db/post_migrate/20200212052620_readd_template_column_to_services.rb index e54b9e39277..2b0d26b2ad4 100644 --- a/db/post_migrate/20200212052620_readd_template_column_to_services.rb +++ b/db/post_migrate/20200212052620_readd_template_column_to_services.rb @@ -7,6 +7,7 @@ class ReaddTemplateColumnToServices < ActiveRecord::Migration[6.0] disable_ddl_transaction! + # rubocop:disable Migration/UpdateLargeTable def up return if column_exists? :services, :template @@ -16,6 +17,7 @@ class ReaddTemplateColumnToServices < ActiveRecord::Migration[6.0] # of `template`, we would look for entries with `project_id IS NULL`. add_column_with_default :services, :template, :boolean, default: false, allow_null: true end + # rubocop:enable Migration/UpdateLargeTable def down # NOP since the column is expected to exist diff --git a/db/post_migrate/20200311192351_add_index_on_noteable_type_and_noteable_id_to_sent_notifications.rb b/db/post_migrate/20200311192351_add_index_on_noteable_type_and_noteable_id_to_sent_notifications.rb new file mode 100644 index 00000000000..fa0246218c3 --- /dev/null +++ b/db/post_migrate/20200311192351_add_index_on_noteable_type_and_noteable_id_to_sent_notifications.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexOnNoteableTypeAndNoteableIdToSentNotifications < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_sent_notifications_on_noteable_type_noteable_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :sent_notifications, + [:noteable_id], + name: INDEX_NAME, + where: "noteable_type = 'Issue'" + end + + def down + remove_concurrent_index_by_name :sent_notifications, INDEX_NAME + end +end diff --git a/db/schema.rb b/db/schema.rb index db9ba2ce8f5..f3a475bbfe9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -3919,6 +3919,7 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do t.string "note_type" t.text "position" t.string "in_reply_to_discussion_id" + t.index ["noteable_id"], name: "index_sent_notifications_on_noteable_type_noteable_id", where: "((noteable_type)::text = 'Issue'::text)" t.index ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true end diff --git a/doc/ci/variables/predefined_variables.md b/doc/ci/variables/predefined_variables.md index a340f8b705d..c90d2e1aa5e 100644 --- a/doc/ci/variables/predefined_variables.md +++ b/doc/ci/variables/predefined_variables.md @@ -51,11 +51,11 @@ future GitLab releases.** | `CI_ENVIRONMENT_NAME` | 8.15 | all | The name of the environment for this job. Only present if [`environment:name`](../yaml/README.md#environmentname) is set. | | `CI_ENVIRONMENT_SLUG` | 8.15 | all | A simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, etc. Only present if [`environment:name`](../yaml/README.md#environmentname) is set. | | `CI_ENVIRONMENT_URL` | 9.3 | all | The URL of the environment for this job. Only present if [`environment:url`](../yaml/README.md#environmenturl) is set. | -| `CI_EXTERNAL_PULL_REQUEST_IID` | 12.3 | all | Pull Request ID from GitHub if the [pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` is used and the pull request is open. | -| `CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME` | 12.3 | all | The source branch name of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` is used and the pull request is open. | -| `CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHA` | 12.3 | all | The HEAD SHA of the source branch of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` is used and the pull request is open. | -| `CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME` | 12.3 | all | The target branch name of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` is used and the pull request is open. | -| `CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA` | 12.3 | all | The HEAD SHA of the target branch of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` is used and the pull request is open. | +| `CI_EXTERNAL_PULL_REQUEST_IID` | 12.3 | all | Pull Request ID from GitHub if the [pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the pull request is open. | +| `CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME` | 12.3 | all | The source branch name of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the pull request is open. | +| `CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHA` | 12.3 | all | The HEAD SHA of the source branch of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the pull request is open. | +| `CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME` | 12.3 | all | The target branch name of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the pull request is open. | +| `CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA` | 12.3 | all | The HEAD SHA of the target branch of the pull request if [the pipelines are for external pull requests](../ci_cd_for_external_repos/index.md#pipelines-for-external-pull-requests). Available only if `only: [external_pull_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the pull request is open. | | `CI_JOB_ID` | 9.0 | all | The unique id of the current job that GitLab CI uses internally | | `CI_JOB_IMAGE` | 12.9 | 12.9 | The name of the image running the CI job | | `CI_JOB_MANUAL` | 8.12 | all | The flag to indicate that job was manually started | @@ -63,25 +63,25 @@ future GitLab releases.** | `CI_JOB_STAGE` | 9.0 | 0.5 | The name of the stage as defined in `.gitlab-ci.yml` | | `CI_JOB_TOKEN` | 9.0 | 1.2 | Token used for authenticating with the [GitLab Container Registry][registry] and downloading [dependent repositories][dependent-repositories] | | `CI_JOB_URL` | 11.1 | 0.5 | Job details URL | -| `CI_MERGE_REQUEST_ASSIGNEES` | 11.9 | all | Comma-separated list of username(s) of assignee(s) for the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | +| `CI_MERGE_REQUEST_ASSIGNEES` | 11.9 | all | Comma-separated list of username(s) of assignee(s) for the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | | `CI_MERGE_REQUEST_CHANGED_PAGE_PATHS` | 12.9 | all | Comma-separated list of paths of changed pages in a deployed [Review App](../review_apps/index.md) for a [Merge Request](../merge_request_pipelines/index.md). A [Route Map](../review_apps/index.md#route-maps) must be configured. | | `CI_MERGE_REQUEST_CHANGED_PAGE_URLS` | 12.9 | all | Comma-separated list of URLs of changed pages in a deployed [Review App](../review_apps/index.md) for a [Merge Request](../merge_request_pipelines/index.md). A [Route Map](../review_apps/index.md#route-maps) must be configured. | -| `CI_MERGE_REQUEST_ID` | 11.6 | all | The ID of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_IID` | 11.6 | all | The IID of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_LABELS` | 11.9 | all | Comma-separated label names of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_MILESTONE` | 11.9 | all | The milestone title of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_PROJECT_ID` | 11.6 | all | The ID of the project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_PROJECT_PATH` | 11.6 | all | The path of the project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md) (e.g. `namespace/awesome-project`). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_PROJECT_URL` | 11.6 | all | The URL of the project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md) (e.g. `http://192.168.10.15:3000/namespace/awesome-project`). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_REF_PATH` | 11.6 | all | The ref path of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). (e.g. `refs/merge-requests/1/head`). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_SOURCE_BRANCH_NAME` | 11.6 | all | The source branch name of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the source branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used, the merge request is created, and the pipeline is a [merged result pipeline](../merge_request_pipelines/pipelines_for_merged_results/index.md). **(PREMIUM)** | -| `CI_MERGE_REQUEST_SOURCE_PROJECT_ID` | 11.6 | all | The ID of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_SOURCE_PROJECT_PATH` | 11.6 | all | The path of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_SOURCE_PROJECT_URL` | 11.6 | all | The URL of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_TARGET_BRANCH_NAME` | 11.6 | all | The target branch name of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_TARGET_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the target branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used, the merge request is created, and the pipeline is a [merged result pipeline](../merge_request_pipelines/pipelines_for_merged_results/index.md). **(PREMIUM)** | -| `CI_MERGE_REQUEST_TITLE` | 11.9 | all | The title of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | +| `CI_MERGE_REQUEST_ID` | 11.6 | all | The ID of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_IID` | 11.6 | all | The IID of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_LABELS` | 11.9 | all | Comma-separated label names of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_MILESTONE` | 11.9 | all | The milestone title of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_PROJECT_ID` | 11.6 | all | The ID of the project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_PROJECT_PATH` | 11.6 | all | The path of the project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md) (e.g. `namespace/awesome-project`). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_PROJECT_URL` | 11.6 | all | The URL of the project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md) (e.g. `http://192.168.10.15:3000/namespace/awesome-project`). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_REF_PATH` | 11.6 | all | The ref path of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). (e.g. `refs/merge-requests/1/head`). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_SOURCE_BRANCH_NAME` | 11.6 | all | The source branch name of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the source branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used, the merge request is created, and the pipeline is a [merged result pipeline](../merge_request_pipelines/pipelines_for_merged_results/index.md). **(PREMIUM)** | +| `CI_MERGE_REQUEST_SOURCE_PROJECT_ID` | 11.6 | all | The ID of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_SOURCE_PROJECT_PATH` | 11.6 | all | The path of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_SOURCE_PROJECT_URL` | 11.6 | all | The URL of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_TARGET_BRANCH_NAME` | 11.6 | all | The target branch name of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | +| `CI_MERGE_REQUEST_TARGET_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the target branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used, the merge request is created, and the pipeline is a [merged result pipeline](../merge_request_pipelines/pipelines_for_merged_results/index.md). **(PREMIUM)** | +| `CI_MERGE_REQUEST_TITLE` | 11.9 | all | The title of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` or [`rules`](../yaml/README.md#rules) syntax is used and the merge request is created. | | `CI_MERGE_REQUEST_EVENT_TYPE` | 12.3 | all | The event type of the merge request, if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Can be `detached`, `merged_result` or `merge_train`. | | `CI_NODE_INDEX` | 11.5 | all | Index of the job in the job set. If the job is not parallelized, this variable is not set. | | `CI_NODE_TOTAL` | 11.5 | all | Total number of instances of this job running in parallel. If the job is not parallelized, this variable is set to `1`. | diff --git a/doc/development/api_styleguide.md b/doc/development/api_styleguide.md index bd5ea6ac506..8537c63a8b7 100644 --- a/doc/development/api_styleguide.md +++ b/doc/development/api_styleguide.md @@ -11,6 +11,12 @@ to access them as we do in Rails views), local variables are fine. Always use an [Entity] to present the endpoint's payload. +## Documentation + +API endpoints must come with [documentation](documentation/styleguide.md#api), unless it is internal or behind a feature flag. +The docs should be in the same merge request, or, if strictly necessary, +in a follow-up with the same milestone as the original merge request. + ## Methods and parameters description Every method must be described using the [Grape DSL](https://github.com/ruby-grape/grape#describing-methods) diff --git a/doc/user/application_security/index.md b/doc/user/application_security/index.md index 8e97427e061..e1056eb2002 100644 --- a/doc/user/application_security/index.md +++ b/doc/user/application_security/index.md @@ -7,9 +7,11 @@ type: reference, howto GitLab can check your application for security vulnerabilities that may lead to unauthorized access, data leaks, denial of services, and more. GitLab reports vulnerabilities in the merge request so you can fix them before merging. The [Security Dashboard](security_dashboard/index.md) provides a -high-level view of vulnerabilities detected in your projects, pipeline, and groups. With the -information provided, you can immediately begin risk analysis and remediation. +high-level view of vulnerabilities detected in your projects, pipeline, and groups. The [Threat Monitoring](threat_monitoring/index.md) +page provides runtime security metrics for application environments. With the information provided, +you can immediately begin risk analysis and remediation. +<i class="fa fa-youtube-play youtube" aria-hidden="true"></i> For an overview of application security with GitLab, see [Security Deep Dive](https://www.youtube.com/watch?v=k4vEJnGYy84). diff --git a/doc/user/application_security/offline_deployments/index.md b/doc/user/application_security/offline_deployments/index.md index f72b632ff82..6fc16684d79 100644 --- a/doc/user/application_security/offline_deployments/index.md +++ b/doc/user/application_security/offline_deployments/index.md @@ -13,7 +13,7 @@ connected to the internet, in what is sometimes known as an offline, limited connectivity, Local Area Network (LAN), Intranet, or "air-gap" environment. -In this situation, the GitLab instance can be one, or more, servers and services running in a network that can talk to one another, but have zero, or perhaps very restricted access to the internet. Assume anything within the GitLab instance and supporting infrastrusture (private maven repository for example) can be accessed via local network connection. Assume any files from the internet must come in via physical media (USB drive, hard drive). +In this situation, the GitLab instance can be one, or more, servers and services running in a network that can talk to one another, but have zero, or perhaps very restricted access to the internet. Assume anything within the GitLab instance and supporting infrastructure (private Maven repository for example) can be accessed via local network connection. Assume any files from the internet must come in via physical media (USB drive, hard drive). GitLab scanners generally will connect to the internet to download the latest sets of signatures, rules, and patches. A few extra steps are necessary diff --git a/doc/user/application_security/threat_monitoring/index.md b/doc/user/application_security/threat_monitoring/index.md new file mode 100644 index 00000000000..07427af7c7d --- /dev/null +++ b/doc/user/application_security/threat_monitoring/index.md @@ -0,0 +1,40 @@ +--- +type: reference, howto +--- + +# Threat Monitoring **(ULTIMATE)** + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/14707) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.9. + +The **Threat Monitoring** page provides metrics for the GitLab +application runtime security features. You can access these metrics by +navigating to your project's **Security & Compliance > Threat Monitoring** page. + +GitLab supports statistics for the following security features: + +- [Web Application Firewall](../../clusters/applications.md#web-application-firewall-modsecurity) + +## Web Application Firewall + +The Web Application Firewall section provides metrics for the NGINX +Ingress controller and ModSecurity firewall. This section has the +following prerequisites: + +- Project has to have at least one [environment](../../../ci/environments.md). +- [Web Application Firewall](../../clusters/applications.md#web-application-firewall-modsecurity) has to be enabled. +- [Elastic Stack](../../clusters/applications.md#web-application-firewall-modsecurity) has to be installed. + +If you are using custom Helm values for the Elastic Stack you have to +configure Filebeat similarly to the [vendored values](https://gitlab.com/gitlab-org/gitlab/-/blob/f610a080b1ccc106270f588a50cb3c07c08bdd5a/vendor/elastic_stack/values.yaml). + +The **Web Application Firewall** section displays the following information +about your Ingress traffic: + +- The total amount of requests to your application +- The proportion of traffic that is considered anomalous according to + the configured rules +- The request breakdown graph for the selected time interval + +If a significant percentage of traffic is anomalous, you should +investigate it for potential threats by +[examining the application logs](../../clusters/applications.md#web-application-firewall-modsecurity). diff --git a/doc/user/img/markdown_toc_preview_v12_9.png b/doc/user/img/markdown_toc_preview_v12_9.png Binary files differnew file mode 100644 index 00000000000..dd832d2788c --- /dev/null +++ b/doc/user/img/markdown_toc_preview_v12_9.png diff --git a/doc/user/markdown.md b/doc/user/markdown.md index 29163f98fb4..882ded57684 100644 --- a/doc/user/markdown.md +++ b/doc/user/markdown.md @@ -45,10 +45,10 @@ in October 2018. You may have older issues, merge requests, or Markdown documents in your repository that were written using some of the nuances of GitLab's RedCarpet version -of Markdown. Since CommonMark uses a slightly stricter syntax, these documents -may now display a little differently since we've transitioned to CommonMark. +of Markdown. Since CommonMark uses slightly stricter syntax, these documents +might now appear a little differently since we have transitioned to CommonMark. -It is usually quite easy to fix. For example, numbered lists with nested lists may +It's usually quite easy to fix. For example, numbered lists with nested lists may render incorrectly: ```markdown @@ -119,7 +119,7 @@ changing how standard Markdown is used: > If this is not rendered correctly, [view it in GitLab itself](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#colors). -It is possible to have color written in HEX, RGB or HSL format rendered with a color +It's possible to have color written in HEX, RGB, or HSL format rendered with a color indicator. Supported formats (named colors are not supported): @@ -154,14 +154,14 @@ Color written inside backticks will be followed by a color "chip": ### Diagrams and flowcharts -It is possible to generate diagrams and flowcharts from text in GitLab using [Mermaid](https://mermaidjs.github.io/) or [PlantUML](http://plantuml.com). +It's possible to generate diagrams and flowcharts from text in GitLab using [Mermaid](https://mermaidjs.github.io/) or [PlantUML](http://plantuml.com). #### Mermaid > [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/15107) in GitLab 10.3. -Visit the [official page](https://mermaidjs.github.io/) for more details. If you are new to using Mermaid or need help identifying issues in your Mermaid code, the [Mermaid Live Editor](https://mermaid-js.github.io/mermaid-live-editor/) is a helpful tool for creating and resolving issues within Mermaid diagrams. +Visit the [official page](https://mermaidjs.github.io/) for more details. If you're new to using Mermaid or need help identifying issues in your Mermaid code, the [Mermaid Live Editor](https://mermaid-js.github.io/mermaid-live-editor/) is a helpful tool for creating and resolving issues within Mermaid diagrams. In order to generate a diagram or flowchart, you should write your text inside the `mermaid` block: @@ -236,7 +236,7 @@ Sometimes you want to :monkey: around a bit and add some :star2: to your :speech You can use it to point out a :bug: or warn about :speak_no_evil: patches. And if someone improves your really :snail: code, send them some :birthday:. People will :heart: you for that. -If you are new to this, don't be :fearful:. You can easily join the emoji :family:. All you need to do is to look up one of the supported codes. +If you're new to this, don't be :fearful:. You can easily join the emoji :family:. All you need to do is to look up one of the supported codes. Consult the [Emoji Cheat Sheet](https://www.emojicopy.com) for a list of all supported emoji codes. :thumbsup: ``` @@ -247,7 +247,7 @@ Sometimes you want to <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/ma You can use it to point out a <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/bug.png" width="20px" height="20px" style="display:inline;margin:0"> or warn about <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/speak_no_evil.png" width="20px" height="20px" style="display:inline;margin:0"> patches. And if someone improves your really <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/snail.png" width="20px" height="20px" style="display:inline;margin:0"> code, send them some <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/birthday.png" width="20px" height="20px" style="display:inline;margin:0">. People will <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/heart.png" width="20px" height="20px" style="display:inline;margin:0"> you for that. -If you are new to this, don't be <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/fearful.png" width="20px" height="20px" style="display:inline;margin:0">. You can easily join the emoji <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/family.png" width="20px" height="20px" style="display:inline;margin:0">. All you need to do is to look up one of the supported codes. +If you're new to this, don't be <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/fearful.png" width="20px" height="20px" style="display:inline;margin:0">. You can easily join the emoji <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/family.png" width="20px" height="20px" style="display:inline;margin:0">. All you need to do is to look up one of the supported codes. Consult the [Emoji Cheat Sheet](https://www.webfx.com/tools/emoji-cheat-sheet/) for a list of all supported emoji codes. <img src="https://gitlab.com/gitlab-org/gitlab-foss/raw/master/app/assets/images/emoji/thumbsup.png" width="20px" height="20px" style="display:inline;margin:0"> @@ -345,7 +345,7 @@ The wrapping tags can be either curly braces or square brackets: --- -However the wrapping tags cannot be mixed: +However, the wrapping tags can't be mixed: ```markdown - {+ addition +] @@ -354,11 +354,24 @@ However the wrapping tags cannot be mixed: - [- deletion -} ``` +If your diff includes words in `` `code` `` font, make sure to escape each bactick `` ` `` with a +backslash `\`, otherwise the diff highlight won't render correctly: + +```markdown +- {+ Just regular text +} +- {+ Text with `backticks` inside +} +- {+ Text with escaped \`backticks\` inside +} +``` + +- {+ Just regular text +} +- {+ Text with `backticks` inside +} +- {+ Text with escaped \`backticks\` inside +} + ### Math > If this is not rendered correctly, [view it in GitLab itself](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#math). -It is possible to have math written with LaTeX syntax rendered using [KaTeX](https://github.com/KaTeX/KaTeX). +It's possible to have math written with LaTeX syntax rendered using [KaTeX](https://github.com/KaTeX/KaTeX). Math written between dollar signs `$` will be rendered inline with the text. Math written inside a [code block](#code-spans-and-blocks) with the language declared as `math`, will be rendered @@ -462,22 +475,35 @@ unordered or ordered lists: 1. [ ] Sub-task 1 1. [x] Sub-task 2 -### Table of Contents +### Table of contents -A table of contents can be added to a Markdown file, issue or merge request -description, or a wiki page, by adding the tag `[[_TOC_]]` on its own line. -It will be replaced with an unordered list that links to the various -headers. +You can add a table of contents to a Markdown file, wiki page, or issue/merge request +description, by adding the tag `[[_TOC_]]` on its own line. +It will appear as an unordered list that links to the various headers. ```markdown +This is an intro sentence to my Wiki page. + [[_TOC_]] + +## My first heading + +First section content. + +## My second heading + +Second section content. ``` +![Preview of an auto-generated TOC in a Wiki](img/markdown_toc_preview_v12_9.png) + +--- + ### Wiki-specific Markdown The following examples show how links inside wikis behave. -#### Wiki - Direct page link +#### Wiki - direct page link A link which just includes the slug for a page will point to that page, _at the base level of the wiki_. @@ -488,7 +514,7 @@ This snippet would link to a `documentation` page at the root of your wiki: [Link to Documentation](documentation) ``` -#### Wiki - Direct file link +#### Wiki - direct file link Links with a file extension point to that file, _relative to the current page_. @@ -499,10 +525,10 @@ it would link to `<your_wiki>/documentation/file.md`: [Link to File](file.md) ``` -#### Wiki - Hierarchical link +#### Wiki - hierarchical link A link can be constructed relative to the current wiki page using `./<page>`, -`../<page>`, etc. +`../<page>`, and so on. If this snippet was placed on a page at `<your_wiki>/documentation/main`, it would link to `<your_wiki>/documentation/related`: @@ -532,7 +558,7 @@ it would link to `<your_wiki>/documentation/main.md`: [Link to Related Page](../main.md) ``` -#### Wiki - Root link +#### Wiki - root link A link starting with a `/` is relative to the wiki root. @@ -560,7 +586,7 @@ If a functionality is extended, the new option will be listed as a sub-section. ### Blockquotes -Blockquotes are an easy way to highlight information, such as a side-note. It is generated +Blockquotes are an easy way to highlight information, such as a side-note. It's generated by starting the lines of the blockquote with `>`: ```markdown @@ -667,8 +693,8 @@ Tildes are OK too. GitLab uses the [Rouge Ruby library](http://rouge.jneen.net/) for more colorful syntax highlighting in code blocks. For a list of supported languages visit the [Rouge project wiki](https://github.com/rouge-ruby/rouge/wiki/List-of-supported-languages-and-lexers). -Syntax highlighting is only supported in code blocks, it is not possible to highlight -code when it is inline. +Syntax highlighting is only supported in code blocks, so it's not possible to highlight +code when it's inline. Blocks of code are fenced by lines with three back-ticks (```` ``` ````) or three tildes (`~~~`), and have the language identified at the end of the first fence: @@ -756,7 +782,7 @@ NOTE: **Note:** Strikethrough is not part of the core Markdown standard, but is > If this is not rendered correctly, [view it in GitLab itself](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#multiple-underscores-in-words). -It is not usually useful to italicize just _part_ of a word, especially when you're +It's not usually useful to italicize just _part_ of a word, especially when you're dealing with code and names that often appear with multiple underscores. As a result, GFM extends the standard Markdown standard by ignoring multiple underlines in words, to allow better rendering of Markdown documents discussing code: @@ -793,7 +819,8 @@ do*this*and*do*that*and*another thing Footnotes add a link to a note that will be rendered at the end of a Markdown file. -To make a footnote, you need both a reference tag and a separate line (anywhere in the file) with the note content. +To make a footnote, you need both a reference tag and a separate line (anywhere in the file) with +the note content. Regardless of the tag names, the relative order of the reference tags determines the rendered numbering. @@ -804,20 +831,23 @@ A footnote reference tag looks like this:[^1] Reference tags can use letters and other characters.[^footnote-note] -[^footnote-note]: Avoid using lowercase `w` or an underscore (`_`) -in your footnote tag name until an -[upstream bug](https://gitlab.com/gitlab-org/gitlab/issues/24423) is resolved. -``` +Avoid using lowercase `w` or an underscore (`_`) in footnote tag names until +[this bug](https://gitlab.com/gitlab-org/gitlab/issues/24423) is resolved. [^this-name-has-w] [^this-name-has_] -A footnote reference tag looks like this:[^1] +[^this-name-has-w]: This won't be rendered, because the name contains "w". -[^1]: This is the contents of a footnote. +[^this-name-has_]: This won be rendered, because the name contains an underscore. + +``` Reference tags can use letters and other characters.[^footnote-note] -[^footnote-note]: Avoid using lowercase `w` or an underscore (`_`) -in your footnote tag name until an -[upstream bug](https://gitlab.com/gitlab-org/gitlab/issues/24423) is resolved. +Avoid using lowercase `w` or an underscore (`_`) in footnote tag names until +[this bug](https://gitlab.com/gitlab-org/gitlab/issues/24423) is resolved. [^this-name-has-w] [^this-name-has_] + +[^this-name-has-w]: This won't be rendered, because the name contains "w". + +[^this-name-has_]: This won't be rendered, because the name contains an underscore. ### Headers @@ -849,7 +879,7 @@ the header to use it somewhere else. The IDs are generated from the content of the header according to the following rules: 1. All text is converted to lowercase. -1. All non-word text (e.g., punctuation, HTML) is removed. +1. All non-word text (such as punctuation or HTML) is removed. 1. All spaces are converted to hyphens. 1. Two or more hyphens in a row are converted to one. 1. If a header with the same ID has already been generated, a unique @@ -875,8 +905,8 @@ Would generate the following link IDs: 1. `this-header-has-spaces-in-it-2` 1. `this-header-has-3-5-in-it-and-parentheses` -Note that the Emoji processing happens before the header IDs are generated, so the -Emoji is converted to an image which is then removed from the ID. +Note that the emoji processing happens before the header IDs are generated, so the +emoji is converted to an image which is then removed from the ID. ### Horizontal Rule @@ -966,7 +996,7 @@ Here's a sample audio clip: > To see the Markdown rendered within HTML in the second example, [view it in GitLab itself](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#inline-html). -You can also use raw HTML in your Markdown, and it'll usually work pretty well. +You can also use raw HTML in your Markdown, and it will usually work pretty well. See the documentation for HTML::Pipeline's [SanitizationFilter](https://www.rubydoc.info/gems/html-pipeline/1.11.0/HTML/Pipeline/SanitizationFilter#WHITELIST-constant) class for the list of allowed HTML tags and attributes. In addition to the default @@ -992,7 +1022,7 @@ class for the list of allowed HTML tags and attributes. In addition to the defau --- -It is still possible to use Markdown inside HTML tags, but only if the lines containing Markdown +It's still possible to use Markdown inside HTML tags, but only if the lines containing Markdown are separated into their own lines: ```html @@ -1023,7 +1053,7 @@ are separated into their own lines: </dd> </dl> -#### Details and Summary +#### Details and summary > To see the Markdown rendered within HTML in the second example, [view it in GitLab itself](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#details-and-summary). @@ -1034,7 +1064,7 @@ tags. This is especially useful for collapsing long logs so they take up less sc ```html <p> <details> -<summary>Click me to collapse/fold.</summary> +<summary>Click this to collapse/fold.</summary> These details <em>will</em> remain <strong>hidden</strong> until expanded. @@ -1046,7 +1076,7 @@ These details <em>will</em> remain <strong>hidden</strong> until expanded. <p> <details> -<summary>Click me to collapse/fold.</summary> +<summary>Click this to collapse/fold.</summary> These details <em>will</em> remain <strong>hidden</strong> until expanded. @@ -1062,7 +1092,7 @@ after the `</summary>` tag and before the `</details>` tag, as shown in the exam ````html <details> -<summary>Click me to collapse/fold.</summary> +<summary>Click this to collapse/fold.</summary> These details _will_ remain **hidden** until expanded. @@ -1076,7 +1106,7 @@ PASTE LOGS HERE <!-- Note: The example below uses HTML to force correct rendering on docs.gitlab.com, Markdown will be fine in GitLab --> <details> -<summary>Click me to collapse/fold.</summary> +<summary>Click this to collapse/fold.</summary> These details <em>will</em> remain <b>hidden</b> until expanded. @@ -1084,10 +1114,10 @@ These details <em>will</em> remain <b>hidden</b> until expanded. </details> -### Line Breaks +### Line breaks A line break will be inserted (a new paragraph will start) if the previous text is -ended with two newlines, i.e. you hit <kbd>Enter</kbd> twice in a row. If you only +ended with two newlines, like when you hit <kbd>Enter</kbd> twice in a row. If you only use one newline (hit <kbd>Enter</kbd> once), the next sentence will be part of the same paragraph. This is useful if you want to keep long lines from wrapping, and keep them easily editable: @@ -1116,8 +1146,8 @@ in the *same paragraph*. GFM adheres to the Markdown specification in how [paragraphs and line breaks are handled](https://spec.commonmark.org/current/). -A paragraph is simply one or more consecutive lines of text, separated by one or -more blank lines (i.e. two newlines at the end of the first paragraph), as [explained above](#line-breaks). +A paragraph is one or more consecutive lines of text, separated by one or +more blank lines (two newlines at the end of the first paragraph), as [explained above](#line-breaks). If you need more control over line-breaks or soft returns, you can add a single line-break by ending a line with a backslash, or two or more spaces. Two newlines in a row will create a new @@ -1340,7 +1370,7 @@ Example: ### Superscripts / Subscripts -CommonMark and GFM currently do not support the superscript syntax ( `x^2` ) that +Currently, CommonMark and GFM don't support the superscript syntax ( `x^2` ) that Redcarpet does. You can use the standard HTML syntax for superscripts and subscripts: ```html @@ -1353,7 +1383,7 @@ while the equation for the theory of relativity is E = mc<sup>2</sup>. ### Tables -Tables aren't part of the core Markdown spec, but they are part of GFM. +Tables are not part of the core Markdown spec, but they are part of GFM. 1. The first line contains the headers, separated by "pipes" (`|`). 1. The second line separates the headers from the cells, and must contain three or more dashes. @@ -1401,8 +1431,8 @@ to the sides of the "dash" lines in the second row. This will affect every cell [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/27205) in GitLab 12.7. -If you're working in spreadsheet software (e.g. Microsoft Excel, Google -Sheets, Apple Numbers), you can copy from a spreadsheet, and GitLab will +If you're working in spreadsheet software (for example, Microsoft Excel, Google +Sheets, or Apple Numbers), you can copy from a spreadsheet, and GitLab will paste it as a Markdown table. For example, suppose you have the following spreadsheet: diff --git a/doc/user/project/wiki/index.md b/doc/user/project/wiki/index.md index 6fda2514849..3255e3a5477 100644 --- a/doc/user/project/wiki/index.md +++ b/doc/user/project/wiki/index.md @@ -93,6 +93,11 @@ To edit a page, simply click on the **Edit** button. From there on, you can change its content. When done, click **Save changes** for the changes to take effect. +### Adding a table of contents + +To generate a table of contents from the headings in a Wiki page, use the `[[_TOC_]]` tag. +For an example, see [Table of contents](../../markdown.md#table-of-contents). + ## Deleting a wiki page NOTE: **Note:** diff --git a/lib/feature.rb b/lib/feature.rb index 37cbe33f7c9..60a5c03a839 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -38,7 +38,7 @@ class Feature begin # We saw on GitLab.com, this database request was called 2300 # times/s. Let's cache it for a minute to avoid that load. - Gitlab::ThreadMemoryCache.cache_backend.fetch('flipper:persisted_names', expires_in: 1.minute) do + Gitlab::ProcessMemoryCache.cache_backend.fetch('flipper:persisted_names', expires_in: 1.minute) do FlipperFeature.feature_names end end diff --git a/lib/gitlab/checks/diff_check.rb b/lib/gitlab/checks/diff_check.rb index 0eb2b4c79ef..a73f243e946 100644 --- a/lib/gitlab/checks/diff_check.rb +++ b/lib/gitlab/checks/diff_check.rb @@ -21,7 +21,7 @@ module Gitlab process_commits do |commit| validate_once(commit) do commit.raw_deltas.each do |diff| - file_paths << (diff.new_path || diff.old_path) + file_paths.concat([diff.new_path, diff.old_path].compact) validate_diff(diff) end diff --git a/rubocop/cop/migration/add_column.rb b/rubocop/cop/migration/add_column.rb index a25bd843559..0af90fb7fd1 100644 --- a/rubocop/cop/migration/add_column.rb +++ b/rubocop/cop/migration/add_column.rb @@ -8,11 +8,6 @@ module RuboCop class AddColumn < RuboCop::Cop::Cop include MigrationHelpers - WHITELISTED_TABLES = %i[ - application_settings - plan_limits - ].freeze - MSG = '`add_column` with a default value requires downtime, ' \ 'use `add_column_with_default` instead'.freeze diff --git a/rubocop/cop/migration/add_column_with_default.rb b/rubocop/cop/migration/add_column_with_default.rb index 68e53b17f19..383653ef5a5 100644 --- a/rubocop/cop/migration/add_column_with_default.rb +++ b/rubocop/cop/migration/add_column_with_default.rb @@ -10,38 +10,6 @@ module RuboCop class AddColumnWithDefault < RuboCop::Cop::Cop include MigrationHelpers - # Tables >= 10 GB on GitLab.com as of 02/2020 - BLACKLISTED_TABLES = %i[ - audit_events - ci_build_trace_sections - ci_builds - ci_builds_metadata - ci_job_artifacts - ci_pipeline_variables - ci_pipelines - ci_stages - deployments - events - issues - merge_request_diff_commits - merge_request_diff_files - merge_request_diffs - merge_request_metrics - merge_requests - note_diff_files - notes - project_authorizations - projects - push_event_payloads - resource_label_events - sent_notifications - system_note_metadata - taggings - todos - users - web_hook_logs - ].freeze - MSG = '`add_column_with_default` without `allow_null: true` may cause prolonged lock situations and downtime, ' \ 'see https://gitlab.com/gitlab-org/gitlab/issues/38060'.freeze diff --git a/rubocop/cop/migration/safer_boolean_column.rb b/rubocop/cop/migration/safer_boolean_column.rb index fa524efe5be..25aaf42d00e 100644 --- a/rubocop/cop/migration/safer_boolean_column.rb +++ b/rubocop/cop/migration/safer_boolean_column.rb @@ -23,10 +23,6 @@ module RuboCop NULL_OFFENSE = 'Boolean columns on the `%s` table should disallow nulls.'.freeze DEFAULT_AND_NULL_OFFENSE = 'Boolean columns on the `%s` table should have a default and should disallow nulls. You may wish to use `add_column_with_default`.'.freeze - SMALL_TABLES = %i[ - application_settings - ].freeze - def_node_matcher :add_column?, <<~PATTERN (send nil? :add_column $...) PATTERN @@ -41,7 +37,7 @@ module RuboCop table, _, type = matched.to_a.take(3).map(&:children).map(&:first) opts = matched[3] - return unless SMALL_TABLES.include?(table) && type == :boolean + return unless WHITELISTED_TABLES.include?(table) && type == :boolean no_default = no_default?(opts) nulls_allowed = nulls_allowed?(opts) diff --git a/rubocop/cop/migration/update_large_table.rb b/rubocop/cop/migration/update_large_table.rb index 94bba31c249..e44eadbdb92 100644 --- a/rubocop/cop/migration/update_large_table.rb +++ b/rubocop/cop/migration/update_large_table.rb @@ -19,26 +19,6 @@ module RuboCop 'complete, and should be avoided unless absolutely ' \ 'necessary'.freeze - LARGE_TABLES = %i[ - ci_build_trace_sections - ci_builds - ci_job_artifacts - ci_pipelines - ci_stages - events - issues - merge_request_diff_commits - merge_request_diff_files - merge_request_diffs - merge_requests - namespaces - notes - projects - project_ci_cd_settings - routes - users - ].freeze - BATCH_UPDATE_METHODS = %w[ :add_column_with_default :change_column_type_concurrently @@ -59,7 +39,7 @@ module RuboCop update_method = matches.first table = matches.last.to_a.first - return unless LARGE_TABLES.include?(table) + return unless BLACKLISTED_TABLES.include?(table) add_offense(node, location: :expression, message: format(MSG, update_method, table)) end diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index 767cacaecaf..b5edb502d4c 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -1,6 +1,49 @@ module RuboCop # Module containing helper methods for writing migration cops. module MigrationHelpers + WHITELISTED_TABLES = %i[ + application_settings + plan_limits + ].freeze + + # Blacklisted table due to: + # - size in GB (>= 10 GB on GitLab.com as of 02/2020) + # - number of records + BLACKLISTED_TABLES = %i[ + audit_events + ci_build_trace_sections + ci_builds + ci_builds_metadata + ci_job_artifacts + ci_pipeline_variables + ci_pipelines + ci_stages + deployments + events + issues + merge_request_diff_commits + merge_request_diff_files + merge_request_diffs + merge_request_metrics + merge_requests + namespaces + note_diff_files + notes + project_authorizations + projects + project_ci_cd_settings + push_event_payloads + resource_label_events + routes + sent_notifications + services + system_note_metadata + taggings + todos + users + web_hook_logs + ].freeze + # Returns true if the given node originated from the db/migrate directory. def in_migration?(node) dirname(node).end_with?('db/migrate', 'db/geo/migrate') || in_post_deployment_migration?(node) diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb index 44f47e6c739..4f54695e5be 100644 --- a/spec/graphql/features/authorization_spec.rb +++ b/spec/graphql/features/authorization_spec.rb @@ -9,7 +9,7 @@ describe 'Gitlab::Graphql::Authorization' do let(:permission_single) { :foo } let(:permission_collection) { [:foo, :bar] } let(:test_object) { double(name: 'My name') } - let(:query_string) { '{ item() { name } }' } + let(:query_string) { '{ item { name } }' } let(:result) { execute_query(query_type)['data'] } subject { result['item'] } @@ -177,7 +177,7 @@ describe 'Gitlab::Graphql::Authorization' do end describe 'type authorizations when applied to a relay connection' do - let(:query_string) { '{ item() { edges { node { name } } } }' } + let(:query_string) { '{ item { edges { node { name } } } }' } let(:second_test_object) { double(name: 'Second thing') } let(:type) do diff --git a/spec/graphql/features/feature_flag_spec.rb b/spec/graphql/features/feature_flag_spec.rb index 13b1e472fab..51914cf0ca8 100644 --- a/spec/graphql/features/feature_flag_spec.rb +++ b/spec/graphql/features/feature_flag_spec.rb @@ -9,7 +9,7 @@ describe 'Graphql Field feature flags' do let(:feature_flag) { 'test_feature' } let(:test_object) { double(name: 'My name') } - let(:query_string) { '{ item() { name } }' } + let(:query_string) { '{ item { name } }' } let(:result) { execute_query(query_type)['data'] } subject { result } diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb index d0eb0475879..bd22458355c 100644 --- a/spec/graphql/gitlab_schema_spec.rb +++ b/spec/graphql/gitlab_schema_spec.rb @@ -27,11 +27,11 @@ describe GitlabSchema do end it 'has the base mutation' do - expect(described_class.mutation).to eq(::Types::MutationType.to_graphql) + expect(described_class.mutation).to eq(::Types::MutationType) end it 'has the base query' do - expect(described_class.query).to eq(::Types::QueryType.to_graphql) + expect(described_class.query).to eq(::Types::QueryType) end it 'paginates active record relations using `Connections::Keyset::Connection`' do diff --git a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb index 5663a3d7195..de5ece3b749 100644 --- a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb +++ b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe GitlabSchema.types['AwardEmoji'] do it { expect(described_class.graphql_name).to eq('AwardEmoji') } - it { is_expected.to require_graphql_authorizations(:read_emoji) } + it { expect(described_class).to require_graphql_authorizations(:read_emoji) } it { expect(described_class).to have_graphql_fields(:description, :unicode_version, :emoji, :name, :unicode, :user) } end diff --git a/spec/graphql/types/board_type_spec.rb b/spec/graphql/types/board_type_spec.rb index 9d18065bbcd..1ca4bf18b57 100644 --- a/spec/graphql/types/board_type_spec.rb +++ b/spec/graphql/types/board_type_spec.rb @@ -10,6 +10,6 @@ describe GitlabSchema.types['Board'] do it 'has specific fields' do expected_fields = %w[id name] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/diff_refs_type_spec.rb b/spec/graphql/types/diff_refs_type_spec.rb index 85225e5809c..a6ead27455f 100644 --- a/spec/graphql/types/diff_refs_type_spec.rb +++ b/spec/graphql/types/diff_refs_type_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe GitlabSchema.types['DiffRefs'] do it { expect(described_class.graphql_name).to eq('DiffRefs') } - it { is_expected.to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } + it { expect(described_class).to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } it { expect(described_class.fields['headSha'].type).to be_non_null } it { expect(described_class.fields['baseSha'].type).not_to be_non_null } diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb index cf30893b3ca..9e8f13e4c2e 100644 --- a/spec/graphql/types/environment_type_spec.rb +++ b/spec/graphql/types/environment_type_spec.rb @@ -10,8 +10,8 @@ describe GitlabSchema.types['Environment'] do name id ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_environment) } + it { expect(described_class).to require_graphql_authorizations(:read_environment) } end diff --git a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb index 3a512fee3b3..44652f831b5 100644 --- a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb @@ -37,6 +37,6 @@ describe GitlabSchema.types['SentryDetailedError'] do tags ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb index 3de0a359c15..20ec31391d8 100644 --- a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb @@ -15,7 +15,7 @@ describe GitlabSchema.types['SentryErrorCollection'] do error_stack_trace ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'errors field' do diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb index ce5fade6fcc..05cc2ca7612 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb @@ -14,6 +14,6 @@ describe GitlabSchema.types['SentryErrorStackTraceEntry'] do trace_context ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb index ac41e6903e5..2a422228f72 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb @@ -14,6 +14,6 @@ describe GitlabSchema.types['SentryErrorStackTrace'] do stack_trace_entries ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb index 51acd035024..4676d91ef9c 100644 --- a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb @@ -26,6 +26,6 @@ describe GitlabSchema.types['SentryError'] do frequency ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/grafana_integration_type_spec.rb b/spec/graphql/types/grafana_integration_type_spec.rb index ddfedc5a75c..ac26911acbf 100644 --- a/spec/graphql/types/grafana_integration_type_spec.rb +++ b/spec/graphql/types/grafana_integration_type_spec.rb @@ -18,5 +18,5 @@ describe GitlabSchema.types['GrafanaIntegration'] do it { expect(described_class).to require_graphql_authorizations(:admin_operations) } - it { is_expected.to have_graphql_fields(*expected_fields) } + it { expect(described_class).to have_graphql_fields(*expected_fields) } end diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 240dd9fa5e2..532f1a4b53d 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -19,7 +19,7 @@ describe GitlabSchema.types['Group'] do mentions_disabled parent boards ] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'boards field' do diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index daa2224ef20..ebe48c17c11 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -9,7 +9,7 @@ describe GitlabSchema.types['Issue'] do it { expect(described_class).to require_graphql_authorizations(:read_issue) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType.to_graphql) } + it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has specific fields' do fields = %i[iid title description state reference author assignees participants labels milestone due_date diff --git a/spec/graphql/types/label_type_spec.rb b/spec/graphql/types/label_type_spec.rb index a023a75eeff..71b86d9b528 100644 --- a/spec/graphql/types/label_type_spec.rb +++ b/spec/graphql/types/label_type_spec.rb @@ -5,8 +5,8 @@ describe GitlabSchema.types['Label'] do it 'has the correct fields' do expected_fields = [:id, :description, :description_html, :title, :color, :text_color] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_label) } + it { expect(described_class).to require_graphql_authorizations(:read_label) } end diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index 04e9bb6861f..0c83ebd3de9 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -7,7 +7,7 @@ describe GitlabSchema.types['MergeRequest'] do it { expect(described_class).to require_graphql_authorizations(:read_merge_request) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType.to_graphql) } + it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has the expected fields' do expected_fields = %w[ @@ -25,6 +25,6 @@ describe GitlabSchema.types['MergeRequest'] do total_time_spent reference ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/metadata_type_spec.rb b/spec/graphql/types/metadata_type_spec.rb index 2988f3c6ba5..c8270a8c2f5 100644 --- a/spec/graphql/types/metadata_type_spec.rb +++ b/spec/graphql/types/metadata_type_spec.rb @@ -4,5 +4,5 @@ require 'spec_helper' describe GitlabSchema.types['Metadata'] do it { expect(described_class.graphql_name).to eq('Metadata') } - it { is_expected.to require_graphql_authorizations(:read_instance_metadata) } + it { expect(described_class).to require_graphql_authorizations(:read_instance_metadata) } end diff --git a/spec/graphql/types/namespace_type_spec.rb b/spec/graphql/types/namespace_type_spec.rb index f476dd7286f..6c2ba70cf4c 100644 --- a/spec/graphql/types/namespace_type_spec.rb +++ b/spec/graphql/types/namespace_type_spec.rb @@ -11,8 +11,8 @@ describe GitlabSchema.types['Namespace'] do lfs_enabled request_access_enabled projects root_storage_statistics ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_namespace) } + it { expect(described_class).to require_graphql_authorizations(:read_namespace) } end diff --git a/spec/graphql/types/notes/diff_position_type_spec.rb b/spec/graphql/types/notes/diff_position_type_spec.rb index aa08daaacd4..01f355cb278 100644 --- a/spec/graphql/types/notes/diff_position_type_spec.rb +++ b/spec/graphql/types/notes/diff_position_type_spec.rb @@ -7,6 +7,6 @@ describe GitlabSchema.types['DiffPosition'] do :new_path, :position_type, :old_line, :new_line, :x, :y, :width, :height] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/notes/discussion_type_spec.rb b/spec/graphql/types/notes/discussion_type_spec.rb index ba7fc961212..804785ba67d 100644 --- a/spec/graphql/types/notes/discussion_type_spec.rb +++ b/spec/graphql/types/notes/discussion_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe GitlabSchema.types['Discussion'] do - it { is_expected.to have_graphql_fields(:id, :created_at, :notes, :reply_id) } + it { expect(described_class).to have_graphql_fields(:id, :created_at, :notes, :reply_id) } - it { is_expected.to require_graphql_authorizations(:read_note) } + it { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb index e8a58da4b17..809f54c120c 100644 --- a/spec/graphql/types/notes/note_type_spec.rb +++ b/spec/graphql/types/notes/note_type_spec.rb @@ -7,9 +7,9 @@ describe GitlabSchema.types['Note'] do :updated_at, :discussion, :resolvable, :position, :user_permissions, :resolved_by, :resolved_at, :system, :body_html] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to expose_permissions_using(Types::PermissionTypes::Note) } - it { is_expected.to require_graphql_authorizations(:read_note) } + it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Note) } + it { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/noteable_type_spec.rb b/spec/graphql/types/notes/noteable_type_spec.rb index d10c79b5344..a4259e160e0 100644 --- a/spec/graphql/types/notes/noteable_type_spec.rb +++ b/spec/graphql/types/notes/noteable_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Types::Notes::NoteableType do - it { is_expected.to have_graphql_fields(:notes, :discussions) } + it { expect(described_class).to have_graphql_fields(:notes, :discussions) } describe ".resolve_type" do it 'knows the correct type for objects' do diff --git a/spec/graphql/types/permission_types/base_permission_type_spec.rb b/spec/graphql/types/permission_types/base_permission_type_spec.rb index aa6b4320006..4c6d5fd369a 100644 --- a/spec/graphql/types/permission_types/base_permission_type_spec.rb +++ b/spec/graphql/types/permission_types/base_permission_type_spec.rb @@ -19,13 +19,13 @@ describe Types::PermissionTypes::BasePermissionType do describe '.permission_field' do it 'adds a field for the required permission' do - is_expected.to have_graphql_field(:do_stuff) + expect(test_type).to have_graphql_field(:do_stuff) end end describe '.ability_field' do it 'adds a field for the required permission' do - is_expected.to have_graphql_field(:read_issue) + expect(test_type).to have_graphql_field(:read_issue) end it 'does not add a resolver block if another resolving param is passed' do @@ -44,7 +44,7 @@ describe Types::PermissionTypes::BasePermissionType do describe '.abilities' do it 'adds a field for the passed permissions' do - is_expected.to have_graphql_field(:admin_issue) + expect(test_type).to have_graphql_field(:admin_issue) end end end diff --git a/spec/graphql/types/permission_types/note_spec.rb b/spec/graphql/types/permission_types/note_spec.rb index a7811fc20e5..a2becb6892b 100644 --- a/spec/graphql/types/permission_types/note_spec.rb +++ b/spec/graphql/types/permission_types/note_spec.rb @@ -8,6 +8,6 @@ describe GitlabSchema.types['NotePermissions'] do :read_note, :create_note, :admin_note, :resolve_note, :award_emoji ] - is_expected.to have_graphql_fields(expected_permissions) + expect(described_class).to have_graphql_fields(expected_permissions) end end diff --git a/spec/graphql/types/project_statistics_type_spec.rb b/spec/graphql/types/project_statistics_type_spec.rb index e9feac57a36..fbea780494b 100644 --- a/spec/graphql/types/project_statistics_type_spec.rb +++ b/spec/graphql/types/project_statistics_type_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe GitlabSchema.types['ProjectStatistics'] do it "has all the required fields" do - is_expected.to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, + expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :commit_count, :wiki_size) end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 9c6d1e3f35c..475ae9ff5f6 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -27,7 +27,7 @@ describe GitlabSchema.types['Project'] do boards ] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'issue field' do diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb index 236f9bb9459..f746e75b574 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -7,7 +7,7 @@ describe GitlabSchema.types['Repository'] do it { expect(described_class).to require_graphql_authorizations(:download_code) } - it { is_expected.to have_graphql_field(:root_ref) } + it { expect(described_class).to have_graphql_field(:root_ref) } - it { is_expected.to have_graphql_field(:tree) } + it { expect(described_class).to have_graphql_field(:tree) } end diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb index 8c69c13aa73..b796b974b82 100644 --- a/spec/graphql/types/root_storage_statistics_type_spec.rb +++ b/spec/graphql/types/root_storage_statistics_type_spec.rb @@ -6,9 +6,9 @@ describe GitlabSchema.types['RootStorageStatistics'] do it { expect(described_class.graphql_name).to eq('RootStorageStatistics') } it 'has all the required fields' do - is_expected.to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, + expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :wiki_size) end - it { is_expected.to require_graphql_authorizations(:read_statistics) } + it { expect(described_class).to require_graphql_authorizations(:read_statistics) } end diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb index 97573f8c46b..afac480d06b 100644 --- a/spec/graphql/types/snippet_type_spec.rb +++ b/spec/graphql/types/snippet_type_spec.rb @@ -10,7 +10,7 @@ describe GitlabSchema.types['Snippet'] do :web_url, :raw_url, :notes, :discussions, :user_permissions, :description_html, :blob] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'authorizations' do diff --git a/spec/graphql/types/snippets/blob_type_spec.rb b/spec/graphql/types/snippets/blob_type_spec.rb index b6253e96d60..da36ab80f44 100644 --- a/spec/graphql/types/snippets/blob_type_spec.rb +++ b/spec/graphql/types/snippets/blob_type_spec.rb @@ -8,6 +8,6 @@ describe GitlabSchema.types['SnippetBlob'] do :raw_path, :size, :binary, :name, :path, :simple_viewer, :rich_viewer, :mode] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/snippets/blob_viewer_type_spec.rb b/spec/graphql/types/snippets/blob_viewer_type_spec.rb index f1f7608cb69..a51d09813ab 100644 --- a/spec/graphql/types/snippets/blob_viewer_type_spec.rb +++ b/spec/graphql/types/snippets/blob_viewer_type_spec.rb @@ -7,6 +7,6 @@ describe GitlabSchema.types['SnippetBlobViewer'] do expected_fields = [:type, :load_async, :too_large, :collapsed, :render_error, :file_type, :loading_partial_name] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/todo_type_spec.rb b/spec/graphql/types/todo_type_spec.rb index a5ea5bcffb0..59118259d09 100644 --- a/spec/graphql/types/todo_type_spec.rb +++ b/spec/graphql/types/todo_type_spec.rb @@ -6,7 +6,7 @@ describe GitlabSchema.types['Todo'] do it 'has the correct fields' do expected_fields = [:id, :project, :group, :author, :action, :target_type, :body, :state, :created_at] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end it { expect(described_class).to require_graphql_authorizations(:read_todo) } diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index b9174b9a90b..8c76ce43e95 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -12,7 +12,7 @@ describe GitlabSchema.types['User'] do user_permissions snippets name username avatarUrl webUrl todos ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'snippets field' do diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb index cbe617359ef..2890b8d4f3b 100644 --- a/spec/lib/feature_spec.rb +++ b/spec/lib/feature_spec.rb @@ -42,7 +42,7 @@ describe Feature do .once .and_call_original - expect(Gitlab::ThreadMemoryCache.cache_backend) + expect(Gitlab::ProcessMemoryCache.cache_backend) .to receive(:fetch) .once .with('flipper:persisted_names', expires_in: 1.minute) diff --git a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb index 915b73ed5a7..b27a4cd4f80 100644 --- a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb +++ b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb @@ -17,7 +17,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do allow(cop).to receive(:in_migration?).and_return(true) end - described_class::SMALL_TABLES.each do |table| + described_class::WHITELISTED_TABLES.each do |table| context "for the #{table} table" do sources_and_offense = [ ["add_column :#{table}, :column, :boolean, default: true", 'should disallow nulls'], @@ -62,14 +62,14 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do end end - it 'registers no offense for tables not listed in SMALL_TABLES' do + it 'registers no offense for tables not listed in WHITELISTED_TABLES' do inspect_source("add_column :large_table, :column, :boolean") expect(cop.offenses).to be_empty end it 'registers no offense for non-boolean columns' do - table = described_class::SMALL_TABLES.sample + table = described_class::WHITELISTED_TABLES.sample inspect_source("add_column :#{table}, :column, :string") expect(cop.offenses).to be_empty @@ -78,7 +78,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do context 'outside of migration' do it 'registers no offense' do - table = described_class::SMALL_TABLES.sample + table = described_class::WHITELISTED_TABLES.sample inspect_source("add_column :#{table}, :column, :boolean") expect(cop.offenses).to be_empty diff --git a/spec/rubocop/cop/migration/update_large_table_spec.rb b/spec/rubocop/cop/migration/update_large_table_spec.rb index 0463b6550a8..bdb0ca3466b 100644 --- a/spec/rubocop/cop/migration/update_large_table_spec.rb +++ b/spec/rubocop/cop/migration/update_large_table_spec.rb @@ -18,7 +18,7 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do end shared_examples 'large tables' do |update_method| - described_class::LARGE_TABLES.each do |table| + described_class::BLACKLISTED_TABLES.each do |table| it "registers an offense for the #{table} table" do inspect_source("#{update_method} :#{table}, :column, default: true") @@ -53,7 +53,7 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do end it 'registers no offense for non-blacklisted methods' do - table = described_class::LARGE_TABLES.sample + table = described_class::BLACKLISTED_TABLES.sample inspect_source("some_other_method :#{table}, :column, default: true") @@ -62,7 +62,7 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do end context 'outside of migration' do - let(:table) { described_class::LARGE_TABLES.sample } + let(:table) { described_class::BLACKLISTED_TABLES.sample } it 'registers no offense for add_column_with_default' do inspect_source("add_column_with_default :#{table}, :column, default: true") diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 370162b45f0..1bb942ff39b 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -71,10 +71,10 @@ module GraphqlHelpers mutation_name = GraphqlHelpers.fieldnamerize(name) input_variable_name = "$#{input_variable_name_for_mutation(name)}" mutation_field = GitlabSchema.mutation.fields[mutation_name] - fields ||= all_graphql_fields_for(mutation_field.type) + fields ||= all_graphql_fields_for(mutation_field.type.to_graphql) query = <<~MUTATION - mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type}) { + mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type.to_graphql}) { #{mutation_name}(input: #{input_variable_name}) { #{fields} } @@ -118,15 +118,22 @@ module GraphqlHelpers GraphqlHelpers.fieldnamerize(input_type) end - def query_graphql_field(name, attributes = {}, fields = nil) - field_params = if attributes.present? + def field_with_params(name, attributes = {}) + namerized = GraphqlHelpers.fieldnamerize(name.to_s) + return "#{namerized}" if attributes.blank? + + field_params = if attributes.is_a?(Hash) "(#{attributes_to_graphql(attributes)})" else - '' + "(#{attributes})" end + "#{namerized}#{field_params}" + end + + def query_graphql_field(name, attributes = {}, fields = nil) <<~QUERY - #{GraphqlHelpers.fieldnamerize(name.to_s)}#{field_params} + #{field_with_params(name, attributes)} #{wrap_fields(fields || all_graphql_fields_for(name.to_s.classify))} QUERY end @@ -300,7 +307,7 @@ module GraphqlHelpers end def field_type(field) - field_type = field.type + field_type = field.type.respond_to?(:to_graphql) ? field.type.to_graphql : field.type # The type could be nested. For example `[GraphQL::STRING_TYPE]`: # - List diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb index 31b0290bb15..6439b68764e 100644 --- a/spec/support/matchers/graphql_matchers.rb +++ b/spec/support/matchers/graphql_matchers.rb @@ -2,7 +2,7 @@ RSpec::Matchers.define :require_graphql_authorizations do |*expected| match do |field| - expect(field.metadata[:authorize]).to eq(*expected) + expect(field.to_graphql.metadata[:authorize]).to eq(*expected) end end @@ -87,13 +87,13 @@ end RSpec::Matchers.define :have_graphql_type do |expected| match do |field| - expect(field.type).to eq(expected.to_graphql) + expect(field.type).to eq(expected) end end RSpec::Matchers.define :have_non_null_graphql_type do |expected| match do |field| - expect(field.type).to eq(!expected.to_graphql) + expect(field.type.to_graphql).to eq(!expected.to_graphql) end end @@ -101,16 +101,16 @@ RSpec::Matchers.define :have_graphql_resolver do |expected| match do |field| case expected when Method - expect(field.metadata[:type_class].resolve_proc).to eq(expected) + expect(field.to_graphql.metadata[:type_class].resolve_proc).to eq(expected) else - expect(field.metadata[:type_class].resolver).to eq(expected) + expect(field.to_graphql.metadata[:type_class].resolver).to eq(expected) end end end RSpec::Matchers.define :have_graphql_extension do |expected| match do |field| - expect(field.metadata[:type_class].extensions).to include(expected) + expect(field.to_graphql.metadata[:type_class].extensions).to include(expected) end end diff --git a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb index ca77c68c130..4c80bbef153 100644 --- a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb +++ b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb @@ -15,7 +15,7 @@ RSpec.shared_context 'group and project boards query context' do board_parent_type, { 'fullPath' => board_parent.full_path }, <<~BOARDS - boards(#{board_params}) { + #{field_with_params('boards', board_params)} { pageInfo { startCursor endCursor @@ -35,7 +35,7 @@ RSpec.shared_context 'group and project boards query context' do board_parent_type, { 'fullPath' => board_parent.full_path }, <<~BOARD - board(#{board_params}) { + #{field_with_params('board', board_params)} { #{all_graphql_fields_for('board'.classify)} } BOARD |