Commit 19a339be authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '31648-use-rules-iteration-1' into 'master'

Start to use the 'rules' keyword for the 'package-and-qa' job

See merge request gitlab-org/gitlab!21945
parents 5e9840d7 1b7b3d05
# 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: .qa-job-base:
extends: extends:
- .default-tags - .default-tags
...@@ -40,23 +65,15 @@ qa:selectors-foss: ...@@ -40,23 +65,15 @@ qa:selectors-foss:
- install_gitlab_gem - install_gitlab_gem
- ./scripts/trigger-build omnibus - ./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: package-and-qa:
extends: extends: .package-and-qa-base
- .package-and-qa-base rules:
- .default-only - <<: *if-canonical-gitlab-and-merge-request
- .only:variables-canonical-dot-com changes: *qa-patterns
- .except:refs-master-tags-stable-deploy when: on_success
- .only:changes-qa - <<: *if-canonical-gitlab-and-merge-request
changes: *code-patterns
when: manual
needs: ["build-qa-image", "gitlab:assets:compile pull-cache"] needs: ["build-qa-image", "gitlab:assets:compile pull-cache"]
allow_failure: true allow_failure: true
......
# 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: .review-docker:
extends: extends:
- .default-tags - .default-tags
- .default-retry - .default-retry
- .default-only
image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa-alpine image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa-alpine
services: services:
- docker:19.03.0-dind - docker:19.03.0-dind
...@@ -15,12 +41,12 @@ ...@@ -15,12 +41,12 @@
GITLAB_EDITION: "ce" GITLAB_EDITION: "ce"
build-qa-image: build-qa-image:
extends: extends: .review-docker
- .review-docker
- .only:variables-canonical-dot-com
- .except:refs-deploy
- .only:changes-code-qa
stage: prepare stage: prepare
rules:
- <<: *if-canonical-gitlab
changes: *code-qa-patterns
when: on_success
script: script:
- '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"' - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"'
- export QA_MASTER_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:master" - export QA_MASTER_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:master"
...@@ -173,11 +199,10 @@ review-stop: ...@@ -173,11 +199,10 @@ review-stop:
- delete_release - delete_release
.review-qa-base: .review-qa-base:
extends: extends: .review-docker
- .review-docker
- .only-review
- .only:changes-code-qa
stage: qa stage: qa
needs: ["review-deploy"]
dependencies: ["review-deploy"]
allow_failure: true allow_failure: true
variables: variables:
QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa" QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa"
...@@ -189,13 +214,6 @@ review-stop: ...@@ -189,13 +214,6 @@ review-stop:
GITLAB_ADMIN_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}" GITLAB_ADMIN_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}"
GITHUB_ACCESS_TOKEN: "${REVIEW_APPS_QA_GITHUB_ACCESS_TOKEN}" GITHUB_ACCESS_TOKEN: "${REVIEW_APPS_QA_GITHUB_ACCESS_TOKEN}"
EE_LICENSE: "${REVIEW_APPS_EE_LICENSE}" 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: before_script:
- '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"' - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"'
- export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}" - export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}"
...@@ -205,14 +223,26 @@ review-stop: ...@@ -205,14 +223,26 @@ review-stop:
- source scripts/utils.sh - source scripts/utils.sh
- install_api_client_dependencies_with_apk - install_api_client_dependencies_with_apk
- gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}} - 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: review-qa-smoke:
extends: .review-qa-base extends: .review-qa-base
rules:
- <<: *if-canonical-gitlab-and-merge-request
changes: *code-qa-patterns
when: on_success
script: script:
- gitlab-qa Test::Instance::Smoke "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}" - gitlab-qa Test::Instance::Smoke "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}"
review-qa-all: review-qa-all:
extends: .review-qa-base extends: .review-qa-base
rules:
- <<: *if-canonical-gitlab-and-merge-request
changes: *code-qa-patterns
when: manual when: manual
parallel: 5 parallel: 5
script: script:
......
...@@ -129,6 +129,64 @@ from a commit or MR by extending from the following CI definitions: ...@@ -129,6 +129,64 @@ from a commit or MR by extending from the following CI definitions:
**See <https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/ci/global.gitlab-ci.yml> **See <https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/ci/global.gitlab-ci.yml>
for the list of exact patterns.** 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 ## Directed acyclic graph
We're using the [`needs:`](../ci/yaml/README.md#needs) keyword to We're using the [`needs:`](../ci/yaml/README.md#needs) keyword to
......
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