summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml1
-rw-r--r--.gitlab/ci/cache-repo.gitlab-ci.yml8
-rw-r--r--.gitlab/ci/cng.gitlab-ci.yml8
-rw-r--r--.gitlab/ci/dev-fixtures.gitlab-ci.yml45
-rw-r--r--.gitlab/ci/docs.gitlab-ci.yml61
-rw-r--r--.gitlab/ci/frontend.gitlab-ci.yml162
-rw-r--r--.gitlab/ci/global.gitlab-ci.yml176
-rw-r--r--.gitlab/ci/memory.gitlab-ci.yml25
-rw-r--r--.gitlab/ci/pages.gitlab-ci.yml35
-rw-r--r--.gitlab/ci/qa.gitlab-ci.yml87
-rw-r--r--.gitlab/ci/rails.gitlab-ci.yml106
-rw-r--r--.gitlab/ci/releases.gitlab-ci.yml8
-rw-r--r--.gitlab/ci/reports.gitlab-ci.yml123
-rw-r--r--.gitlab/ci/review.gitlab-ci.yml60
-rw-r--r--.gitlab/ci/rules.gitlab-ci.yml500
-rw-r--r--.gitlab/ci/setup.gitlab-ci.yml87
-rw-r--r--.gitlab/ci/test-metadata.gitlab-ci.yml53
-rw-r--r--.gitlab/ci/yaml.gitlab-ci.yml5
-rw-r--r--app/controllers/users/terms_controller.rb2
-rw-r--r--app/models/project_services/jira_service.rb12
-rw-r--r--app/views/groups/registry/repositories/index.html.haml1
-rw-r--r--app/views/projects/registry/repositories/index.html.haml1
-rw-r--r--changelogs/unreleased/198325-migrate-design-mentions-to-db-table.yml5
-rw-r--r--changelogs/unreleased/204723-nomethoderror-undefined-method-term_agreements-for-nil-nilclass.yml5
-rw-r--r--changelogs/unreleased/a11y-ci-template.yml5
-rw-r--r--changelogs/unreleased/add-missing-secure-queues-changelog.yml5
-rw-r--r--changelogs/unreleased/ak-drop-etag.yml5
-rw-r--r--db/post_migrate/20200124110831_migrate_design_notes_mentions_to_db.rb61
-rw-r--r--db/schema.rb1
-rw-r--r--doc/development/background_migrations.md2
-rw-r--r--doc/development/pipelines.md236
-rw-r--r--doc/install/aws/index.md2
-rw-r--r--doc/system_hooks/system_hooks.md6
-rw-r--r--doc/user/project/integrations/prometheus.md17
-rw-r--r--doc/user/project/merge_requests/accessibility_testing.md53
-rw-r--r--doc/user/project/merge_requests/index.md1
-rw-r--r--lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb3
-rw-r--r--lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb12
-rw-r--r--lib/gitlab/background_migration/user_mentions/models/design.rb32
-rw-r--r--lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb18
-rw-r--r--lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml27
-rw-r--r--lib/gitlab/template/finders/global_template_finder.rb17
-rw-r--r--lib/gitlab/template/gitlab_ci_yml_template.rb11
-rw-r--r--spec/controllers/users/terms_controller_spec.rb146
-rw-r--r--spec/graphql/features/authorization_spec.rb3
-rw-r--r--spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb10
-rw-r--r--spec/graphql/resolvers/group_resolver_spec.rb4
-rw-r--r--spec/graphql/resolvers/issues_resolver_spec.rb10
-rw-r--r--spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb8
-rw-r--r--spec/graphql/resolvers/merge_requests_resolver_spec.rb13
-rw-r--r--spec/graphql/resolvers/project_pipelines_resolver_spec.rb6
-rw-r--r--spec/graphql/resolvers/project_resolver_spec.rb7
-rw-r--r--spec/helpers/auto_devops_helper_spec.rb4
-rw-r--r--spec/helpers/boards_helper_spec.rb2
-rw-r--r--spec/helpers/environments_helper_spec.rb6
-rw-r--r--spec/helpers/labels_helper_spec.rb14
-rw-r--r--spec/helpers/markup_helper_spec.rb18
-rw-r--r--spec/helpers/projects/error_tracking_helper_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/templates/templates_spec.rb50
-rw-r--r--spec/lib/gitlab/template/finders/global_template_finder_spec.rb84
-rw-r--r--spec/mailers/emails/pages_domains_spec.rb4
-rw-r--r--spec/mailers/emails/pipelines_spec.rb2
-rw-r--r--spec/mailers/notify_spec.rb22
-rw-r--r--spec/models/project_services/jira_service_spec.rb9
-rw-r--r--spec/policies/application_setting/term_policy_spec.rb2
-rw-r--r--spec/policies/ci/pipeline_schedule_policy_spec.rb6
-rw-r--r--spec/policies/project_policy_spec.rb12
-rw-r--r--spec/policies/resource_label_event_policy_spec.rb8
-rw-r--r--spec/requests/api/internal/base_spec.rb193
-rw-r--r--spec/services/post_receive_service_spec.rb186
-rw-r--r--spec/support/shared_examples/lib/gitlab/background_migration/mentions_migration_shared_examples.rb8
71 files changed, 1385 insertions, 1546 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fec78218958..19dca0b2fcd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -36,6 +36,7 @@ include:
- local: .gitlab/ci/reports.gitlab-ci.yml
- local: .gitlab/ci/rails.gitlab-ci.yml
- local: .gitlab/ci/review.gitlab-ci.yml
+ - local: .gitlab/ci/rules.gitlab-ci.yml
- local: .gitlab/ci/setup.gitlab-ci.yml
- local: .gitlab/ci/dev-fixtures.gitlab-ci.yml
- local: .gitlab/ci/test-metadata.gitlab-ci.yml
diff --git a/.gitlab/ci/cache-repo.gitlab-ci.yml b/.gitlab/ci/cache-repo.gitlab-ci.yml
index 670341eab65..ecbed0ed6c8 100644
--- a/.gitlab/ci/cache-repo.gitlab-ci.yml
+++ b/.gitlab/ci/cache-repo.gitlab-ci.yml
@@ -1,7 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-cache-credentials-schedule: &if-cache-credentials-schedule
- if: '$CI_REPO_CACHE_CREDENTIALS && $CI_PIPELINE_SOURCE == "schedule"'
-
# Builds a cached .tar.gz of the master branch with full history and
# uploads it to Google Cloud Storage. This archive is downloaded by a
# script defined by a CI/CD variable named CI_PRE_CLONE_SCRIPT. This has
@@ -22,6 +18,7 @@
# runner, or network egress charges will apply:
# https://cloud.google.com/storage/pricing
cache-repo:
+ extends: .cache-repo:rules
image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
stage: sync
allow_failure: true
@@ -38,6 +35,3 @@ cache-repo:
- tar cf $TAR_FILENAME .
- gzip $TAR_FILENAME
- gsutil cp $TAR_FILENAME.gz gs://gitlab-ci-git-repo-cache/project-$CI_PROJECT_ID/gitlab-master.tar.gz
- rules:
- - <<: *if-cache-credentials-schedule
- when: on_success
diff --git a/.gitlab/ci/cng.gitlab-ci.yml b/.gitlab/ci/cng.gitlab-ci.yml
index fa22c22a8ab..2450e346569 100644
--- a/.gitlab/ci/cng.gitlab-ci.yml
+++ b/.gitlab/ci/cng.gitlab-ci.yml
@@ -1,8 +1,5 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-dot-com-gitlab-org-groups-tag: &if-canonical-dot-com-gitlab-org-groups-tag
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/ && $CI_COMMIT_TAG'
-
cloud-native-image:
+ extends: .cng:rules
image: ruby:2.6-alpine
dependencies: []
stage: post-test
@@ -12,6 +9,3 @@ cloud-native-image:
script:
- install_gitlab_gem
- CNG_PROJECT_PATH="gitlab-org/build/CNG" BUILD_TRIGGER_TOKEN=$CI_JOB_TOKEN ./scripts/trigger-build cng
- rules:
- - <<: *if-canonical-dot-com-gitlab-org-groups-tag
- when: manual
diff --git a/.gitlab/ci/dev-fixtures.gitlab-ci.yml b/.gitlab/ci/dev-fixtures.gitlab-ci.yml
index a0b5100992b..e08f7e969cb 100644
--- a/.gitlab/ci/dev-fixtures.gitlab-ci.yml
+++ b/.gitlab/ci/dev-fixtures.gitlab-ci.yml
@@ -1,48 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-ee: &if-not-ee
- if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-patterns: &code-backstage-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-.dev-fixtures:rules:ee-and-foss:
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
-
-.dev-fixtures:rules:ee-only:
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
-
.run-dev-fixtures:
extends:
- .default-tags
diff --git a/.gitlab/ci/docs.gitlab-ci.yml b/.gitlab/ci/docs.gitlab-ci.yml
index b6680461da4..59f1773da2e 100644
--- a/.gitlab/ci/docs.gitlab-ci.yml
+++ b/.gitlab/ci/docs.gitlab-ci.yml
@@ -1,55 +1,8 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-dot-com-gitlab-org-groups-merge-request: &if-canonical-dot-com-gitlab-org-groups-merge-request
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/ && $CI_MERGE_REQUEST_IID'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-ee: &if-not-ee
- if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-docs-patterns: &code-docs-patterns
- - ".gitlab/route-map.yml"
- - "doc/**/*"
- - ".markdownlint.json"
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-qa-patterns: &code-backstage-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
.review-docs:
extends:
- .default-tags
- .default-retry
- rules:
- - <<: *if-canonical-dot-com-gitlab-org-groups-merge-request
- changes: *code-docs-patterns
- when: manual
+ - .docs:rules:review-docs
allow_failure: true
image: ruby:2.6-alpine
stage: review
@@ -90,10 +43,7 @@ docs lint:
extends:
- .default-tags
- .default-retry
- rules:
- - <<: *if-default-refs
- changes: *code-docs-patterns
- when: on_success
+ - .docs:rules:docs-lint
image: "registry.gitlab.com/gitlab-org/gitlab-docs:docs-lint"
stage: test
dependencies: []
@@ -117,13 +67,8 @@ graphql-reference-verify:
- .default-retry
- .default-cache
- .default-before_script
+ - .docs:rules:graphql-reference-verify
- .use-pg9
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-qa-patterns
- when: on_success
stage: test
needs: ["setup-test-env"]
script:
diff --git a/.gitlab/ci/frontend.gitlab-ci.yml b/.gitlab/ci/frontend.gitlab-ci.yml
index 26e0b4fdf08..3a72c941b89 100644
--- a/.gitlab/ci/frontend.gitlab-ci.yml
+++ b/.gitlab/ci/frontend.gitlab-ci.yml
@@ -1,68 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-canonical-namespace: &if-not-canonical-namespace
- if: '$CI_PROJECT_NAMESPACE !~ /^gitlab(-org)?($|\/)/'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-ee: &if-not-ee
- if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-master-refs: &if-master-refs
- if: '$CI_COMMIT_REF_NAME == "master"'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-patterns: &code-backstage-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-qa-patterns: &code-backstage-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
.assets-compile-cache:
cache:
paths:
@@ -113,24 +48,16 @@
- docker
gitlab:assets:compile pull-push-cache:
- extends: .gitlab:assets:compile-metadata
- rules:
- - <<: *if-not-canonical-namespace
- when: never
- - <<: *if-master-refs
- changes: *code-backstage-qa-patterns
- when: on_success
+ extends:
+ - .gitlab:assets:compile-metadata
+ - .frontend:rules:gitlab-assets-compile-pull-push-cache
cache:
policy: pull-push
gitlab:assets:compile pull-cache:
- extends: .gitlab:assets:compile-metadata
- rules:
- - <<: *if-not-canonical-namespace
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-qa-patterns
- when: on_success
+ extends:
+ - .gitlab:assets:compile-metadata
+ - .frontend:rules:gitlab-assets-compile-pull-cache
cache:
policy: pull
@@ -160,47 +87,33 @@ gitlab:assets:compile pull-cache:
- public/assets
compile-assets pull-push-cache:
- extends: .compile-assets-metadata
- rules:
- - <<: *if-master-refs
- changes: *code-backstage-qa-patterns
- when: on_success
+ extends:
+ - .compile-assets-metadata
+ - .frontend:rules:compile-assets-pull-push-cache
cache:
policy: pull-push
-compile-assets pull-push-cache foss:
+compile-assets pull-push-cache as-if-foss:
extends:
- .compile-assets-metadata
+ - .frontend:rules:compile-assets-pull-push-cache-as-if-foss
- .as-if-foss
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-master-refs
- changes: *code-backstage-qa-patterns
- when: on_success
cache:
policy: pull-push
key: "assets-compile:v9:foss"
compile-assets pull-cache:
- extends: .compile-assets-metadata
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-qa-patterns
- when: on_success
+ extends:
+ - .compile-assets-metadata
+ - .frontend:rules:compile-assets-pull-cache
cache:
policy: pull
-compile-assets pull-cache foss:
+compile-assets pull-cache as-if-foss:
extends:
- .compile-assets-metadata
+ - .frontend:rules:compile-assets-pull-cache-as-if-foss
- .as-if-foss
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-qa-patterns
- when: on_success
cache:
policy: pull
key: "assets-compile:v9:foss"
@@ -228,11 +141,9 @@ compile-assets pull-cache foss:
- bundle exec rake karma
karma:
- extends: .karma-base
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
+ extends:
+ - .karma-base
+ - .frontend:rules:default-frontend-jobs
coverage: '/^Statements *: (\d+\.\d+%)/'
artifacts:
name: coverage-javascript
@@ -245,16 +156,11 @@ karma:
reports:
junit: junit_karma.xml
-karma-foss:
+karma-as-if-foss:
extends:
- .karma-base
+ - .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
.jest-base:
extends: .frontend-job-base
@@ -271,11 +177,9 @@ karma-foss:
policy: pull-push
jest:
- extends: .jest-base
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
+ extends:
+ - .jest-base
+ - .frontend:rules:default-frontend-jobs
artifacts:
name: coverage-frontend
expire_in: 31d
@@ -287,16 +191,11 @@ jest:
reports:
junit: junit_jest.xml
-jest-foss:
+jest-as-if-foss:
extends:
- .jest-base
+ - .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
cache:
policy: pull
@@ -305,10 +204,8 @@ jest-foss:
- .default-tags
- .default-retry
- .default-cache
+ - .frontend:rules:qa-frontend-node
stage: test
- rules:
- - <<: *if-master-refs
- when: on_success
dependencies: []
cache:
key: "$CI_JOB_NAME"
@@ -339,11 +236,8 @@ webpack-dev-server:
- .default-tags
- .default-retry
- .default-cache
+ - .frontend:rules:default-frontend-jobs
stage: test
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
needs: ["setup-test-env", "compile-assets pull-cache"]
variables:
WEBPACK_MEMORY_TEST: "true"
diff --git a/.gitlab/ci/global.gitlab-ci.yml b/.gitlab/ci/global.gitlab-ci.yml
index babdfb2ed75..ffdc115cff7 100644
--- a/.gitlab/ci/global.gitlab-ci.yml
+++ b/.gitlab/ci/global.gitlab-ci.yml
@@ -33,171 +33,6 @@
- vendor/gitaly-ruby
policy: pull
-.default-only:
- only:
- refs:
- - master
- - /^[\d-]+-stable(-ee)?$/
- - /^\d+-\d+-auto-deploy-\d+$/
- - /^security\//
- - merge_requests
- - tags
-
-.only:variables-canonical-dot-com:
- only:
- variables:
- - $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/ # Matches the gitlab-org group or its subgroups
-
-.only:variables_refs-canonical-dot-com-schedules:
- extends: .only:variables-canonical-dot-com
- only:
- refs:
- - schedules
-
-.except:refs-deploy:
- except:
- refs:
- - /^\d+-\d+-auto-deploy-\d+$/
-
-.except:refs-master-tags-stable-deploy:
- except:
- refs:
- - master
- - tags
- - /^[\d-]+-stable(-ee)?$/
- - /^\d+-\d+-auto-deploy-\d+$/
-
-.only:kubernetes:
- only:
- kubernetes: active
-
-.only-review:
- extends:
- - .only:variables-canonical-dot-com
- - .only:kubernetes
- - .except:refs-master-tags-stable-deploy
-
-.only-review-schedules:
- extends:
- - .only:variables_refs-canonical-dot-com-schedules
- - .only:kubernetes
- - .except:refs-deploy
-
-.code-patterns: &code-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
-
-.backstage-patterns: &backstage-patterns
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-.qa-patterns: &qa-patterns
- - ".dockerignore"
- - "qa/**/*"
-
-.docs-patterns: &docs-patterns
- - ".gitlab/route-map.yml"
- - "doc/**/*"
- - ".markdownlint.json"
-
-.only:changes-code:
- only:
- changes: *code-patterns
-
-.only:changes-qa:
- only:
- changes: *qa-patterns
-
-.only:changes-docs:
- only:
- changes: *docs-patterns
-
-.only:changes-code-backstage:
- only:
- changes:
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-.only:changes-code-qa:
- only:
- changes:
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
-.only:changes-code-backstage-qa:
- only:
- changes:
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
.use-pg9:
services:
- name: postgres:9.6.17
@@ -234,17 +69,6 @@
variables:
POSTGRES_HOST_AUTH_METHOD: trust
-.only-ee:
- only:
- variables:
- - $CI_PROJECT_NAME == "gitlab"
- - $CI_PROJECT_NAME == "gitlab-ee" # Support former project name for forks/mirrors
-
.as-if-foss:
variables:
FOSS_ONLY: '1'
-
-.only-ee-as-if-foss:
- extends:
- - .only-ee
- - .as-if-foss
diff --git a/.gitlab/ci/memory.gitlab-ci.yml b/.gitlab/ci/memory.gitlab-ci.yml
index e0b430354d0..a8e2d90a4ee 100644
--- a/.gitlab/ci/memory.gitlab-ci.yml
+++ b/.gitlab/ci/memory.gitlab-ci.yml
@@ -1,33 +1,10 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-patterns: &code-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
-
.only-code-memory-job-base:
extends:
- .default-tags
- .default-retry
- .default-cache
- .default-before_script
- rules:
- - <<: *if-default-refs
- changes: *code-patterns
- when: on_success
+ - .memory:rules
memory-static:
extends: .only-code-memory-job-base
diff --git a/.gitlab/ci/pages.gitlab-ci.yml b/.gitlab/ci/pages.gitlab-ci.yml
index 6c52afb068f..993ed21e39d 100644
--- a/.gitlab/ci/pages.gitlab-ci.yml
+++ b/.gitlab/ci/pages.gitlab-ci.yml
@@ -1,42 +1,9 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-dot-com-gitlab-org-group-master-refs: &if-canonical-dot-com-gitlab-org-group-master-refs
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_COMMIT_REF_NAME == "master"'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-qa-patterns: &code-backstage-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
pages:
extends:
- .default-tags
- .default-retry
- .default-cache
- rules:
- - <<: *if-canonical-dot-com-gitlab-org-group-master-refs
- changes: *code-backstage-qa-patterns
- when: on_success
+ - .pages:rules
stage: pages
dependencies: ["coverage", "karma", "gitlab:assets:compile pull-cache"]
script:
diff --git a/.gitlab/ci/qa.gitlab-ci.yml b/.gitlab/ci/qa.gitlab-ci.yml
index deb966fdbaf..0e9d7abb3ac 100644
--- a/.gitlab/ci/qa.gitlab-ci.yml
+++ b/.gitlab/ci/qa.gitlab-ci.yml
@@ -1,73 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-dot-com-gitlab-org-group-schedule: &if-canonical-dot-com-gitlab-org-group-schedule
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-gitlab-merge-request: &if-canonical-gitlab-merge-request
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_MERGE_REQUEST_IID'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-ee: &if-not-ee
- if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-patterns: &code-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.qa-patterns: &qa-patterns
- - ".dockerignore"
- - "qa/**/*"
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-qa-patterns: &code-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
-.qa:rules:ee-and-foss:
- rules:
- - <<: *if-default-refs
- changes: *code-qa-patterns
- when: on_success
-
-.qa:rules:ee-only:
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-default-refs
- changes: *code-qa-patterns
- when: on_success
-
.qa-job-base:
extends:
- .default-tags
@@ -91,7 +21,7 @@ qa:internal:
script:
- bundle exec rspec
-qa:internal-foss:
+qa:internal-as-if-foss:
extends:
- .qa-job-base
- .qa:rules:ee-only
@@ -106,7 +36,7 @@ qa:selectors:
script:
- bundle exec bin/qa Test::Sanity::Selectors
-qa:selectors-foss:
+qa:selectors-as-if-foss:
extends:
- qa:selectors
- .qa:rules:ee-only
@@ -123,15 +53,8 @@ qa:selectors-foss:
- ./scripts/trigger-build omnibus
package-and-qa:
- extends: .package-and-qa-base
- rules:
- - <<: *if-canonical-gitlab-merge-request
- changes: *qa-patterns
- when: on_success
- - <<: *if-canonical-gitlab-merge-request
- changes: *code-patterns
- when: manual
- - <<: *if-canonical-dot-com-gitlab-org-group-schedule
- when: on_success
+ extends:
+ - .package-and-qa-base
+ - .qa:rules:package-and-qa
needs: ["build-qa-image", "gitlab:assets:compile pull-cache"]
allow_failure: true
diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml
index 066a9515980..58c4ef0e02a 100644
--- a/.gitlab/ci/rails.gitlab-ci.yml
+++ b/.gitlab/ci/rails.gitlab-ci.yml
@@ -1,102 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-ee: &if-not-ee
- if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-master-refs: &if-master-refs
- if: '$CI_COMMIT_REF_NAME == "master"'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-merge-request: &if-merge-request
- if: '$CI_MERGE_REQUEST_IID'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-patterns: &code-backstage-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-qa-patterns: &code-backstage-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
-.rails:rules:ee-and-foss:
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
-
-.rails:rules:default-refs-code-backstage-qa:
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-qa-patterns
- when: on_success
-
-.rails:rules:master-refs-code-backstage:
- rules:
- - <<: *if-master-refs
- changes: *code-backstage-patterns
- when: on_success
-
-.rails:rules:master-refs-code-backstage-ee-only:
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-master-refs
- changes: *code-backstage-patterns
- when: on_success
-
-.rails:rules:ee-only:
- rules:
- - <<: *if-not-ee
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
-
.rails:needs:setup-and-assets:
needs:
- job: setup-test-env
@@ -153,11 +54,8 @@ downtime_check:
extends:
- .rails-job-base
- .rails:needs:setup-and-assets
+ - .rails:rules:downtime_check
stage: test
- rules:
- - <<: *if-merge-request
- changes: *code-backstage-patterns
- when: on_success
variables:
SETUP_DB: "false"
script:
@@ -407,7 +305,7 @@ rspec-ee system pg10:
artifacts: true
- job: retrieve-tests-metadata
artifacts: true
- - job: compile-assets pull-cache foss
+ - job: compile-assets pull-cache as-if-foss
artifacts: true
.rspec-ee-base-pg9:
diff --git a/.gitlab/ci/releases.gitlab-ci.yml b/.gitlab/ci/releases.gitlab-ci.yml
index 0f6753aa274..b3f961afe62 100644
--- a/.gitlab/ci/releases.gitlab-ci.yml
+++ b/.gitlab/ci/releases.gitlab-ci.yml
@@ -1,11 +1,3 @@
-.releases:rules:canonical-dot-com-gitlab-stable-branch-only:
- rules:
- - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAME == "gitlab-org/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
-
-.releases:rules:canonical-dot-com-security-gitlab-stable-branch-only:
- rules:
- - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAME == "gitlab-org/security/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
-
# Syncs any changes pushed to a stable branch to the corresponding
# gitlab-foss/CE stable branch. We run this prior to any tests so that random
# failures don't prevent a sync.
diff --git a/.gitlab/ci/reports.gitlab-ci.yml b/.gitlab/ci/reports.gitlab-ci.yml
index 797ec4f5860..e7ee47fbe0a 100644
--- a/.gitlab/ci/reports.gitlab-ci.yml
+++ b/.gitlab/ci/reports.gitlab-ci.yml
@@ -1,118 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-gitlab-merge-request: &if-canonical-gitlab-merge-request
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_MERGE_REQUEST_IID'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-dot-com-gitlab-org-group-schedule: &if-canonical-dot-com-gitlab-org-group-schedule
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-master-refs: &if-master-refs
- if: '$CI_COMMIT_REF_NAME == "master"'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-patterns: &code-backstage-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-qa-patterns: &code-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-qa-patterns: &code-backstage-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
-.reports:rules:code_quality:
- rules:
- - if: '$CODE_QUALITY_DISABLED'
- when: never
- # - <<: *if-master-refs # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
- - <<: *if-default-refs
- changes: *code-backstage-patterns
-
-.reports:rules:sast:
- rules:
- - if: '$SAST_DISABLED || $GITLAB_FEATURES !~ /\bsast\b/'
- when: never
- # - <<: *if-master-refs # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
- - <<: *if-default-refs
- changes: *code-backstage-qa-patterns
-
-.reports:rules:dependency_scanning:
- rules:
- - if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/'
- when: never
- # - <<: *if-master-refs # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
- - <<: *if-default-refs
- changes: *code-backstage-qa-patterns
-
-.reports:rules:dast:
- rules:
- - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
- when: never
- - <<: *if-canonical-gitlab-merge-request
- changes: *code-qa-patterns
-
# include:
# - template: Jobs/Code-Quality.gitlab-ci.yml
# - template: Security/SAST.gitlab-ci.yml
@@ -299,10 +184,8 @@ dast:
# To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
# schedule:dast:
-# extends: dast
-# rules:
-# - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
-# when: never
-# - <<: *if-canonical-dot-com-gitlab-org-group-schedule
+# extends:
+# - dast
+# - .reports:schedule-dast
# variables:
# DAST_FULL_SCAN_ENABLED: "true"
diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml
index c15c7c2ab5d..e23708337a4 100644
--- a/.gitlab/ci/review.gitlab-ci.yml
+++ b/.gitlab/ci/review.gitlab-ci.yml
@@ -1,63 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-dot-com-gitlab-org-group-schedule: &if-canonical-dot-com-gitlab-org-group-schedule
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-gitlab-merge-request: &if-canonical-gitlab-merge-request
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_MERGE_REQUEST_IID'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-qa-patterns: &code-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
-.review:rules:mr-and-schedule:
- rules:
- - <<: *if-canonical-gitlab-merge-request
- changes: *code-qa-patterns
- when: on_success
- - <<: *if-canonical-dot-com-gitlab-org-group-schedule
- when: on_success
-
-.review:rules:mr-only-auto:
- rules:
- - <<: *if-canonical-gitlab-merge-request
- changes: *code-qa-patterns
- when: on_success
-
-.review:rules:mr-only-manual:
- rules:
- - <<: *if-canonical-gitlab-merge-request
- changes: *code-qa-patterns
- when: manual
-
-.review:rules:review-cleanup:
- rules:
- - <<: *if-canonical-gitlab-merge-request
- changes: *code-qa-patterns
- when: manual
- - <<: *if-canonical-dot-com-gitlab-org-group-schedule
- when: on_success
-
-.review:rules:danger:
- rules:
- - if: '$DANGER_GITLAB_API_TOKEN && $CI_MERGE_REQUEST_IID'
- when: on_success
-
.review-docker:
extends:
- .default-tags
diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml
new file mode 100644
index 00000000000..a4285f47b6c
--- /dev/null
+++ b/.gitlab/ci/rules.gitlab-ci.yml
@@ -0,0 +1,500 @@
+##############
+# Conditions #
+##############
+.if-not-canonical-namespace: &if-not-canonical-namespace
+ if: '$CI_PROJECT_NAMESPACE !~ /^gitlab(-org)?($|\/)/'
+
+.if-not-ee: &if-not-ee
+ if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'
+
+.if-not-foss: &if-not-foss
+ if: '$CI_PROJECT_NAME != "gitlab-foss" && $CI_PROJECT_NAME != "gitlab-ce" && $CI_PROJECT_NAME != "gitlabhq"'
+
+.if-default-refs: &if-default-refs
+ if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
+
+.if-master-refs: &if-master-refs
+ if: '$CI_COMMIT_REF_NAME == "master"'
+
+.if-master-or-tag: &if-master-or-tag
+ if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_TAG'
+
+.if-merge-request: &if-merge-request
+ if: '$CI_MERGE_REQUEST_IID'
+
+.if-dot-com-gitlab-org-schedule: &if-dot-com-gitlab-org-schedule
+ if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"'
+
+.if-dot-com-gitlab-org-master: &if-dot-com-gitlab-org-master
+ if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_COMMIT_REF_NAME == "master"'
+
+.if-dot-com-gitlab-org-merge-request: &if-dot-com-gitlab-org-merge-request
+ if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_MERGE_REQUEST_IID'
+
+.if-dot-com-gitlab-org-and-security-merge-request: &if-dot-com-gitlab-org-and-security-merge-request
+ if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/security$)/ && $CI_MERGE_REQUEST_IID'
+
+.if-dot-com-gitlab-org-and-security-tag: &if-dot-com-gitlab-org-and-security-tag
+ if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/security$)/ && $CI_COMMIT_TAG'
+
+.if-dot-com-ee-schedule: &if-dot-com-ee-schedule
+ if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab" && $CI_PIPELINE_SOURCE == "schedule"'
+
+.if-cache-credentials-schedule: &if-cache-credentials-schedule
+ if: '$CI_REPO_CACHE_CREDENTIALS && $CI_PIPELINE_SOURCE == "schedule"'
+
+####################
+# Changes patterns #
+####################
+.yaml-patterns: &yaml-patterns
+ - "**/*.yml"
+
+.docs-patterns: &docs-patterns
+ - ".gitlab/route-map.yml"
+ - "doc/**/*"
+ - ".markdownlint.json"
+
+.backstage-patterns: &backstage-patterns
+ - "Dangerfile"
+ - "danger/**/*"
+ - "{,ee/}fixtures/**/*"
+ - "{,ee/}rubocop/**/*"
+ - "{,ee/}spec/**/*"
+ - "doc/README.md" # Some RSpec test rely on this file
+
+.code-patterns: &code-patterns
+ - ".gitlab/ci/**/*"
+ - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
+ - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
+ - ".csscomb.json"
+ - "Dockerfile.assets"
+ - "*_VERSION"
+ - "Gemfile{,.lock}"
+ - "Rakefile"
+ - "{babel.config,jest.config}.js"
+ - "config.ru"
+ - "{package.json,yarn.lock}"
+ - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
+ - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
+
+.qa-patterns: &qa-patterns
+ - ".dockerignore"
+ - "qa/**/*"
+
+.code-backstage-patterns: &code-backstage-patterns
+ - ".gitlab/ci/**/*"
+ - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
+ - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
+ - ".csscomb.json"
+ - "Dockerfile.assets"
+ - "*_VERSION"
+ - "Gemfile{,.lock}"
+ - "Rakefile"
+ - "{babel.config,jest.config}.js"
+ - "config.ru"
+ - "{package.json,yarn.lock}"
+ - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
+ - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
+ # Backstage changes
+ - "Dangerfile"
+ - "danger/**/*"
+ - "{,ee/}fixtures/**/*"
+ - "{,ee/}rubocop/**/*"
+ - "{,ee/}spec/**/*"
+ - "doc/README.md" # Some RSpec test rely on this file
+
+.code-qa-patterns: &code-qa-patterns
+ - ".gitlab/ci/**/*"
+ - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
+ - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
+ - ".csscomb.json"
+ - "Dockerfile.assets"
+ - "*_VERSION"
+ - "Gemfile{,.lock}"
+ - "Rakefile"
+ - "{babel.config,jest.config}.js"
+ - "config.ru"
+ - "{package.json,yarn.lock}"
+ - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
+ - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
+ # QA changes
+ - ".dockerignore"
+ - "qa/**/*"
+
+.code-backstage-qa-patterns: &code-backstage-qa-patterns
+ - ".gitlab/ci/**/*"
+ - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
+ - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
+ - ".csscomb.json"
+ - "Dockerfile.assets"
+ - "*_VERSION"
+ - "Gemfile{,.lock}"
+ - "Rakefile"
+ - "{babel.config,jest.config}.js"
+ - "config.ru"
+ - "{package.json,yarn.lock}"
+ - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
+ - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
+ # Backstage changes
+ - "Dangerfile"
+ - "danger/**/*"
+ - "{,ee/}fixtures/**/*"
+ - "{,ee/}rubocop/**/*"
+ - "{,ee/}spec/**/*"
+ - "doc/README.md" # Some RSpec test rely on this file
+ # QA changes
+ - ".dockerignore"
+ - "qa/**/*"
+
+####################
+# Cache repo rules #
+####################
+.cache-repo:rules:
+ rules:
+ - <<: *if-cache-credentials-schedule
+ when: on_success
+
+#############
+# CNG rules #
+#############
+.cng:rules:
+ rules:
+ - <<: *if-dot-com-gitlab-org-and-security-tag
+ when: manual
+
+######################
+# Dev fixtures rules #
+######################
+.dev-fixtures:rules:ee-and-foss:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.dev-fixtures:rules:ee-only:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+##############
+# Docs rules #
+##############
+.docs:rules:review-docs:
+ rules:
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *docs-patterns
+ when: manual
+
+.docs:rules:docs-lint:
+ rules:
+ - <<: *if-default-refs
+ changes: *docs-patterns
+ when: on_success
+
+.docs:rules:graphql-reference-verify:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-default-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+##################
+# Frontend rules #
+##################
+.frontend:rules:gitlab-assets-compile-pull-push-cache:
+ rules:
+ - <<: *if-not-canonical-namespace
+ when: never
+ - <<: *if-master-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.frontend:rules:gitlab-assets-compile-pull-cache:
+ rules:
+ - <<: *if-not-canonical-namespace
+ when: never
+ - <<: *if-default-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.frontend:rules:compile-assets-pull-push-cache:
+ rules:
+ - <<: *if-master-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.frontend:rules:compile-assets-pull-push-cache-as-if-foss:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-master-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.frontend:rules:compile-assets-pull-cache:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.frontend:rules:compile-assets-pull-cache-as-if-foss:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-default-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.frontend:rules:default-frontend-jobs:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.frontend:rules:default-frontend-jobs-as-if-foss:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.frontend:rules:qa-frontend-node:
+ rules:
+ - <<: *if-master-refs
+ when: on_success
+
+################
+# Memory rules #
+################
+.memory:rules:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-patterns
+ when: on_success
+
+###############
+# Pages rules #
+###############
+.pages:rules:
+ rules:
+ - <<: *if-dot-com-gitlab-org-master
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+############
+# QA rules #
+############
+.qa:rules:ee-and-foss:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-qa-patterns
+ when: on_success
+
+.qa:rules:ee-only:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-default-refs
+ changes: *code-qa-patterns
+ when: on_success
+
+.qa:rules:package-and-qa:
+ rules:
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *qa-patterns
+ when: on_success
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *code-patterns
+ when: manual
+ - <<: *if-dot-com-gitlab-org-schedule
+ when: on_success
+
+###############
+# Rails rules #
+###############
+.rails:rules:ee-and-foss:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.rails:rules:default-refs-code-backstage-qa:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.rails:rules:master-refs-code-backstage:
+ rules:
+ - <<: *if-master-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.rails:rules:master-refs-code-backstage-ee-only:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-master-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.rails:rules:ee-only:
+ rules:
+ - <<: *if-not-ee
+ when: never
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.rails:rules:downtime_check:
+ rules:
+ - <<: *if-merge-request
+ changes: *code-backstage-patterns
+ when: on_success
+
+##################
+# Releases rules #
+##################
+.releases:rules:canonical-dot-com-gitlab-stable-branch-only:
+ rules:
+ - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAME == "gitlab-org/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
+
+.releases:rules:canonical-dot-com-security-gitlab-stable-branch-only:
+ rules:
+ - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAME == "gitlab-org/security/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
+
+#################
+# Reports rules #
+#################
+.reports:rules:code_quality:
+ rules:
+ - if: '$CODE_QUALITY_DISABLED'
+ when: never
+ # - <<: *if-master-refs # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+
+.reports:rules:sast:
+ rules:
+ - if: '$SAST_DISABLED || $GITLAB_FEATURES !~ /\bsast\b/'
+ when: never
+ # - <<: *if-master-refs # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
+ - <<: *if-default-refs
+ changes: *code-backstage-qa-patterns
+
+.reports:rules:dependency_scanning:
+ rules:
+ - if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/'
+ when: never
+ # - <<: *if-master-refs # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
+ - <<: *if-default-refs
+ changes: *code-backstage-qa-patterns
+
+.reports:rules:dast:
+ rules:
+ - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
+ when: never
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *code-qa-patterns
+
+.reports:schedule-dast:
+ rules:
+ - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
+ when: never
+ - <<: *if-dot-com-gitlab-org-schedule
+
+################
+# Review rules #
+################
+.review:rules:mr-and-schedule:
+ rules:
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *code-qa-patterns
+ when: on_success
+ - <<: *if-dot-com-gitlab-org-schedule
+ when: on_success
+
+.review:rules:mr-only-auto:
+ rules:
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *code-qa-patterns
+ when: on_success
+
+.review:rules:mr-only-manual:
+ rules:
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *code-qa-patterns
+ when: manual
+
+.review:rules:review-cleanup:
+ rules:
+ - <<: *if-dot-com-gitlab-org-merge-request
+ changes: *code-qa-patterns
+ when: manual
+ - <<: *if-dot-com-gitlab-org-schedule
+ when: on_success
+
+.review:rules:danger:
+ rules:
+ - if: '$DANGER_GITLAB_API_TOKEN && $CI_MERGE_REQUEST_IID'
+ when: on_success
+
+###############
+# Setup rules #
+###############
+.setup:rules:cache-gems:
+ rules:
+ - <<: *if-not-canonical-namespace
+ when: never
+ - <<: *if-master-or-tag
+ changes: *code-backstage-qa-patterns
+ when: on_success
+
+.setup:rules:gitlab_git_test:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.setup:rules:no_ee_check:
+ rules:
+ - <<: *if-not-foss
+ when: never
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+#######################
+# Test metadata rules #
+#######################
+.test-metadata:rules:retrieve-tests-metadata:
+ rules:
+ - <<: *if-default-refs
+ changes: *code-backstage-patterns
+ when: on_success
+
+.test-metadata:rules:update-tests-metadata:
+ rules:
+ - <<: *if-dot-com-ee-schedule
+ changes: *code-backstage-patterns
+ when: on_success
+
+.test-metadata:rules:flaky-examples-check:
+ rules:
+ - <<: *if-merge-request
+ changes: *code-backstage-patterns
+ when: on_success
+
+
+##############
+# YAML rules #
+##############
+.yaml:rules:
+ rules:
+ - <<: *if-default-refs
+ changes: *yaml-patterns
diff --git a/.gitlab/ci/setup.gitlab-ci.yml b/.gitlab/ci/setup.gitlab-ci.yml
index 73ec0a559fc..fb203db1478 100644
--- a/.gitlab/ci/setup.gitlab-ci.yml
+++ b/.gitlab/ci/setup.gitlab-ci.yml
@@ -1,90 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-canonical-namespace: &if-not-canonical-namespace
- if: '$CI_PROJECT_NAMESPACE !~ /^gitlab(-org)?($|\/)/'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-not-foss: &if-not-foss
- if: '$CI_PROJECT_NAME != "gitlab-foss" && $CI_PROJECT_NAME != "gitlab-ce" && $CI_PROJECT_NAME != "gitlabhq"'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-master-or-tag: &if-master-or-tag
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-patterns: &code-backstage-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-qa-patterns: &code-backstage-qa-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
- # QA changes
- - ".dockerignore"
- - "qa/**/*"
-
-.setup:rules:cache-gems:
- rules:
- - <<: *if-not-canonical-namespace
- when: never
- - <<: *if-master-or-tag
- changes: *code-backstage-qa-patterns
- when: on_success
-
-.setup:rules:gitlab_git_test:
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
-
-.setup:rules:no_ee_check:
- rules:
- - <<: *if-not-foss
- when: never
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
-
# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
diff --git a/.gitlab/ci/test-metadata.gitlab-ci.yml b/.gitlab/ci/test-metadata.gitlab-ci.yml
index 2457498f84d..719e4e821c9 100644
--- a/.gitlab/ci/test-metadata.gitlab-ci.yml
+++ b/.gitlab/ci/test-metadata.gitlab-ci.yml
@@ -1,56 +1,3 @@
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-default-refs: &if-default-refs
- if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-merge-request: &if-merge-request
- if: '$CI_MERGE_REQUEST_IID'
-
-# Make sure to update all the similar conditions in other CI config files if you modify these conditions
-.if-canonical-dot-com-gitlab-schedule: &if-canonical-dot-com-gitlab-schedule
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab" && $CI_PIPELINE_SOURCE == "schedule"'
-
-# Make sure to update all the similar patterns in other CI config files if you modify these patterns
-.code-backstage-patterns: &code-backstage-patterns
- - ".gitlab/ci/**/*"
- - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- - ".csscomb.json"
- - "Dockerfile.assets"
- - "*_VERSION"
- - "Gemfile{,.lock}"
- - "Rakefile"
- - "{babel.config,jest.config}.js"
- - "config.ru"
- - "{package.json,yarn.lock}"
- - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- - "doc/api/graphql/reference/*" # Files in this folder are auto-generated
- # Backstage changes
- - "Dangerfile"
- - "danger/**/*"
- - "{,ee/}fixtures/**/*"
- - "{,ee/}rubocop/**/*"
- - "{,ee/}spec/**/*"
- - "doc/README.md" # Some RSpec test rely on this file
-
-.test-metadata:rules:retrieve-tests-metadata:
- rules:
- - <<: *if-default-refs
- changes: *code-backstage-patterns
- when: on_success
-
-.test-metadata:rules:update-tests-metadata:
- rules:
- - <<: *if-canonical-dot-com-gitlab-schedule
- changes: *code-backstage-patterns
- when: on_success
-
-.test-metadata:rules:flaky-examples-check:
- rules:
- - <<: *if-merge-request
- changes: *code-backstage-patterns
- when: on_success
-
.tests-metadata-state:
variables:
TESTS_METADATA_S3_BUCKET: "gitlab-ce-cache"
diff --git a/.gitlab/ci/yaml.gitlab-ci.yml b/.gitlab/ci/yaml.gitlab-ci.yml
index 4fcf940974b..cdc3aa6e577 100644
--- a/.gitlab/ci/yaml.gitlab-ci.yml
+++ b/.gitlab/ci/yaml.gitlab-ci.yml
@@ -4,10 +4,7 @@ lint-ci-gitlab:
extends:
- .default-tags
- .default-retry
- - .default-only
- only:
- changes:
- - "**/*.yml"
+ - .yaml:rules
image: sdesbure/yamllint:latest
dependencies: []
variables:
diff --git a/app/controllers/users/terms_controller.rb b/app/controllers/users/terms_controller.rb
index 3c16d934b4d..231e449f733 100644
--- a/app/controllers/users/terms_controller.rb
+++ b/app/controllers/users/terms_controller.rb
@@ -4,7 +4,7 @@ module Users
class TermsController < ApplicationController
include InternalRedirect
- skip_before_action :authenticate_user!
+ skip_before_action :authenticate_user!, only: [:index]
skip_before_action :enforce_terms!
skip_before_action :check_password_expiration
skip_before_action :check_two_factor_requirement
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb
index 9875e0b9b88..028cd1ecce0 100644
--- a/app/models/project_services/jira_service.rb
+++ b/app/models/project_services/jira_service.rb
@@ -229,7 +229,15 @@ class JiraService < IssueTrackerService
jira_issue_transition_id.scan(Gitlab::Regex.jira_transition_id_regex).each do |transition_id|
issue.transitions.build.save!(transition: { id: transition_id })
rescue => error
- log_error("Issue transition failed", error: error.message, client_url: client_url)
+ log_error(
+ "Issue transition failed",
+ error: {
+ exception_class: error.class.name,
+ exception_message: error.message,
+ exception_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(error.backtrace)
+ },
+ client_url: client_url
+ )
return false
end
end
@@ -354,7 +362,7 @@ class JiraService < IssueTrackerService
error: {
exception_class: error.class.name,
exception_message: error.message,
- exception_backtrace: error.backtrace.join("\n")
+ exception_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(error.backtrace)
}
)
nil
diff --git a/app/views/groups/registry/repositories/index.html.haml b/app/views/groups/registry/repositories/index.html.haml
index b82910df5d5..d3c3e5c1436 100644
--- a/app/views/groups/registry/repositories/index.html.haml
+++ b/app/views/groups/registry/repositories/index.html.haml
@@ -1,4 +1,5 @@
- page_title _("Container Registry")
+- @content_class = "limit-container-width" unless fluid_layout
%section
.row.registry-placeholder.prepend-bottom-10
diff --git a/app/views/projects/registry/repositories/index.html.haml b/app/views/projects/registry/repositories/index.html.haml
index 6ff7c27b1bc..3f90334d452 100644
--- a/app/views/projects/registry/repositories/index.html.haml
+++ b/app/views/projects/registry/repositories/index.html.haml
@@ -1,4 +1,5 @@
- page_title _("Container Registry")
+- @content_class = "limit-container-width" unless fluid_layout
%section
.row.registry-placeholder.prepend-bottom-10
diff --git a/changelogs/unreleased/198325-migrate-design-mentions-to-db-table.yml b/changelogs/unreleased/198325-migrate-design-mentions-to-db-table.yml
new file mode 100644
index 00000000000..3a26827378c
--- /dev/null
+++ b/changelogs/unreleased/198325-migrate-design-mentions-to-db-table.yml
@@ -0,0 +1,5 @@
+---
+title: Migrate mentions for design notes to design_user_mentions DB table
+merge_request: 23704
+author:
+type: changed
diff --git a/changelogs/unreleased/204723-nomethoderror-undefined-method-term_agreements-for-nil-nilclass.yml b/changelogs/unreleased/204723-nomethoderror-undefined-method-term_agreements-for-nil-nilclass.yml
new file mode 100644
index 00000000000..db99c44945d
--- /dev/null
+++ b/changelogs/unreleased/204723-nomethoderror-undefined-method-term_agreements-for-nil-nilclass.yml
@@ -0,0 +1,5 @@
+---
+title: Require a logged in user to accept or decline a term
+merge_request: 24771
+author:
+type: fixed
diff --git a/changelogs/unreleased/a11y-ci-template.yml b/changelogs/unreleased/a11y-ci-template.yml
new file mode 100644
index 00000000000..b8312508144
--- /dev/null
+++ b/changelogs/unreleased/a11y-ci-template.yml
@@ -0,0 +1,5 @@
+---
+title: Add accessibility scanning CI template
+merge_request: 25144
+author:
+type: added
diff --git a/changelogs/unreleased/add-missing-secure-queues-changelog.yml b/changelogs/unreleased/add-missing-secure-queues-changelog.yml
new file mode 100644
index 00000000000..dc9b492b543
--- /dev/null
+++ b/changelogs/unreleased/add-missing-secure-queues-changelog.yml
@@ -0,0 +1,5 @@
+---
+title: Move namespace of Secure Sidekiq queues
+merge_request: 24340
+author:
+type: other
diff --git a/changelogs/unreleased/ak-drop-etag.yml b/changelogs/unreleased/ak-drop-etag.yml
new file mode 100644
index 00000000000..0e5c1838ff4
--- /dev/null
+++ b/changelogs/unreleased/ak-drop-etag.yml
@@ -0,0 +1,5 @@
+---
+title: Drop etag cache on logs API
+merge_request: 24864
+author:
+type: fixed
diff --git a/db/post_migrate/20200124110831_migrate_design_notes_mentions_to_db.rb b/db/post_migrate/20200124110831_migrate_design_notes_mentions_to_db.rb
new file mode 100644
index 00000000000..f1e4ee9807b
--- /dev/null
+++ b/db/post_migrate/20200124110831_migrate_design_notes_mentions_to_db.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+
+class MigrateDesignNotesMentionsToDb < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ DELAY = 2.minutes.to_i
+ BATCH_SIZE = 10000
+ MIGRATION = 'UserMentions::CreateResourceUserMention'
+
+ INDEX_NAME = 'design_mentions_temp_index'
+ INDEX_CONDITION = "note LIKE '%@%'::text AND notes.noteable_type = 'DesignManagement::Design'"
+ QUERY_CONDITIONS = "#{INDEX_CONDITION} AND design_user_mentions.design_id IS NULL"
+ JOIN = 'INNER JOIN design_management_designs ON design_management_designs.id = notes.noteable_id LEFT JOIN design_user_mentions ON notes.id = design_user_mentions.note_id'
+
+ class DesignUserMention < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'design_user_mentions'
+ end
+
+ class Note < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'notes'
+ end
+
+ def up
+ return unless Gitlab.ee?
+
+ # cleanup design user mentions with no actual mentions,
+ # re https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24586#note_285982468
+ DesignUserMention
+ .where(mentioned_users_ids: nil)
+ .where(mentioned_groups_ids: nil)
+ .where(mentioned_projects_ids: nil)
+ .each_batch(of: BATCH_SIZE) do |batch|
+ batch.delete_all
+ end
+
+ # create temporary index for notes with mentions, may take well over 1h
+ add_concurrent_index(:notes, :id, where: INDEX_CONDITION, name: INDEX_NAME)
+
+ Note
+ .joins(JOIN)
+ .where(QUERY_CONDITIONS)
+ .each_batch(of: BATCH_SIZE) do |batch, index|
+ range = batch.pluck(Arel.sql('MIN(notes.id)'), Arel.sql('MAX(notes.id)')).first
+ BackgroundMigrationWorker.perform_in(index * DELAY, MIGRATION, ['DesignManagement::Design', JOIN, QUERY_CONDITIONS, true, *range])
+ end
+ end
+
+ def down
+ # no-op
+ # temporary index is to be dropped in a different migration in an upcoming release:
+ # https://gitlab.com/gitlab-org/gitlab/issues/196842
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 435d994e201..fec0ba6e753 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2808,6 +2808,7 @@ ActiveRecord::Schema.define(version: 2020_02_13_220211) do
t.index ["commit_id"], name: "index_notes_on_commit_id"
t.index ["created_at"], name: "index_notes_on_created_at"
t.index ["discussion_id"], name: "index_notes_on_discussion_id"
+ t.index ["id"], name: "design_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'DesignManagement::Design'::text))"
t.index ["id"], name: "epic_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'Epic'::text))"
t.index ["line_code"], name: "index_notes_on_line_code"
t.index ["note"], name: "index_notes_on_note_trigram", opclass: :gin_trgm_ops, using: :gin
diff --git a/doc/development/background_migrations.md b/doc/development/background_migrations.md
index 02d31976481..dfe2312c2fa 100644
--- a/doc/development/background_migrations.md
+++ b/doc/development/background_migrations.md
@@ -329,6 +329,6 @@ for more details.
or ask someone to measure on production).
[migrations-readme]: https://gitlab.com/gitlab-org/gitlab/blob/master/spec/migrations/README.md
-[issue-rspec-hooks]: https://gitlab.com/gitlab-org/gitlab-foss/issues/35351
+[issue-rspec-hooks]: https://gitlab.com/gitlab-org/gitlab/issues/18839
[reliable-sidekiq]: https://gitlab.com/gitlab-org/gitlab-foss/issues/36791
[import-export]: ../user/project/settings/import_export.md
diff --git a/doc/development/pipelines.md b/doc/development/pipelines.md
index 29208c1bf76..e228845bc72 100644
--- a/doc/development/pipelines.md
+++ b/doc/development/pipelines.md
@@ -64,180 +64,62 @@ Most of the jobs [extend from a few CI definitions](../ci/yaml/README.md#extends
that are scoped to a single
[configuration parameter](../ci/yaml/README.md#configuration-parameters).
-These common definitions are:
-
-- `.default-tags`: Ensures a job has the `gitlab-org` tag to ensure it's using
- our dedicated runners.
-- `.default-retry`: Allows a job to [retry](../ci/yaml/README.md#retry) upon `unknown_failure`, `api_failure`,
- `runner_system_failure`, `job_execution_timeout`, or `stuck_or_timeout_failure`.
-- `.default-before_script`: Allows a job to use a default `before_script` definition
- suitable for Ruby/Rails tasks that may need a database running (e.g. tests).
-- `.default-cache`: Allows a job to use a default `cache` definition suitable for
- Ruby/Rails and frontend tasks.
-- `.default-only`: Restricts the cases where a job is created. This currently
- includes `master`, `/^[\d-]+-stable(-ee)?$/` (stable branches),
- `/^\d+-\d+-auto-deploy-\d+$/` (auto-deploy branches), `/^security\//` (security branches), `merge_requests`, `tags`.
- Note that jobs won't be created for branches with this default configuration.
-- `.only:variables-canonical-dot-com`: Only creates a job if the project is
- located under <https://gitlab.com/gitlab-org>.
-- `.only:variables_refs-canonical-dot-com-schedules`: Same as
- `.only:variables-canonical-dot-com` but add the condition that pipeline is scheduled.
-- `.except:refs-deploy`: Don't create a job if the `ref` is an auto-deploy branch.
-- `.except:refs-master-tags-stable-deploy`: Don't create a job if the `ref` is one of:
- - `master`
- - a tag
- - a stable branch
- - an auto-deploy branch
-- `.only:kubernetes`: Only creates a job if a Kubernetes integration is enabled
- on the project.
-- `.only-review`: This extends from:
- - `.only:variables-canonical-dot-com`
- - `.only:kubernetes`
- - `.except:refs-master-tags-stable-deploy`
-- `.only-review-schedules`: This extends from:
- - `.only:variables_refs-canonical-dot-com-schedules`
- - `.only:kubernetes`
- - `.except:refs-deploy`
-- `.use-pg9`: Allows a job to use the `postgres:9.6` and `redis:alpine` services.
-- `.use-pg10`: Allows a job to use the `postgres:10.9` and `redis:alpine` services.
-- `.use-pg9-ee`: Same as `.use-pg9` but also use the
- `docker.elastic.co/elasticsearch/elasticsearch:5.6.12` services.
-- `.use-pg10-ee`: Same as `.use-pg10` but also use the
- `docker.elastic.co/elasticsearch/elasticsearch:5.6.12` services.
-- `.only-ee`: Only creates a job for the `gitlab` or `gitlab-ee` project.
-- `.only-ee-as-if-foss`: Same as `.only-ee` but simulate the FOSS project by
- setting the `FOSS_ONLY='1'` environment variable.
-
-## Changes detection
-
-If a job extends from `.default-only` (and most of the jobs should), it can restrict
-the cases where it should be created
-[based on the changes](../ci/yaml/README.md#onlychangesexceptchanges)
-from a commit or MR by extending from the following CI definitions:
-
-- `.only:changes-code`: Allows a job to only be created upon code-related changes.
-- `.only:changes-qa`: Allows a job to only be created upon QA-related changes.
-- `.only:changes-docs`: Allows a job to only be created upon docs-related changes.
-- `.only:changes-graphql`: Allows a job to only be created upon GraphQL-related changes.
-- `.only:changes-code-backstage`: Allows a job to only be created upon code-related or backstage-related (e.g. Danger, RuboCop, specs) changes.
-- `.only:changes-code-qa`: Allows a job to only be created upon code-related or QA-related changes.
-- `.only:changes-code-backstage-qa`: Allows a job to only be created upon code-related, backstage-related (e.g. Danger, RuboCop, specs) or QA-related changes.
-
-**See <https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/ci/global.gitlab-ci.yml>
-for the list of exact patterns.**
-
-## Rules conditions and changes patterns
-
-We're making use of the [`rules` keyword](https://docs.gitlab.com/ee/ci/yaml/#rules) but we're currently
-duplicating the `if` conditions and `changes` patterns lists since they cannot be shared across
-`include`d files as we do with `extends`.
-
-**If you update an `if` condition or `changes`
-patterns list, make sure to mass-update those across all the CI config files (i.e. `.gitlab/ci/*.yml`).**
-
-### Canonical/security namespace merge requests only
-
-This condition limits jobs creation to merge requests under the `gitlab-org/` top-level group
-on GitLab.com only (i.e. this won't run for `master`, stable or auto-deploy branches).
-This is similar to the `.only:variables-canonical-dot-com` + `only:refs: [merge_requests]`
-CI definitions.
-
-The definition for `if-canonical-dot-com-gitlab-org-groups-merge-request` can be
-seen in <https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/docs.gitlab-ci.yml>.
-
-### Canonical/security namespace tags only
-
-This condition limits jobs creation to tags under the `gitlab-org/` top-level group
-on GitLab.com only.
-This is similar to the `.only:variables-canonical-dot-com` + `only:refs: [tags]` CI definition:
-
-The definition for `if-canonical-dot-com-gitlab-org-groups-tag` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/cng.gitlab-ci.yml>.
-
-### Canonical namespace `master` only
-
-This condition limits jobs creation to `master` pipelines for the `gitlab-org` top-level group
-on GitLab.com only.
-This is similar to the `.only:variables-canonical-dot-com` + `only:refs: [master]` CI definition:
-
-The definition for `if-canonical-dot-com-gitlab-org-group-master-refs` can be
-seen in <https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/pages.gitlab-ci.yml>.
-
-### Canonical namespace schedules only
-
-This condition limits jobs creation to scheduled pipelines for the `gitlab-org` top-level group
-on GitLab.com only.
-This is similar to the `.only:variables-canonical-dot-com` + `only:refs: [schedules]` CI definition:
-
-The definition for `if-canonical-dot-com-gitlab-org-group-schedule` can be seen
-in <https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/qa.gitlab-ci.yml>.
-
-### Not canonical/security namespace
-
-This condition matches if the project isn't in the canonical/security namespace.
-Useful to **not** create a job if the project is a fork, or in other words, when
-a job should only run in the canonical projects.
-
-The definition for `if-not-canonical-namespace` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/frontend.gitlab-ci.yml>.
-
-### Not EE
-
-This condition matches if the project isn't EE. Useful to **not** create a job if
-the project is GitLab, or in other words, when a job should only run in the GitLab
-FOSS project.
-
-The definition for `if-not-ee` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/frontend.gitlab-ci.yml>.
-
-### Default refs only
-
-This condition is the equivalent of `.default-only`.
-
-The definition for `if-default-refs` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/frontend.gitlab-ci.yml>.
-
-### `master` refs only
-
-This condition is the equivalent of `only:refs: [master]`.
-
-The definition for `if-master-refs` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/frontend.gitlab-ci.yml>.
-
-### Code changes patterns
-
-Similar patterns as for `.only:changes-code`:
-
-The definition for `code-patterns` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/qa.gitlab-ci.yml>.
-
-### QA changes patterns
-
-Similar patterns as for `.only:changes-qa`:
-
-The definition for `qa-patterns` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/qa.gitlab-ci.yml>.
-
-### Docs changes patterns
-
-Similar patterns as for `.only:changes-docs`:
-
-The definition for `docs-patterns` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/docs.gitlab-ci.yml>.
-
-### Code and QA changes patterns
-
-Similar patterns as for `.only:changes-code-qa`:
-
-The definition for `code-qa-patterns` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/review.gitlab-ci.yml>.
-
-### Code, backstage and QA changes patterns
-
-Similar patterns as for `.only:changes-code-backstage-qa`:
-
-The definition for `code-backstage-qa-patterns` can be seen in
-<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/frontend.gitlab-ci.yml>.
+| Job definitions | Description |
+|------------------|-------------|
+| `.default-tags` | Ensures a job has the `gitlab-org` tag to ensure it's using our dedicated runners. |
+| `.default-retry` | Allows a job to [retry](../ci/yaml/README.md#retry) upon `unknown_failure`, `api_failure`, `runner_system_failure`, `job_execution_timeout`, or `stuck_or_timeout_failure`. |
+| `.default-before_script` | Allows a job to use a default `before_script` definition suitable for Ruby/Rails tasks that may need a database running (e.g. tests). |
+| `.default-cache` | Allows a job to use a default `cache` definition suitable for Ruby/Rails and frontend tasks. |
+| `.use-pg9` | Allows a job to use the `postgres:9.6.17` and `redis:alpine` services. |
+| `.use-pg10` | Allows a job to use the `postgres:10.12` and `redis:alpine` services. |
+| `.use-pg9-ee` | Same as `.use-pg9` but also use the `docker.elastic.co/elasticsearch/elasticsearch:6.4.2` services. |
+| `.use-pg10-ee` | Same as `.use-pg10` but also use the `docker.elastic.co/elasticsearch/elasticsearch:6.4.2` services. |
+| `.as-if-foss` | Simulate the FOSS project by setting the `FOSS_ONLY='1'` environment variable. |
+
+## `rules`, `if:` conditions and `changes:` patterns
+
+We're using the [`rules` keyword](../ci/yaml/README.md#rules) extensively.
+
+All `rules` definitions are defined in
+<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/rules.gitlab-ci.yml>,
+then included in individual jobs via [`extends`](../ci/yaml/README.md#extends).
+
+The `rules` definitions are composed of `if:` conditions and `changes:` patterns,
+which are also defined in
+<https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/rules.gitlab-ci.yml>
+and included in `rules` definitions via [YAML anchors](../ci/yaml/README.md#anchors)
+
+### `if:` conditions
+
+| `if:` conditions | Description | Notes |
+|------------------|-------------|-------|
+| `if-not-canonical-namespace` | Matches if the project isn't in the canonical (`gitlab-org/`) or security (`gitlab-org/security`) namespace. | Use to create a job for forks (by using `when: on_success\|manual`), or **not** create a job for forks (by using `when: never`). |
+| `if-not-ee` | Matches if the project isn't EE (i.e. project name isn't `gitlab` or `gitlab-ee`). | Use to create a job only in the FOSS project (by using `when: on_success|manual`), or **not** create a job if the project is EE (by using `when: never`). |
+| `if-not-foss` | Matches if the project isn't FOSS (i.e. project name isn't `gitlab-foss`, `gitlab-ce`, or `gitlabhq`). | Use to create a job only in the EE project (by using `when: on_success|manual`), or **not** create a job if the project is FOSS (by using `when: never`). |
+| `if-default-refs` | Matches if the pipeline is for `master`, `/^[\d-]+-stable(-ee)?$/` (stable branches), `/^\d+-\d+-auto-deploy-\d+$/` (auto-deploy branches), `/^security\//` (security branches), merge requests, and tags. | Note that jobs won't be created for branches with this default configuration. |
+| `if-master-refs` | Matches if the current branch is `master`. | |
+| `if-master-or-tag` | Matches if the pipeline is for the `master` branch or for a tag. | |
+| `if-merge-request` | Matches if the pipeline is for a merge request. | |
+| `if-dot-com-gitlab-org-schedule` | Limits jobs creation to scheduled pipelines for the `gitlab-org` group on GitLab.com. | |
+| `if-dot-com-gitlab-org-master` | Limits jobs creation to the `master` branch for the `gitlab-org` group on GitLab.com. | |
+| `if-dot-com-gitlab-org-merge-request` | Limits jobs creation to merge requests for the `gitlab-org` group on GitLab.com. | |
+| `if-dot-com-gitlab-org-and-security-tag` | Limits job creation to tags for the `gitlab-org` and `gitlab-org/security` groups on GitLab.com. | |
+| `if-dot-com-gitlab-org-and-security-merge-request` | Limit jobs creation to merge requests for the `gitlab-org` and `gitlab-org/security` groups on GitLab.com. | |
+| `if-dot-com-ee-schedule` | Limits jobs to scheduled pipelines for the `gitlab-org/gitlab` project on GitLab.com. | |
+| `if-cache-credentials-schedule` | Limits jobs to scheduled pipelines with the `$CI_REPO_CACHE_CREDENTIALS` variable set. | |
+
+### `changes:` patterns
+
+| `changes:` patterns | Description |
+|------------------------------|--------------------------------------------------------------------------|
+| `yaml-patterns` | Only create job for YAML-related changes. |
+| `docs-patterns` | Only create job for docs-related changes. |
+| `backstage-patterns` | Only create job for backstage-related changes. |
+| `code-patterns` | Only create job for code-related changes. |
+| `qa-patterns` | Only create job for QA-related changes. |
+| `code-backstage-patterns` | Combination of `code-patterns` and `backstage-patterns`. |
+| `code-qa-patterns` | Combination of `code-patterns` and `qa-patterns`. |
+| `code-backstage-qa-patterns` | Combination of `code-patterns`, `backstage-patterns`, and `qa-patterns`. |
## Directed acyclic graph
@@ -254,11 +136,11 @@ graph RL;
F[build-qa-image];
G[review-deploy];
I["karma, jest, webpack-dev-server, static-analysis"];
- I2["karma-foss, jest-foss<br/>(EE default refs only)"];
+ I2["karma-as-if-foss, jest-as-if-foss<br/>(EE default refs only)"];
J["compile-assets pull-push-cache<br/>(master only)"];
- J2["compile-assets pull-push-cache foss<br/>(EE master only)"];
+ J2["compile-assets pull-push-cache as-if-foss<br/>(EE master only)"];
K[compile-assets pull-cache];
- K2["compile-assets pull-cache foss<br/>(EE default refs only)"];
+ K2["compile-assets pull-cache as-if-foss<br/>(EE default refs only)"];
M[coverage];
N["pages (master only)"];
Q[package-and-qa];
diff --git a/doc/install/aws/index.md b/doc/install/aws/index.md
index 096d724717e..aa94dc1a2a5 100644
--- a/doc/install/aws/index.md
+++ b/doc/install/aws/index.md
@@ -639,7 +639,7 @@ And the more complex the solution, the more work is involved in setting up and
maintaining it.
Have a read through these other resources and feel free to
-[open an issue](https://gitlab.com/gitlab-org/gitlab-foss/issues/new)
+[open an issue](https://gitlab.com/gitlab-org/gitlab/issues/new)
to request additional material:
- [GitLab High Availability](../../administration/high_availability/README.md):
diff --git a/doc/system_hooks/system_hooks.md b/doc/system_hooks/system_hooks.md
index 30d080eab29..c2121697ed4 100644
--- a/doc/system_hooks/system_hooks.md
+++ b/doc/system_hooks/system_hooks.md
@@ -296,7 +296,7 @@ If the user is blocked via LDAP, `state` will be `ldap_blocked`.
}
```
-`owner_name` and `owner_email` are always `null`. Please see <https://gitlab.com/gitlab-org/gitlab-foss/issues/39675>.
+`owner_name` and `owner_email` are always `null`. Please see <https://gitlab.com/gitlab-org/gitlab/issues/20011>.
**Group removed:**
@@ -313,7 +313,7 @@ If the user is blocked via LDAP, `state` will be `ldap_blocked`.
}
```
-`owner_name` and `owner_email` are always `null`. Please see <https://gitlab.com/gitlab-org/gitlab-foss/issues/39675>.
+`owner_name` and `owner_email` are always `null`. Please see <https://gitlab.com/gitlab-org/gitlab/issues/20011>.
**Group renamed:**
@@ -333,7 +333,7 @@ If the user is blocked via LDAP, `state` will be `ldap_blocked`.
}
```
-`owner_name` and `owner_email` are always `null`. Please see <https://gitlab.com/gitlab-org/gitlab-foss/issues/39675>.
+`owner_name` and `owner_email` are always `null`. Please see <https://gitlab.com/gitlab-org/gitlab/issues/20011>.
**New Group Member:**
diff --git a/doc/user/project/integrations/prometheus.md b/doc/user/project/integrations/prometheus.md
index 210ce4ffe56..e703f15b4d3 100644
--- a/doc/user/project/integrations/prometheus.md
+++ b/doc/user/project/integrations/prometheus.md
@@ -198,18 +198,23 @@ supported and will not be available in the UI.
#### Duplicating a GitLab-defined dashboard
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/37238) in GitLab 12.7.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/37238) in GitLab 12.7.
+> - From [GitLab 12.8 onwards](https://gitlab.com/gitlab-org/gitlab/issues/39505), custom metrics are also duplicated when you duplicate a dashboard.
-You can save a copy of a GitLab defined dashboard that can be customized and adapted to your project. You can decide to save the dashboard new `.yml` file in the project's **default** branch or in a newly created branch with a name of your choosing.
+You can save a complete copy of a GitLab defined dashboard along with all custom metrics added to it.
+Resulting `.yml` file can be customized and adapted to your project.
+You can decide to save the dashboard `.yml` file in the project's **default** branch or in a
+new branch.
-1. Click on the "Duplicate dashboard" in the dashboard dropdown.
+1. Click **Duplicate dashboard** in the dashboard dropdown.
NOTE: **Note:**
- Only GitLab-defined dashboards can be duplicated.
+ You can duplicate only GitLab-defined dashboards.
-1. Input the file name and other information, such as a new commit message, and click on "Duplicate".
+1. Enter the file name and other information, such as the new commit's message, and click **Duplicate**.
-If you select your **default** branch, the new dashboard will become immediately available. If you select another branch, this branch should be merged to your **default** branch first.
+If you select your **default** branch, the new dashboard becomes immediately available.
+If you select another branch, this branch should be merged to your **default** branch first.
#### Dashboard YAML properties
diff --git a/doc/user/project/merge_requests/accessibility_testing.md b/doc/user/project/merge_requests/accessibility_testing.md
new file mode 100644
index 00000000000..7fa758b8a51
--- /dev/null
+++ b/doc/user/project/merge_requests/accessibility_testing.md
@@ -0,0 +1,53 @@
+---
+type: reference, howto
+---
+
+# Accessibility Testing
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25144) in GitLab 12.8.
+
+If your application offers a web interface and you are using
+[GitLab CI/CD](../../../ci/README.md), you can quickly determine the accessibility
+impact of pending code changes.
+
+## Overview
+
+GitLab uses [pa11y](https://pa11y.org/), a free and open source tool for
+measuring the accessibility of web sites, and has built a simple
+[CI job template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml).
+This job outputs accessibility violations, warnings, and notices for each page
+analyzed to a file called `accessibility`.
+
+## Configure Accessibility Testing
+
+This example shows how to run [pa11y](https://pa11y.org/)
+on your code with GitLab CI/CD using a node Docker image.
+
+For GitLab 12.8 and later, to define the `a11y` job, you must
+[include](../../../ci/yaml/README.md#includetemplate) the
+[`Accessibility.gitlab-ci.yml` template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml)
+included with your GitLab installation, as shown below.
+For GitLab versions earlier than 12.8, you can copy and use the job as
+defined in that template.
+
+Add the following to your `.gitlab-ci.yml` file:
+
+```yaml
+include:
+ template: Verify/Accessibility.gitlab-ci.yml
+
+a11y:
+ variables:
+ a11y_urls: https://example.com https://example.com/another-page
+```
+
+The example above will create an `a11y` job in your CI/CD pipeline and will run
+Pa11y against the webpage you defined in `a11y_urls` to build a report.
+
+The full HTML Pa11y report will be saved as an artifact that can be [viewed directly in your browser](../pipelines/job_artifacts.md#browsing-artifacts).
+
+NOTE: **Note:**
+The job definition provided by the template does not support Kubernetes yet.
+
+It is not yet possible to pass configurations into Pa11y via CI configuration. To change anything,
+copy the template to your CI file and make the desired edits.
diff --git a/doc/user/project/merge_requests/index.md b/doc/user/project/merge_requests/index.md
index 0617e6bc74d..2c613a29b0d 100644
--- a/doc/user/project/merge_requests/index.md
+++ b/doc/user/project/merge_requests/index.md
@@ -91,6 +91,7 @@ or link to useful information directly in the merge request page:
| Feature | Description |
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| [Accessibility Testing](accessibility_testing.md) | Automatically report A11y violations for changed pages in merge requests |
| [Browser Performance Testing](browser_performance_testing.md) **(PREMIUM)** | Quickly determine the performance impact of pending code changes. |
| [Code Quality](code_quality.md) **(STARTER)** | Analyze your source code quality using the [Code Climate](https://codeclimate.com/) analyzer and show the Code Climate report right in the merge request widget area. |
| [Display arbitrary job artifacts](../../../ci/yaml/README.md#artifactsexpose_as) | Configure CI pipelines with the `artifacts:expose_as` parameter to directly link to selected [artifacts](../pipelines/job_artifacts.md) in merge requests. |
diff --git a/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb b/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
index 40f45301727..22b984887b1 100644
--- a/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
+++ b/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
@@ -21,7 +21,8 @@ module Gitlab
records.in_groups_of(BULK_INSERT_SIZE, false).each do |records|
mentions = []
records.each do |record|
- mentions << record.build_mention_values(resource_user_mention_model.resource_foreign_key)
+ mention_record = record.build_mention_values(resource_user_mention_model.resource_foreign_key)
+ mentions << mention_record unless mention_record.blank?
end
Gitlab::Database.bulk_insert(
diff --git a/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb b/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb
index b7fa92a6686..1fac4b230ca 100644
--- a/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb
+++ b/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb
@@ -68,12 +68,18 @@ module Gitlab
def build_mention_values(resource_foreign_key)
refs = all_references(author)
+ mentioned_users_ids = array_to_sql(refs.mentioned_users.pluck(:id))
+ mentioned_projects_ids = array_to_sql(refs.mentioned_projects.pluck(:id))
+ mentioned_groups_ids = array_to_sql(refs.mentioned_groups.pluck(:id))
+
+ return if mentioned_users_ids.blank? && mentioned_projects_ids.blank? && mentioned_groups_ids.blank?
+
{
"#{resource_foreign_key}": user_mention_resource_id,
note_id: user_mention_note_id,
- mentioned_users_ids: array_to_sql(refs.mentioned_users.pluck(:id)),
- mentioned_projects_ids: array_to_sql(refs.mentioned_projects.pluck(:id)),
- mentioned_groups_ids: array_to_sql(refs.mentioned_groups.pluck(:id))
+ mentioned_users_ids: mentioned_users_ids,
+ mentioned_projects_ids: mentioned_projects_ids,
+ mentioned_groups_ids: mentioned_groups_ids
}
end
diff --git a/lib/gitlab/background_migration/user_mentions/models/design.rb b/lib/gitlab/background_migration/user_mentions/models/design.rb
new file mode 100644
index 00000000000..66cff561bcb
--- /dev/null
+++ b/lib/gitlab/background_migration/user_mentions/models/design.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+# rubocop:disable Style/Documentation
+
+module Gitlab
+ module BackgroundMigration
+ module UserMentions
+ module Models
+ module DesignManagement
+ class Design < ActiveRecord::Base
+ include MentionableMigrationMethods
+
+ def self.user_mention_model
+ Gitlab::BackgroundMigration::UserMentions::Models::DesignUserMention
+ end
+
+ def user_mention_model
+ self.class.user_mention_model
+ end
+
+ def user_mention_resource_id
+ id
+ end
+
+ def user_mention_note_id
+ 'NULL'
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb b/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb
new file mode 100644
index 00000000000..68205ecd3c2
--- /dev/null
+++ b/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+# rubocop:disable Style/Documentation
+
+module Gitlab
+ module BackgroundMigration
+ module UserMentions
+ module Models
+ class DesignUserMention < ActiveRecord::Base
+ self.table_name = 'design_user_mentions'
+
+ def self.resource_foreign_key
+ :design_id
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml b/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml
new file mode 100644
index 00000000000..a295fdcef7c
--- /dev/null
+++ b/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml
@@ -0,0 +1,27 @@
+# Read more about the feature here: https://docs.gitlab.com/ee/user/project/merge_requests/accessibility_testing.html
+
+stages:
+ - build
+ - test
+ - deploy
+ - accessibility
+
+a11y:
+ stage: accessibility
+ image: node
+ script:
+ - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
+ - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \
+ - apt-get update && \
+ - apt-get install -y google-chrome-stable && \
+ - rm -rf /var/lib/apt/lists/*
+ - npm install pa11y@5.3.0 pa11y-reporter-html@1.0.0
+ - 'echo { \"chromeLaunchConfig\": { \"args\": [\"--no-sandbox\"] }, \"includeWarnings\": true, \"reporter\": \"html\" } > pa11y.json'
+ - './node_modules/.bin/pa11y $a11y_urls > accessibility.html'
+ allow_failure: true
+ artifacts:
+ when: always
+ expose_as: 'accessibility'
+ paths: ['accessibility.html']
+ rules:
+ - if: $a11y_urls
diff --git a/lib/gitlab/template/finders/global_template_finder.rb b/lib/gitlab/template/finders/global_template_finder.rb
index 2dd4b7a4092..3669d652fd3 100644
--- a/lib/gitlab/template/finders/global_template_finder.rb
+++ b/lib/gitlab/template/finders/global_template_finder.rb
@@ -5,9 +5,11 @@ module Gitlab
module Template
module Finders
class GlobalTemplateFinder < BaseTemplateFinder
- def initialize(base_dir, extension, categories = {})
+ def initialize(base_dir, extension, categories = {}, exclusions: [])
@categories = categories
@extension = extension
+ @exclusions = exclusions
+
super(base_dir)
end
@@ -16,6 +18,8 @@ module Gitlab
end
def find(key)
+ return if excluded?(key)
+
file_name = "#{key}#{@extension}"
# The key is untrusted input, so ensure we can't be directed outside
@@ -28,11 +32,20 @@ module Gitlab
def list_files_for(dir)
dir = "#{dir}/" unless dir.end_with?('/')
- Dir.glob(File.join(dir, "*#{@extension}")).select { |f| f =~ self.class.filter_regex(@extension) }
+
+ Dir.glob(File.join(dir, "*#{@extension}")).select do |f|
+ next if excluded?(f)
+
+ f =~ self.class.filter_regex(@extension)
+ end
end
private
+ def excluded?(file_name)
+ @exclusions.include?(file_name)
+ end
+
def select_directory(file_name)
@categories.keys.find do |category|
File.exist?(File.join(category_directory(category), file_name))
diff --git a/lib/gitlab/template/gitlab_ci_yml_template.rb b/lib/gitlab/template/gitlab_ci_yml_template.rb
index ee91f1200cd..26a9dc9fd38 100644
--- a/lib/gitlab/template/gitlab_ci_yml_template.rb
+++ b/lib/gitlab/template/gitlab_ci_yml_template.rb
@@ -17,16 +17,25 @@ module Gitlab
{
'General' => '',
'Pages' => 'Pages',
+ 'Verify' => 'Verify',
'Auto deploy' => 'autodeploy'
}
end
+ def disabled_templates
+ %w[
+ Verify/Browser-Performance
+ ]
+ end
+
def base_dir
Rails.root.join('lib/gitlab/ci/templates')
end
def finder(project = nil)
- Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories)
+ Gitlab::Template::Finders::GlobalTemplateFinder.new(
+ self.base_dir, self.extension, self.categories, exclusions: self.disabled_templates
+ )
end
end
end
diff --git a/spec/controllers/users/terms_controller_spec.rb b/spec/controllers/users/terms_controller_spec.rb
index e0bdec3df1d..99582652c39 100644
--- a/spec/controllers/users/terms_controller_spec.rb
+++ b/spec/controllers/users/terms_controller_spec.rb
@@ -4,7 +4,8 @@ require 'spec_helper'
describe Users::TermsController do
include TermsHelper
- let(:user) { create(:user) }
+
+ let_it_be(:user) { create(:user) }
let(:term) { create(:term) }
before do
@@ -12,88 +13,145 @@ describe Users::TermsController do
end
describe 'GET #index' do
- it 'redirects when no terms exist' do
- get :index
+ context 'when a user is signed in' do
+ it 'redirects when no terms exist' do
+ get :index
+
+ expect(response).to redirect_to(root_path)
+ end
+
+ context 'when terms exist' do
+ before do
+ stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ term
+ end
+
+ it 'shows terms when they exist' do
+ get :index
+
+ expect(response).to have_gitlab_http_status(:success)
+ end
+
+ it 'shows a message when the user already accepted the terms' do
+ accept_terms(user)
+
+ get :index
- expect(response).to have_gitlab_http_status(:redirect)
+ expect(controller).to set_flash.now[:notice].to(/already accepted/)
+ end
+ end
end
- context 'when terms exist' do
+ context 'when a user is not signed in' do
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
- term
+ sign_out user
end
- it 'shows terms when they exist' do
- get :index
+ context 'when terms exist' do
+ before do
+ stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ term
+ end
- expect(response).to have_gitlab_http_status(:success)
- end
+ it 'returns success response' do
+ get :index
- it 'shows a message when the user already accepted the terms' do
- accept_terms(user)
+ expect(response).to have_gitlab_http_status(:success)
+ end
+ end
- get :index
+ context 'when no terms exist' do
+ it 'redirects' do
+ get :index
- expect(controller).to set_flash.now[:notice].to(/already accepted/)
+ expect(response).to redirect_to(root_path)
+ end
end
end
end
describe 'POST #accept' do
- it 'saves that the user accepted the terms' do
- post :accept, params: { id: term.id }
+ context 'when a user is signed in' do
+ it 'saves that the user accepted the terms' do
+ post :accept, params: { id: term.id }
- agreement = user.term_agreements.find_by(term: term)
+ agreement = user.term_agreements.find_by(term: term)
- expect(agreement.accepted).to eq(true)
- end
+ expect(agreement.accepted).to eq(true)
+ end
- it 'redirects to a path when specified' do
- post :accept, params: { id: term.id, redirect: groups_path }
+ it 'redirects to a path when specified' do
+ post :accept, params: { id: term.id, redirect: groups_path }
- expect(response).to redirect_to(groups_path)
- end
+ expect(response).to redirect_to(groups_path)
+ end
- it 'redirects to the referer when no redirect specified' do
- request.env["HTTP_REFERER"] = groups_url
+ it 'redirects to the referer when no redirect specified' do
+ request.env["HTTP_REFERER"] = groups_url
- post :accept, params: { id: term.id }
+ post :accept, params: { id: term.id }
- expect(response).to redirect_to(groups_path)
- end
+ expect(response).to redirect_to(groups_path)
+ end
- context 'redirecting to another domain' do
- it 'is prevented when passing a redirect param' do
- post :accept, params: { id: term.id, redirect: '//example.com/random/path' }
+ context 'redirecting to another domain' do
+ it 'is prevented when passing a redirect param' do
+ post :accept, params: { id: term.id, redirect: '//example.com/random/path' }
- expect(response).to redirect_to(root_path)
+ expect(response).to redirect_to(root_path)
+ end
+
+ it 'is prevented when redirecting to the referer' do
+ request.env["HTTP_REFERER"] = 'http://example.com/and/a/path'
+
+ post :accept, params: { id: term.id }
+
+ expect(response).to redirect_to(root_path)
+ end
end
+ end
- it 'is prevented when redirecting to the referer' do
- request.env["HTTP_REFERER"] = 'http://example.com/and/a/path'
+ context 'when a user is not signed in' do
+ before do
+ sign_out user
+ end
+ it 'redirects to login page' do
post :accept, params: { id: term.id }
- expect(response).to redirect_to(root_path)
+ expect(response).to redirect_to(new_user_session_path)
end
end
end
describe 'POST #decline' do
- it 'stores that the user declined the terms' do
- post :decline, params: { id: term.id }
+ context 'when a user is signed in' do
+ it 'stores that the user declined the terms' do
+ post :decline, params: { id: term.id }
+
+ agreement = user.term_agreements.find_by(term: term)
- agreement = user.term_agreements.find_by(term: term)
+ expect(agreement.accepted).to eq(false)
+ end
- expect(agreement.accepted).to eq(false)
+ it 'signs out the user' do
+ post :decline, params: { id: term.id }
+
+ expect(response).to redirect_to(root_path)
+ expect(assigns(:current_user)).to be_nil
+ end
end
- it 'signs out the user' do
- post :decline, params: { id: term.id }
+ context 'when a user is not signed in' do
+ before do
+ sign_out user
+ end
- expect(response).to redirect_to(root_path)
- expect(assigns(:current_user)).to be_nil
+ it 'redirects to login page' do
+ post :decline, params: { id: term.id }
+
+ expect(response).to redirect_to(new_user_session_path)
+ end
end
end
end
diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb
index 5ef1bced179..44f47e6c739 100644
--- a/spec/graphql/features/authorization_spec.rb
+++ b/spec/graphql/features/authorization_spec.rb
@@ -5,8 +5,7 @@ require 'spec_helper'
describe 'Gitlab::Graphql::Authorization' do
include GraphqlHelpers
- set(:user) { create(:user) }
-
+ let_it_be(:user) { create(:user) }
let(:permission_single) { :foo }
let(:permission_collection) { [:foo, :bar] }
let(:test_object) { double(name: 'My name') }
diff --git a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb
index b59561ebdd4..03ff1e11d85 100644
--- a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb
+++ b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb
@@ -17,11 +17,11 @@ describe ResolvesPipelines do
let(:current_user) { create(:user) }
- set(:project) { create(:project, :private) }
- set(:pipeline) { create(:ci_pipeline, project: project) }
- set(:failed_pipeline) { create(:ci_pipeline, :failed, project: project) }
- set(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') }
- set(:sha_pipeline) { create(:ci_pipeline, project: project, sha: 'deadbeef') }
+ let_it_be(:project) { create(:project, :private) }
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+ let_it_be(:failed_pipeline) { create(:ci_pipeline, :failed, project: project) }
+ let_it_be(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') }
+ let_it_be(:sha_pipeline) { create(:ci_pipeline, project: project, sha: 'deadbeef') }
before do
project.add_developer(current_user)
diff --git a/spec/graphql/resolvers/group_resolver_spec.rb b/spec/graphql/resolvers/group_resolver_spec.rb
index 7dec9ac1aa5..70b1102d363 100644
--- a/spec/graphql/resolvers/group_resolver_spec.rb
+++ b/spec/graphql/resolvers/group_resolver_spec.rb
@@ -5,8 +5,8 @@ require 'spec_helper'
describe Resolvers::GroupResolver do
include GraphqlHelpers
- set(:group1) { create(:group) }
- set(:group2) { create(:group) }
+ let_it_be(:group1) { create(:group) }
+ let_it_be(:group2) { create(:group) }
describe '#resolve' do
it 'batch-resolves groups by full path' do
diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb
index 9e75a6cad60..3fbb7280465 100644
--- a/spec/graphql/resolvers/issues_resolver_spec.rb
+++ b/spec/graphql/resolvers/issues_resolver_spec.rb
@@ -8,11 +8,11 @@ describe Resolvers::IssuesResolver do
let(:current_user) { create(:user) }
context "with a project" do
- set(:project) { create(:project) }
- set(:issue1) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
- set(:issue2) { create(:issue, project: project, state: :closed, title: 'foo', created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
- set(:label1) { create(:label, project: project) }
- set(:label2) { create(:label, project: project) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:issue1) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
+ let_it_be(:issue2) { create(:issue, project: project, state: :closed, title: 'foo', created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
+ let_it_be(:label1) { create(:label, project: project) }
+ let_it_be(:label2) { create(:label, project: project) }
before do
project.add_developer(current_user)
diff --git a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb
index b8bdfc36ba7..02c6409a9a6 100644
--- a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb
+++ b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb
@@ -5,8 +5,8 @@ require 'spec_helper'
describe Resolvers::MergeRequestPipelinesResolver do
include GraphqlHelpers
- set(:merge_request) { create(:merge_request) }
- set(:pipeline) do
+ let_it_be(:merge_request) { create(:merge_request) }
+ let_it_be(:pipeline) do
create(
:ci_pipeline,
project: merge_request.source_project,
@@ -14,8 +14,8 @@ describe Resolvers::MergeRequestPipelinesResolver do
sha: merge_request.diff_head_sha
)
end
- set(:other_project_pipeline) { create(:ci_pipeline, project: merge_request.source_project) }
- set(:other_pipeline) { create(:ci_pipeline) }
+ let_it_be(:other_project_pipeline) { create(:ci_pipeline, project: merge_request.source_project) }
+ let_it_be(:other_pipeline) { create(:ci_pipeline) }
let(:current_user) { create(:user) }
before do
diff --git a/spec/graphql/resolvers/merge_requests_resolver_spec.rb b/spec/graphql/resolvers/merge_requests_resolver_spec.rb
index fe167a6ae3e..0bd5043d855 100644
--- a/spec/graphql/resolvers/merge_requests_resolver_spec.rb
+++ b/spec/graphql/resolvers/merge_requests_resolver_spec.rb
@@ -5,16 +5,13 @@ require 'spec_helper'
describe Resolvers::MergeRequestsResolver do
include GraphqlHelpers
- set(:project) { create(:project, :repository) }
- set(:merge_request_1) { create(:merge_request, :simple, source_project: project, target_project: project) }
- set(:merge_request_2) { create(:merge_request, :rebased, source_project: project, target_project: project) }
-
- set(:other_project) { create(:project, :repository) }
- set(:other_merge_request) { create(:merge_request, source_project: other_project, target_project: other_project) }
-
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:merge_request_1) { create(:merge_request, :simple, source_project: project, target_project: project) }
+ let_it_be(:merge_request_2) { create(:merge_request, :rebased, source_project: project, target_project: project) }
+ let_it_be(:other_project) { create(:project, :repository) }
+ let_it_be(:other_merge_request) { create(:merge_request, source_project: other_project, target_project: other_project) }
let(:iid_1) { merge_request_1.iid }
let(:iid_2) { merge_request_2.iid }
-
let(:other_iid) { other_merge_request.iid }
describe '#resolve' do
diff --git a/spec/graphql/resolvers/project_pipelines_resolver_spec.rb b/spec/graphql/resolvers/project_pipelines_resolver_spec.rb
index f312a118c96..2a14796fdfa 100644
--- a/spec/graphql/resolvers/project_pipelines_resolver_spec.rb
+++ b/spec/graphql/resolvers/project_pipelines_resolver_spec.rb
@@ -5,9 +5,9 @@ require 'spec_helper'
describe Resolvers::ProjectPipelinesResolver do
include GraphqlHelpers
- set(:project) { create(:project) }
- set(:pipeline) { create(:ci_pipeline, project: project) }
- set(:other_pipeline) { create(:ci_pipeline) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+ let_it_be(:other_pipeline) { create(:ci_pipeline) }
let(:current_user) { create(:user) }
before do
diff --git a/spec/graphql/resolvers/project_resolver_spec.rb b/spec/graphql/resolvers/project_resolver_spec.rb
index 860f8b4abb8..e9e38353156 100644
--- a/spec/graphql/resolvers/project_resolver_spec.rb
+++ b/spec/graphql/resolvers/project_resolver_spec.rb
@@ -5,10 +5,9 @@ require 'spec_helper'
describe Resolvers::ProjectResolver do
include GraphqlHelpers
- set(:project1) { create(:project) }
- set(:project2) { create(:project) }
-
- set(:other_project) { create(:project) }
+ let_it_be(:project1) { create(:project) }
+ let_it_be(:project2) { create(:project) }
+ let_it_be(:other_project) { create(:project) }
describe '#resolve' do
it 'batch-resolves projects by full path' do
diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb
index 5d42a80aae3..d06548f1595 100644
--- a/spec/helpers/auto_devops_helper_spec.rb
+++ b/spec/helpers/auto_devops_helper_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe AutoDevopsHelper do
- set(:project) { create(:project) }
- set(:user) { create(:user) }
+ let_it_be(:project, reload: true) { create(:project) }
+ let_it_be(:user) { create(:user) }
describe '.show_auto_devops_callout?' do
let(:allowed) { true }
diff --git a/spec/helpers/boards_helper_spec.rb b/spec/helpers/boards_helper_spec.rb
index 8a4446b7f59..e731b95586f 100644
--- a/spec/helpers/boards_helper_spec.rb
+++ b/spec/helpers/boards_helper_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe BoardsHelper do
- set(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
describe '#build_issue_link_base' do
context 'project board' do
diff --git a/spec/helpers/environments_helper_spec.rb b/spec/helpers/environments_helper_spec.rb
index b72fbc9fd3c..37713a04844 100644
--- a/spec/helpers/environments_helper_spec.rb
+++ b/spec/helpers/environments_helper_spec.rb
@@ -3,9 +3,9 @@
require 'spec_helper'
describe EnvironmentsHelper do
- set(:user) { create(:user) }
- set(:project) { create(:project, :repository) }
- set(:environment) { create(:environment, project: project) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project, reload: true) { create(:project, :repository) }
+ let_it_be(:environment) { create(:environment, project: project) }
describe '#metrics_data' do
before do
diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb
index 7ad554fd618..f5771405687 100644
--- a/spec/helpers/labels_helper_spec.rb
+++ b/spec/helpers/labels_helper_spec.rb
@@ -35,7 +35,7 @@ describe LabelsHelper do
end
context 'with a group label' do
- set(:group) { create(:group) }
+ let_it_be(:group) { create(:group) }
let(:label) { create(:group_label, group: group, title: 'bug') }
context 'when asking for an issue link' do
@@ -135,7 +135,7 @@ describe LabelsHelper do
end
describe 'create_label_title' do
- set(:group) { create(:group) }
+ let_it_be(:group) { create(:group) }
context 'with a group as subject' do
it 'returns "Create group label"' do
@@ -144,7 +144,7 @@ describe LabelsHelper do
end
context 'with a project as subject' do
- set(:project) { create(:project, namespace: group) }
+ let_it_be(:project) { create(:project, namespace: group) }
it 'returns "Create project label"' do
expect(create_label_title(project)).to eq _('Create project label')
@@ -159,7 +159,7 @@ describe LabelsHelper do
end
describe 'manage_labels_title' do
- set(:group) { create(:group) }
+ let_it_be(:group) { create(:group) }
context 'with a group as subject' do
it 'returns "Manage group labels"' do
@@ -168,7 +168,7 @@ describe LabelsHelper do
end
context 'with a project as subject' do
- set(:project) { create(:project, namespace: group) }
+ let_it_be(:project) { create(:project, namespace: group) }
it 'returns "Manage project labels"' do
expect(manage_labels_title(project)).to eq _('Manage project labels')
@@ -183,7 +183,7 @@ describe LabelsHelper do
end
describe 'view_labels_title' do
- set(:group) { create(:group) }
+ let_it_be(:group) { create(:group) }
context 'with a group as subject' do
it 'returns "View group labels"' do
@@ -192,7 +192,7 @@ describe LabelsHelper do
end
context 'with a project as subject' do
- set(:project) { create(:project, namespace: group) }
+ let_it_be(:project) { create(:project, namespace: group) }
it 'returns "View project labels"' do
expect(view_labels_title(project)).to eq _('View project labels')
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index d7cc8afe9c5..3fb36e540b6 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -3,15 +3,15 @@
require 'spec_helper'
describe MarkupHelper do
- set(:project) { create(:project, :repository) }
- set(:user) do
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) do
user = create(:user, username: 'gfm')
project.add_maintainer(user)
user
end
- set(:issue) { create(:issue, project: project) }
- set(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
- set(:snippet) { create(:project_snippet, project: project) }
+ let_it_be(:issue) { create(:issue, project: project) }
+ let_it_be(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+ let_it_be(:snippet) { create(:project_snippet, project: project) }
let(:commit) { project.commit }
before do
@@ -45,8 +45,8 @@ describe MarkupHelper do
describe "override default project" do
let(:actual) { issue.to_reference }
- set(:second_project) { create(:project, :public) }
- set(:second_issue) { create(:issue, project: second_project) }
+ let_it_be(:second_project) { create(:project, :public) }
+ let_it_be(:second_issue) { create(:issue, project: second_project) }
it 'links to the issue' do
expected = urls.project_issue_path(second_project, second_issue)
@@ -57,7 +57,7 @@ describe MarkupHelper do
describe 'uploads' do
let(:text) { "![ImageTest](/uploads/test.png)" }
- set(:group) { create(:group) }
+ let_it_be(:group) { create(:group) }
subject { helper.markdown(text) }
@@ -79,7 +79,7 @@ describe MarkupHelper do
end
describe "with a group in the context" do
- set(:project_in_group) { create(:project, group: group) }
+ let_it_be(:project_in_group) { create(:project, group: group) }
before do
helper.instance_variable_set(:@group, group)
diff --git a/spec/helpers/projects/error_tracking_helper_spec.rb b/spec/helpers/projects/error_tracking_helper_spec.rb
index 38a6ef6826b..008d749a002 100644
--- a/spec/helpers/projects/error_tracking_helper_spec.rb
+++ b/spec/helpers/projects/error_tracking_helper_spec.rb
@@ -5,8 +5,8 @@ require 'spec_helper'
describe Projects::ErrorTrackingHelper do
include Gitlab::Routing.url_helpers
- set(:project) { create(:project) }
- set(:current_user) { create(:user) }
+ let_it_be(:project, reload: true) { create(:project) }
+ let_it_be(:current_user) { create(:user) }
describe '#error_tracking_data' do
let(:can_enable_error_tracking) { true }
diff --git a/spec/lib/gitlab/ci/templates/templates_spec.rb b/spec/lib/gitlab/ci/templates/templates_spec.rb
index b52064b3036..bc3d5b89220 100644
--- a/spec/lib/gitlab/ci/templates/templates_spec.rb
+++ b/spec/lib/gitlab/ci/templates/templates_spec.rb
@@ -2,33 +2,43 @@
require 'spec_helper'
-describe "CI YML Templates" do
- using RSpec::Parameterized::TableSyntax
-
+describe 'CI YML Templates' do
subject { Gitlab::Ci::YamlProcessor.new(content) }
- where(:template_name) do
- Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name)
- end
-
- with_them do
- let(:content) do
- <<~EOS
- include:
- - template: #{template_name}
+ let(:all_templates) { Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) }
- concrete_build_implemented_by_a_user:
- stage: test
- script: do something
- EOS
+ let(:disabled_templates) do
+ Gitlab::Template::GitlabCiYmlTemplate.disabled_templates.map do |template|
+ template + Gitlab::Template::GitlabCiYmlTemplate.extension
end
+ end
+
+ context 'included in a CI YAML configuration' do
+ using RSpec::Parameterized::TableSyntax
- it 'is valid' do
- expect { subject }.not_to raise_error
+ where(:template_name) do
+ all_templates - disabled_templates
end
- it 'require default stages to be included' do
- expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
+ with_them do
+ let(:content) do
+ <<~EOS
+ include:
+ - template: #{template_name}
+
+ concrete_build_implemented_by_a_user:
+ stage: test
+ script: do something
+ EOS
+ end
+
+ it 'is valid' do
+ expect { subject }.not_to raise_error
+ end
+
+ it 'require default stages to be included' do
+ expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
+ end
end
end
end
diff --git a/spec/lib/gitlab/template/finders/global_template_finder_spec.rb b/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
index 082ffa855b7..580da497944 100644
--- a/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
+++ b/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
@@ -15,23 +15,87 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
FileUtils.rm_rf(base_dir)
end
- subject(:finder) { described_class.new(base_dir, '', 'Foo' => '', 'Bar' => 'bar') }
+ subject(:finder) { described_class.new(base_dir, '', { 'General' => '', 'Bar' => 'Bar' }, exclusions: exclusions) }
+
+ let(:exclusions) { [] }
describe '.find' do
- it 'finds a template in the Foo category' do
- create_template!('test-template')
+ context 'with a non-prefixed General template' do
+ before do
+ create_template!('test-template')
+ end
- expect(finder.find('test-template')).to be_present
- end
+ it 'finds the template with no prefix' do
+ expect(finder.find('test-template')).to be_present
+ end
+
+ it 'does not find a prefixed template' do
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+
+ it 'does not permit path traversal requests' do
+ expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ end
- it 'finds a template in the Bar category' do
- create_template!('bar/test-template')
+ context 'while listed as an exclusion' do
+ let(:exclusions) { %w[test-template] }
- expect(finder.find('test-template')).to be_present
+ it 'does not find the template without a prefix' do
+ expect(finder.find('test-template')).to be_nil
+ end
+
+ it 'does not find the template with a prefix' do
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+
+ it 'finds another prefixed template with the same name' do
+ create_template!('Bar/test-template')
+
+ expect(finder.find('test-template')).to be_nil
+ expect(finder.find('Bar/test-template')).to be_present
+ end
+ end
end
- it 'does not permit path traversal requests' do
- expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ context 'with a prefixed template' do
+ before do
+ create_template!('Bar/test-template')
+ end
+
+ it 'finds the template with a prefix' do
+ expect(finder.find('Bar/test-template')).to be_present
+ end
+
+ # NOTE: This spec fails, the template Bar/test-template is found
+ # See Gitlab issue: https://gitlab.com/gitlab-org/gitlab/issues/205719
+ xit 'does not find the template without a prefix' do
+ expect(finder.find('test-template')).to be_nil
+ end
+
+ it 'does not permit path traversal requests' do
+ expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ end
+
+ context 'while listed as an exclusion' do
+ let(:exclusions) { %w[Bar/test-template] }
+
+ it 'does not find the template with a prefix' do
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+
+ # NOTE: This spec fails, the template Bar/test-template is found
+ # See Gitlab issue: https://gitlab.com/gitlab-org/gitlab/issues/205719
+ xit 'does not find the template without a prefix' do
+ expect(finder.find('test-template')).to be_nil
+ end
+
+ it 'finds another non-prefixed template with the same name' do
+ create_template!('Bar/test-template')
+
+ expect(finder.find('test-template')).to be_present
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+ end
end
end
end
diff --git a/spec/mailers/emails/pages_domains_spec.rb b/spec/mailers/emails/pages_domains_spec.rb
index e360e38256e..78887cef7ab 100644
--- a/spec/mailers/emails/pages_domains_spec.rb
+++ b/spec/mailers/emails/pages_domains_spec.rb
@@ -7,8 +7,8 @@ describe Emails::PagesDomains do
include EmailSpec::Matchers
include_context 'gitlab email notification'
- set(:domain) { create(:pages_domain, project: project) }
- set(:user) { project.creator }
+ let_it_be(:domain, reload: true) { create(:pages_domain, project: project) }
+ let_it_be(:user) { project.creator }
shared_examples 'a pages domain email' do
let(:recipient) { user }
diff --git a/spec/mailers/emails/pipelines_spec.rb b/spec/mailers/emails/pipelines_spec.rb
index ad1aa915fbb..9996bd9a6c4 100644
--- a/spec/mailers/emails/pipelines_spec.rb
+++ b/spec/mailers/emails/pipelines_spec.rb
@@ -6,7 +6,7 @@ require 'email_spec'
describe Emails::Pipelines do
include EmailSpec::Matchers
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
shared_examples_for 'correct pipeline information' do
it 'has a correct information' do
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 19b15a6c6e2..f49abb24c44 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -13,11 +13,11 @@ describe Notify do
let(:current_user_sanitized) { 'www_example_com' }
- set(:user) { create(:user) }
- set(:current_user) { create(:user, email: "current@email.com", name: 'www.example.com') }
- set(:assignee) { create(:user, email: 'assignee@example.com', name: 'John Doe') }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:current_user) { create(:user, email: "current@email.com", name: 'www.example.com') }
+ let_it_be(:assignee) { create(:user, email: 'assignee@example.com', name: 'John Doe') }
- set(:merge_request) do
+ let_it_be(:merge_request) do
create(:merge_request, source_project: project,
target_project: project,
author: current_user,
@@ -25,7 +25,7 @@ describe Notify do
description: 'Awesome description')
end
- set(:issue) do
+ let_it_be(:issue, reload: true) do
create(:issue, author: current_user,
assignees: [assignee],
project: project,
@@ -487,7 +487,7 @@ describe Notify do
end
describe 'that are unmergeable' do
- set(:merge_request) do
+ let_it_be(:merge_request) do
create(:merge_request, :conflict,
source_project: project,
target_project: project,
@@ -568,7 +568,7 @@ describe Notify do
end
describe '#mail_thread' do
- set(:mail_thread_note) { create(:note) }
+ let_it_be(:mail_thread_note) { create(:note) }
let(:headers) do
{
@@ -638,9 +638,9 @@ describe Notify do
let(:host) { Gitlab.config.gitlab.host }
context 'in discussion' do
- set(:first_note) { create(:discussion_note_on_issue, project: project) }
- set(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note, project: project) }
- set(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note, project: project) }
+ let_it_be(:first_note) { create(:discussion_note_on_issue, project: project) }
+ let_it_be(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note, project: project) }
+ let_it_be(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note, project: project) }
subject { described_class.note_issue_email(recipient.id, third_note.id) }
@@ -664,7 +664,7 @@ describe Notify do
end
context 'individual issue comments' do
- set(:note) { create(:note_on_issue, project: project) }
+ let_it_be(:note) { create(:note_on_issue, project: project) }
subject { described_class.note_issue_email(recipient.id, note.id) }
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 832c19adf1d..c1e7a1c2875 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -489,7 +489,14 @@ describe JiraService do
@jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
- expect(@jira_service).to have_received(:log_error).with("Issue transition failed", error: "Bad Request", client_url: "http://jira.example.com")
+ expect(@jira_service).to have_received(:log_error).with(
+ "Issue transition failed",
+ error: hash_including(
+ exception_class: 'StandardError',
+ exception_message: "Bad Request"
+ ),
+ client_url: "http://jira.example.com"
+ )
end
it 'calls the api with jira_issue_transition_id' do
diff --git a/spec/policies/application_setting/term_policy_spec.rb b/spec/policies/application_setting/term_policy_spec.rb
index 21690d4b457..2b5b9758ec2 100644
--- a/spec/policies/application_setting/term_policy_spec.rb
+++ b/spec/policies/application_setting/term_policy_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
describe ApplicationSetting::TermPolicy do
include TermsHelper
- set(:term) { create(:term) }
+ let_it_be(:term) { create(:term) }
let(:user) { create(:user) }
subject(:policy) { described_class.new(user, term) }
diff --git a/spec/policies/ci/pipeline_schedule_policy_spec.rb b/spec/policies/ci/pipeline_schedule_policy_spec.rb
index 700d7d1af0a..d503401f7cf 100644
--- a/spec/policies/ci/pipeline_schedule_policy_spec.rb
+++ b/spec/policies/ci/pipeline_schedule_policy_spec.rb
@@ -3,9 +3,9 @@
require 'spec_helper'
describe Ci::PipelineSchedulePolicy, :models do
- set(:user) { create(:user) }
- set(:project) { create(:project, :repository) }
- set(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:pipeline_schedule, reload: true) { create(:ci_pipeline_schedule, :nightly, project: project) }
let(:policy) do
described_class.new(user, pipeline_schedule)
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index 3b08726c75a..e1466ad2b73 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -5,12 +5,12 @@ require 'spec_helper'
describe ProjectPolicy do
include ExternalAuthorizationServiceHelpers
include_context 'ProjectPolicy context'
- set(:guest) { create(:user) }
- set(:reporter) { create(:user) }
- set(:developer) { create(:user) }
- set(:maintainer) { create(:user) }
- set(:owner) { create(:user) }
- set(:admin) { create(:admin) }
+ let_it_be(:guest) { create(:user) }
+ let_it_be(:reporter) { create(:user) }
+ let_it_be(:developer) { create(:user) }
+ let_it_be(:maintainer) { create(:user) }
+ let_it_be(:owner) { create(:user) }
+ let_it_be(:admin) { create(:admin) }
let(:project) { create(:project, :public, namespace: owner.namespace) }
let(:base_guest_permissions) do
diff --git a/spec/policies/resource_label_event_policy_spec.rb b/spec/policies/resource_label_event_policy_spec.rb
index 799534d2b08..4db2390c818 100644
--- a/spec/policies/resource_label_event_policy_spec.rb
+++ b/spec/policies/resource_label_event_policy_spec.rb
@@ -3,10 +3,10 @@
require 'spec_helper'
describe ResourceLabelEventPolicy do
- set(:user) { create(:user) }
- set(:project) { create(:project, :private) }
- set(:issue) { create(:issue, project: project) }
- set(:private_project) { create(:project, :private) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :private) }
+ let_it_be(:issue) { create(:issue, project: project) }
+ let_it_be(:private_project) { create(:project, :private) }
describe '#read_resource_label_event' do
context 'with non-member user' do
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb
index 02dc2229769..c3b5f9ded21 100644
--- a/spec/requests/api/internal/base_spec.rb
+++ b/spec/requests/api/internal/base_spec.rb
@@ -811,6 +811,8 @@ describe API::Internal::Base do
describe 'POST /internal/post_receive', :clean_gitlab_redis_shared_state do
let(:identifier) { 'key-123' }
+ let(:branch_name) { 'feature' }
+ let(:push_options) { ['ci.skip', 'another push option'] }
let(:valid_params) do
{
@@ -822,192 +824,33 @@ describe API::Internal::Base do
}
end
- let(:branch_name) { 'feature' }
-
let(:changes) do
"#{Gitlab::Git::BLANK_SHA} 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/#{branch_name}"
end
- let(:push_options) do
- ['ci.skip',
- 'another push option']
- end
+ subject { post api('/internal/post_receive'), params: valid_params }
before do
project.add_developer(user)
allow_any_instance_of(Gitlab::Identifier).to receive(:identify).and_return(user)
end
- it 'enqueues a PostReceive worker job' do
- expect(PostReceive).to receive(:perform_async)
- .with(gl_repository, identifier, changes, { ci: { skip: true } })
-
- post api('/internal/post_receive'), params: valid_params
- end
-
- it 'decreases the reference counter and returns the result' do
- expect(Gitlab::ReferenceCounter).to receive(:new).with(gl_repository)
- .and_return(reference_counter)
- expect(reference_counter).to receive(:decrease).and_return(true)
-
- post api('/internal/post_receive'), params: valid_params
-
- expect(json_response['reference_counter_decreased']).to be(true)
- end
-
- it 'returns link to create new merge request' do
- post api('/internal/post_receive'), params: valid_params
-
+ it 'executes PostReceiveService' do
message = <<~MESSAGE.strip
To create a merge request for #{branch_name}, visit:
http://#{Gitlab.config.gitlab.host}/#{project.full_path}/-/merge_requests/new?merge_request%5Bsource_branch%5D=#{branch_name}
MESSAGE
- expect(json_response['messages']).to include(build_basic_message(message))
- end
-
- it 'returns the link to an existing merge request when it exists' do
- merge_request = create(:merge_request, source_project: project, source_branch: branch_name, target_branch: 'master')
-
- post api('/internal/post_receive'), params: valid_params
-
- message = <<~MESSAGE.strip
- View merge request for feature:
- #{project_merge_request_url(project, merge_request)}
- MESSAGE
-
- expect(json_response['messages']).to include(build_basic_message(message))
- end
-
- it 'returns no merge request messages if printing_merge_request_link_enabled is false' do
- project.update!(printing_merge_request_link_enabled: false)
-
- post api('/internal/post_receive'), params: valid_params
-
- expect(json_response['messages']).to be_blank
- end
-
- it 'does not invoke MergeRequests::PushOptionsHandlerService' do
- expect(MergeRequests::PushOptionsHandlerService).not_to receive(:new)
+ subject
- post api('/internal/post_receive'), params: valid_params
+ expect(json_response).to eq({
+ 'messages' => [{ 'message' => message, 'type' => 'basic' }],
+ 'reference_counter_decreased' => true
+ })
end
it_behaves_like 'storing arguments in the application context' do
let(:expected_params) { { user: user.username, project: project.full_path } }
-
- subject { post api('/internal/post_receive'), params: valid_params }
- end
-
- context 'when there are merge_request push options' do
- before do
- valid_params[:push_options] = ['merge_request.create']
- end
-
- it 'invokes MergeRequests::PushOptionsHandlerService' do
- expect(MergeRequests::PushOptionsHandlerService).to receive(:new)
-
- post api('/internal/post_receive'), params: valid_params
- end
-
- it 'creates a new merge request' do
- expect do
- Sidekiq::Testing.fake! do
- post api('/internal/post_receive'), params: valid_params
- end
- end.to change { MergeRequest.count }.by(1)
- end
-
- it 'links to the newly created merge request' do
- post api('/internal/post_receive'), params: valid_params
-
- message = <<~MESSAGE.strip
- View merge request for #{branch_name}:
- http://#{Gitlab.config.gitlab.host}/#{project.full_path}/-/merge_requests/1
- MESSAGE
-
- expect(json_response['messages']).to include(build_basic_message(message))
- end
-
- it 'adds errors on the service instance to warnings' do
- expect_any_instance_of(
- MergeRequests::PushOptionsHandlerService
- ).to receive(:errors).at_least(:once).and_return(['my error'])
-
- post api('/internal/post_receive'), params: valid_params
-
- message = "WARNINGS:\nError encountered with push options 'merge_request.create': my error"
- expect(json_response['messages']).to include(build_alert_message(message))
- end
-
- it 'adds ActiveRecord errors on invalid MergeRequest records to warnings' do
- invalid_merge_request = MergeRequest.new
- invalid_merge_request.errors.add(:base, 'my error')
-
- expect_any_instance_of(
- MergeRequests::CreateService
- ).to receive(:execute).and_return(invalid_merge_request)
-
- post api('/internal/post_receive'), params: valid_params
-
- message = "WARNINGS:\nError encountered with push options 'merge_request.create': my error"
- expect(json_response['messages']).to include(build_alert_message(message))
- end
- end
-
- context 'broadcast message exists' do
- let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) }
-
- it 'outputs a broadcast message' do
- post api('/internal/post_receive'), params: valid_params
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['messages']).to include(build_alert_message(broadcast_message.message))
- end
- end
-
- context 'broadcast message does not exist' do
- it 'does not output a broadcast message' do
- post api('/internal/post_receive'), params: valid_params
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(has_alert_messages?(json_response['messages'])).to be_falsey
- end
- end
-
- context 'nil broadcast message' do
- it 'does not output a broadcast message' do
- allow(BroadcastMessage).to receive(:current).and_return(nil)
-
- post api('/internal/post_receive'), params: valid_params
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(has_alert_messages?(json_response['messages'])).to be_falsey
- end
- end
-
- context 'with a redirected data' do
- it 'returns redirected message on the response' do
- project_moved = Gitlab::Checks::ProjectMoved.new(project, user, 'http', 'foo/baz')
- project_moved.add_message
-
- post api('/internal/post_receive'), params: valid_params
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['messages']).to include(build_basic_message(project_moved.message))
- end
- end
-
- context 'with new project data' do
- it 'returns new project message on the response' do
- project_created = Gitlab::Checks::ProjectCreated.new(project, user, 'http')
- project_created.add_message
-
- post api('/internal/post_receive'), params: valid_params
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['messages']).to include(build_basic_message(project_created.message))
- end
end
context 'with an orphaned write deploy key' do
@@ -1016,7 +859,7 @@ describe API::Internal::Base do
expect(Gitlab::Checks::ProjectMoved).not_to receive(:fetch_message)
- post api('/internal/post_receive'), params: valid_params
+ subject
expect(response).to have_gitlab_http_status(:ok)
end
@@ -1030,7 +873,7 @@ describe API::Internal::Base do
expect(Gitlab::Checks::ProjectMoved).not_to receive(:fetch_message)
- post api('/internal/post_receive'), params: valid_params
+ subject
expect(response).to have_gitlab_http_status(:ok)
end
@@ -1142,18 +985,4 @@ describe API::Internal::Base do
}
)
end
-
- def build_alert_message(message)
- { 'type' => 'alert', 'message' => message }
- end
-
- def build_basic_message(message)
- { 'type' => 'basic', 'message' => message }
- end
-
- def has_alert_messages?(messages)
- messages.any? do |message|
- message['type'] == 'alert'
- end
- end
end
diff --git a/spec/services/post_receive_service_spec.rb b/spec/services/post_receive_service_spec.rb
new file mode 100644
index 00000000000..9b9200fd33e
--- /dev/null
+++ b/spec/services/post_receive_service_spec.rb
@@ -0,0 +1,186 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe PostReceiveService do
+ include Gitlab::Routing
+
+ let_it_be(:project) { create(:project, :repository, :wiki_repo) }
+ let_it_be(:user) { create(:user) }
+
+ let(:identifier) { 'key-123' }
+ let(:gl_repository) { "project-#{project.id}" }
+ let(:branch_name) { 'feature' }
+ let(:secret_token) { Gitlab::Shell.secret_token }
+ let(:reference_counter) { double('ReferenceCounter') }
+ let(:push_options) { ['ci.skip', 'another push option'] }
+
+ let(:changes) do
+ "#{Gitlab::Git::BLANK_SHA} 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/#{branch_name}"
+ end
+
+ let(:params) do
+ {
+ gl_repository: gl_repository,
+ secret_token: secret_token,
+ identifier: identifier,
+ changes: changes,
+ push_options: push_options
+ }
+ end
+
+ let(:response) { PostReceiveService.new(user, project, params).execute }
+
+ subject { response.messages.as_json }
+
+ it 'enqueues a PostReceive worker job' do
+ expect(PostReceive).to receive(:perform_async)
+ .with(gl_repository, identifier, changes, { ci: { skip: true } })
+
+ subject
+ end
+
+ it 'decreases the reference counter and returns the result' do
+ expect(Gitlab::ReferenceCounter).to receive(:new).with(gl_repository)
+ .and_return(reference_counter)
+ expect(reference_counter).to receive(:decrease).and_return(true)
+
+ expect(response.reference_counter_decreased).to be(true)
+ end
+
+ it 'returns link to create new merge request' do
+ message = <<~MESSAGE.strip
+ To create a merge request for #{branch_name}, visit:
+ http://#{Gitlab.config.gitlab.host}/#{project.full_path}/-/merge_requests/new?merge_request%5Bsource_branch%5D=#{branch_name}
+ MESSAGE
+
+ expect(subject).to include(build_basic_message(message))
+ end
+
+ it 'returns the link to an existing merge request when it exists' do
+ merge_request = create(:merge_request, source_project: project, source_branch: branch_name, target_branch: 'master')
+ message = <<~MESSAGE.strip
+ View merge request for feature:
+ #{project_merge_request_url(project, merge_request)}
+ MESSAGE
+
+ expect(subject).to include(build_basic_message(message))
+ end
+
+ context 'when printing_merge_request_link_enabled is false' do
+ let(:project) { create(:project, printing_merge_request_link_enabled: false) }
+
+ it 'returns no merge request messages' do
+ expect(subject).to be_blank
+ end
+ end
+
+ it 'does not invoke MergeRequests::PushOptionsHandlerService' do
+ expect(MergeRequests::PushOptionsHandlerService).not_to receive(:new)
+
+ subject
+ end
+
+ context 'when there are merge_request push options' do
+ let(:params) { super().merge(push_options: ['merge_request.create']) }
+
+ before do
+ project.add_developer(user)
+ end
+
+ it 'invokes MergeRequests::PushOptionsHandlerService' do
+ expect(MergeRequests::PushOptionsHandlerService).to receive(:new).and_call_original
+
+ subject
+ end
+
+ it 'creates a new merge request' do
+ expect { Sidekiq::Testing.fake! { subject } }.to change(MergeRequest, :count).by(1)
+ end
+
+ it 'links to the newly created merge request' do
+ message = <<~MESSAGE.strip
+ View merge request for #{branch_name}:
+ http://#{Gitlab.config.gitlab.host}/#{project.full_path}/-/merge_requests/1
+ MESSAGE
+
+ expect(subject).to include(build_basic_message(message))
+ end
+
+ it 'adds errors on the service instance to warnings' do
+ expect_any_instance_of(
+ MergeRequests::PushOptionsHandlerService
+ ).to receive(:errors).at_least(:once).and_return(['my error'])
+
+ message = "WARNINGS:\nError encountered with push options 'merge_request.create': my error"
+
+ expect(subject).to include(build_alert_message(message))
+ end
+
+ it 'adds ActiveRecord errors on invalid MergeRequest records to warnings' do
+ invalid_merge_request = MergeRequest.new
+ invalid_merge_request.errors.add(:base, 'my error')
+ message = "WARNINGS:\nError encountered with push options 'merge_request.create': my error"
+
+ expect_any_instance_of(
+ MergeRequests::CreateService
+ ).to receive(:execute).and_return(invalid_merge_request)
+
+ expect(subject).to include(build_alert_message(message))
+ end
+ end
+
+ context 'broadcast message exists' do
+ it 'outputs a broadcast message' do
+ broadcast_message = create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now)
+
+ expect(subject).to include(build_alert_message(broadcast_message.message))
+ end
+ end
+
+ context 'broadcast message does not exist' do
+ it 'does not output a broadcast message' do
+ expect(has_alert_messages?(subject)).to be_falsey
+ end
+ end
+
+ context 'nil broadcast message' do
+ it 'does not output a broadcast message' do
+ allow(BroadcastMessage).to receive(:current).and_return(nil)
+
+ expect(has_alert_messages?(subject)).to be_falsey
+ end
+ end
+
+ context 'with a redirected data' do
+ it 'returns redirected message on the response' do
+ project_moved = Gitlab::Checks::ProjectMoved.new(project, user, 'http', 'foo/baz')
+ project_moved.add_message
+
+ expect(subject).to include(build_basic_message(project_moved.message))
+ end
+ end
+
+ context 'with new project data' do
+ it 'returns new project message on the response' do
+ project_created = Gitlab::Checks::ProjectCreated.new(project, user, 'http')
+ project_created.add_message
+
+ expect(subject).to include(build_basic_message(project_created.message))
+ end
+ end
+
+ def build_alert_message(message)
+ { 'type' => 'alert', 'message' => message }
+ end
+
+ def build_basic_message(message)
+ { 'type' => 'basic', 'message' => message }
+ end
+
+ def has_alert_messages?(messages)
+ messages.any? do |message|
+ message['type'] == 'alert'
+ end
+ end
+end
diff --git a/spec/support/shared_examples/lib/gitlab/background_migration/mentions_migration_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/background_migration/mentions_migration_shared_examples.rb
index f90e1a1ebab..60c0ec45c71 100644
--- a/spec/support/shared_examples/lib/gitlab/background_migration/mentions_migration_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/background_migration/mentions_migration_shared_examples.rb
@@ -26,16 +26,18 @@ shared_examples 'resource notes mentions migration' do |migration_class, resourc
note1.becomes(Note).save!
note2.becomes(Note).save!
note3.becomes(Note).save!
- # note4.becomes(Note).save(validate: false)
+ note4.becomes(Note).save!
+ note5.becomes(Note).save(validate: false)
end
it 'migrates mentions from note' do
join = migration_class::JOIN
conditions = migration_class::QUERY_CONDITIONS
- # there are 4 notes for each noteable_type, but one does not have mentions and
+ # there are 5 notes for each noteable_type, but two do not have mentions and
# another one's noteable_id points to an inexistent resource
- expect(notes.where(noteable_type: resource_class.to_s).count).to eq 4
+ expect(notes.where(noteable_type: resource_class.to_s).count).to eq 5
+ expect(user_mentions.count).to eq 0
expect do
subject.perform(resource_class.name, join, conditions, true, Note.minimum(:id), Note.maximum(:id))