Commit 163a7046 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 0637ba1e
......@@ -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
......
# 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
# 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
# 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
......
# 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:
......
# 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"
......
......@@ -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
# 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
......
# 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:
......
# 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
# 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:
......
.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.
......
# 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"
# 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
......
This diff is collapsed.
# 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:
......
# 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"
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
- page_title _("Container Registry")
- @content_class = "limit-container-width" unless fluid_layout
%section
.row.registry-placeholder.prepend-bottom-10
......
- page_title _("Container Registry")
- @content_class = "limit-container-width" unless fluid_layout
%section
.row.registry-placeholder.prepend-bottom-10
......
---
title: Migrate mentions for design notes to design_user_mentions DB table
merge_request: 23704
author:
type: changed
---
title: Require a logged in user to accept or decline a term
merge_request: 24771
author:
type: fixed
---
title: Add accessibility scanning CI template
merge_request: 25144
author:
type: added
---
title: Move namespace of Secure Sidekiq queues
merge_request: 24340
author:
type: other
---
title: Drop etag cache on logs API
merge_request: 24864
author:
type: fixed
# 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
......@@ -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
......
......@@ -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
This diff is collapsed.
......@@ -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):
......
......@@ -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:**
......
......@@ -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
......
---
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.
......@@ -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. |
......
......@@ -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(
......
......@@ -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
......
# 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
# 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
# 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
......@@ -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))
......
......@@ -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
......
......@@ -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
......@@ -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') }
......
......@@ -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)
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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 }
......
......@@ -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
......
......@@ -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
......
......@@ -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')
......
......@@ -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)
......
......@@ -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 }
......
......@@ -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
......@@ -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
......@@ -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 }
......
......@@ -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
......
......@@ -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) }
......
......@@ -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
......
......@@ -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) }
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
# 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
......@@ -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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment