From 33e1622bfe5afb2eea08ff06e44de490383a93e3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 23 Dec 2019 21:07:52 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .gitlab/ci/qa.gitlab-ci.yml | 49 ++++++++++++++++-------- .gitlab/ci/review.gitlab-ci.yml | 66 ++++++++++++++++++++++++--------- app/models/project.rb | 4 -- doc/development/pipelines.md | 58 +++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 38 deletions(-) diff --git a/.gitlab/ci/qa.gitlab-ci.yml b/.gitlab/ci/qa.gitlab-ci.yml index 3cb5a40a8b5..e9a3cd0da90 100644 --- a/.gitlab/ci/qa.gitlab-ci.yml +++ b/.gitlab/ci/qa.gitlab-ci.yml @@ -1,3 +1,28 @@ +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-canonical-gitlab-and-merge-request: &if-canonical-gitlab-and-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-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/**/*" + .qa-job-base: extends: - .default-tags @@ -40,23 +65,15 @@ qa:selectors-foss: - install_gitlab_gem - ./scripts/trigger-build omnibus -package-and-qa-manual: - extends: - - .package-and-qa-base - - .default-only - - .only:variables-canonical-dot-com - - .except:refs-deploy - - .only:changes-code - when: manual - needs: ["build-qa-image", "gitlab:assets:compile pull-cache"] - package-and-qa: - extends: - - .package-and-qa-base - - .default-only - - .only:variables-canonical-dot-com - - .except:refs-master-tags-stable-deploy - - .only:changes-qa + extends: .package-and-qa-base + rules: + - <<: *if-canonical-gitlab-and-merge-request + changes: *qa-patterns + when: on_success + - <<: *if-canonical-gitlab-and-merge-request + changes: *code-patterns + when: manual needs: ["build-qa-image", "gitlab:assets:compile pull-cache"] allow_failure: true diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml index 1062f6b03a4..7e0759b3c85 100644 --- a/.gitlab/ci/review.gitlab-ci.yml +++ b/.gitlab/ci/review.gitlab-ci.yml @@ -1,8 +1,34 @@ +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-canonical-gitlab: &if-canonical-gitlab + if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/' + +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-canonical-gitlab-and-merge-request: &if-canonical-gitlab-and-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-docker: extends: - .default-tags - .default-retry - - .default-only image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa-alpine services: - docker:19.03.0-dind @@ -15,12 +41,12 @@ GITLAB_EDITION: "ce" build-qa-image: - extends: - - .review-docker - - .only:variables-canonical-dot-com - - .except:refs-deploy - - .only:changes-code-qa + extends: .review-docker stage: prepare + rules: + - <<: *if-canonical-gitlab + changes: *code-qa-patterns + when: on_success script: - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"' - export QA_MASTER_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:master" @@ -173,11 +199,10 @@ review-stop: - delete_release .review-qa-base: - extends: - - .review-docker - - .only-review - - .only:changes-code-qa + extends: .review-docker stage: qa + needs: ["review-deploy"] + dependencies: ["review-deploy"] allow_failure: true variables: QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa" @@ -189,13 +214,6 @@ review-stop: GITLAB_ADMIN_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}" GITHUB_ACCESS_TOKEN: "${REVIEW_APPS_QA_GITHUB_ACCESS_TOKEN}" EE_LICENSE: "${REVIEW_APPS_EE_LICENSE}" - needs: ["review-deploy"] - dependencies: ["review-deploy"] - artifacts: - paths: - - ./qa/gitlab-qa-run-* - expire_in: 7 days - when: always before_script: - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"' - export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}" @@ -205,15 +223,27 @@ review-stop: - source scripts/utils.sh - install_api_client_dependencies_with_apk - gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}} + artifacts: + paths: + - ./qa/gitlab-qa-run-* + expire_in: 7 days + when: always review-qa-smoke: extends: .review-qa-base + rules: + - <<: *if-canonical-gitlab-and-merge-request + changes: *code-qa-patterns + when: on_success script: - gitlab-qa Test::Instance::Smoke "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}" review-qa-all: extends: .review-qa-base - when: manual + rules: + - <<: *if-canonical-gitlab-and-merge-request + changes: *code-qa-patterns + when: manual parallel: 5 script: - export KNAPSACK_REPORT_PATH=knapsack/master_report.json diff --git a/app/models/project.rb b/app/models/project.rb index 9062377943f..ba30a1f586a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -63,10 +63,6 @@ class Project < ApplicationRecord cache_markdown_field :description, pipeline: :description - # TODO: remove once GitLab 12.5 is released - # https://gitlab.com/gitlab-org/gitlab/issues/34638 - ignore_column :merge_requests_require_code_owner_approval, remove_after: '2019-12-01', remove_with: '12.6' - default_value_for :archived, false default_value_for :resolve_outdated_diff_discussions, false default_value_for :container_registry_enabled, gitlab_config_features.container_registry diff --git a/doc/development/pipelines.md b/doc/development/pipelines.md index 99f92e6f39f..b959240cae2 100644 --- a/doc/development/pipelines.md +++ b/doc/development/pipelines.md @@ -129,6 +129,64 @@ from a commit or MR by extending from the following CI definitions: **See for the list of exact patterns.** +## Rules conditions and changes patterns + +We're making use of the [`rules` keyword](https://docs.gitlab.com/ee/ci/yaml/#rules) but we're currently +duplicating the `if` conditions and `changes` patterns lists since they cannot be shared accross +`include`d files as we do with `extends`. + +**If you update an `if` condition or `changes` +patterns list, make sure to mass-update those accross all the CI config files (i.e. `.gitlab/ci/*.yml`).** + +### Canonical commits only + +This condition limits jobs creation to commits under the `gitlab-org/` top-level group +on GitLab.com only. This is similar to the `.only:variables-canonical-dot-com` CI definition: + +```yaml +.if-canonical-gitlab: &if-canonical-gitlab + if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/' +``` + +### Canonical merge requests only + +Same as the "Canonical commits only" condition above but further limits jobs creation +to merge requests only (i.e. this won't run for `master`, stable or auto-deploy branches). +This is similar to the `.only:variables-canonical-dot-com` + `.except:refs-master-tags-stable-deploy` +CI definitions: + +```yaml +.if-canonical-gitlab-and-merge-request: &if-canonical-gitlab-and-merge-request + if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/ && $CI_MERGE_REQUEST_IID' +``` + +### Code changes patterns + +Similar patterns as for `.only:changes-code`: + +```yaml +.code-patterns: &code-patterns + - ... +``` + +### QA changes patterns + +Similar patterns as for `.only:changes-qa`: + +```yaml +.qa-patterns: &qa-patterns + - ... +``` + +### Code and QA changes patterns + +Similar patterns as for `.only:changes-code-qa`: + +```yaml +.code-qa-patterns: &code-qa-patterns + - ... +``` + ## Directed acyclic graph We're using the [`needs:`](../ci/yaml/README.md#needs) keyword to