Commit de99b7ba authored by Philippe Lafoucrière's avatar Philippe Lafoucrière Committed by Kamil Trzciński

Refactor except code

We repeat the same code in many places. With the support of multiple
extends, we can clean up several jobs.
parent 055ed2e8
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
# Trigger a manual docs build in gitlab-docs only on non docs-only branches. # Trigger a manual docs build in gitlab-docs only on non docs-only branches.
# Useful to preview the docs changes live. # Useful to preview the docs changes live.
review-docs-deploy-manual: review-docs-deploy-manual:
<<: *review-docs extends:
- .review-docs
- .no-docs-and-no-qa
stage: build stage: build
script: script:
- gem install gitlab --no-document - gem install gitlab --no-document
...@@ -21,9 +23,6 @@ review-docs-deploy-manual: ...@@ -21,9 +23,6 @@ review-docs-deploy-manual:
only: only:
- branches@gitlab-org/gitlab-ce - branches@gitlab-org/gitlab-ce
- branches@gitlab-org/gitlab-ee - branches@gitlab-org/gitlab-ee
except:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
# Always trigger a docs build in gitlab-docs only on docs-only branches. # Always trigger a docs build in gitlab-docs only on docs-only branches.
# Useful to preview the docs changes live. # Useful to preview the docs changes live.
......
...@@ -70,9 +70,10 @@ gitlab:assets:compile pull-cache: ...@@ -70,9 +70,10 @@ gitlab:assets:compile pull-cache:
cache: cache:
policy: pull policy: pull
except: except:
- master@gitlab-org/gitlab-ce refs:
- master@gitlab-org/gitlab-ee - master@gitlab-org/gitlab-ce
- /(^docs[\/-].*|.*-docs$)/ - master@gitlab-org/gitlab-ee
- /(^docs[\/-].*|.*-docs$)/
.compile-assets-metadata: .compile-assets-metadata:
extends: .dedicated-runner extends: .dedicated-runner
...@@ -107,9 +108,10 @@ compile-assets pull-cache: ...@@ -107,9 +108,10 @@ compile-assets pull-cache:
cache: cache:
policy: pull policy: pull
except: except:
- master@gitlab-org/gitlab-ce refs:
- master@gitlab-org/gitlab-ee - master@gitlab-org/gitlab-ce
- /(^docs[\/-].*|.*-docs$)/ - master@gitlab-org/gitlab-ee
- /(^docs[\/-].*|.*-docs$)/
gitlab:ui:visual: gitlab:ui:visual:
extends: .dedicated-runner extends: .dedicated-runner
......
...@@ -30,7 +30,14 @@ ...@@ -30,7 +30,14 @@
.no-docs: .no-docs:
except: except:
- /(^docs[\/-].*|.*-docs$)/ refs:
- /(^docs[\/-].*|.*-docs$)/
.no-docs-and-no-qa:
except:
refs:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
.dedicated-no-docs-pull-cache-job: .dedicated-no-docs-pull-cache-job:
extends: extends:
...@@ -38,10 +45,9 @@ ...@@ -38,10 +45,9 @@
- .no-docs - .no-docs
.dedicated-no-docs-and-no-qa-pull-cache-job: .dedicated-no-docs-and-no-qa-pull-cache-job:
extends: .dedicated-pull-cache-job extends:
except: - .dedicated-pull-cache-job
- /(^docs[\/-].*|.*-docs$)/ - .no-docs-and-no-qa
- /(^qa[\/-].*|.*-qa$)/
# Jobs that do not need a DB # Jobs that do not need a DB
.dedicated-no-docs-no-db-pull-cache-job: .dedicated-no-docs-no-db-pull-cache-job:
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
- master@gitlab/gitlab-ee - master@gitlab/gitlab-ee
.gitlab-setup: &gitlab-setup .gitlab-setup: &gitlab-setup
extends: .dedicated-no-docs-and-no-qa-pull-cache-job extends:
<<: *use-pg - .dedicated-no-docs-and-no-qa-pull-cache-job
- .use-pg
variables: variables:
SETUP_DB: "false" SETUP_DB: "false"
script: script:
...@@ -43,7 +44,9 @@ ...@@ -43,7 +44,9 @@
- bundle exec rake $CI_JOB_NAME - bundle exec rake $CI_JOB_NAME
.rspec-metadata: &rspec-metadata .rspec-metadata: &rspec-metadata
extends: .dedicated-pull-cache-job extends:
- .dedicated-pull-cache-job
- .no-docs-and-no-qa
stage: test stage: test
script: script:
- JOB_NAME=( $CI_JOB_NAME ) - JOB_NAME=( $CI_JOB_NAME )
...@@ -76,9 +79,6 @@ ...@@ -76,9 +79,6 @@
- tmp/capybara/ - tmp/capybara/
reports: reports:
junit: junit_rspec.xml junit: junit_rspec.xml
except:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
.rspec-metadata-pg: &rspec-metadata-pg .rspec-metadata-pg: &rspec-metadata-pg
<<: *rspec-metadata <<: *rspec-metadata
...@@ -122,8 +122,10 @@ ...@@ -122,8 +122,10 @@
- setup-test-env - setup-test-env
setup-test-env: setup-test-env:
extends: .dedicated-runner-default-cache extends:
<<: *use-pg - .dedicated-runner-default-cache
- .no-docs
- .use-pg
stage: prepare stage: prepare
script: script:
- bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init' - bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init'
...@@ -134,8 +136,6 @@ setup-test-env: ...@@ -134,8 +136,6 @@ setup-test-env:
- tmp/tests - tmp/tests
- config/secrets.yml - config/secrets.yml
- vendor/gitaly-ruby - vendor/gitaly-ruby
except:
- /(^docs[\/-].*|.*-docs$)/
rspec unit pg: rspec unit pg:
<<: *rspec-metadata-pg <<: *rspec-metadata-pg
...@@ -200,11 +200,12 @@ static-analysis: ...@@ -200,11 +200,12 @@ static-analysis:
downtime_check: downtime_check:
<<: *rake-exec <<: *rake-exec
except: except:
- master refs:
- tags - master
- /^[\d-]+-stable(-ee)?$/ - tags
- /(^docs[\/-].*|.*-docs$)/ - /^[\d-]+-stable(-ee)?$/
- /(^qa[\/-].*|.*-qa$)/ - /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
dependencies: dependencies:
- setup-test-env - setup-test-env
...@@ -212,12 +213,13 @@ ee_compat_check: ...@@ -212,12 +213,13 @@ ee_compat_check:
<<: *rake-exec <<: *rake-exec
dependencies: [] dependencies: []
except: except:
- master refs:
- tags - master
- /[\d-]+-stable(-ee)?/ - tags
- /^security-/ - /[\d-]+-stable(-ee)?/
- branches@gitlab-org/gitlab-ee - /^security-/
- branches@gitlab/gitlab-ee - branches@gitlab-org/gitlab-ee
- branches@gitlab/gitlab-ee
retry: 0 retry: 0
artifacts: artifacts:
name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}" name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}"
...@@ -261,7 +263,9 @@ gitlab:setup-pg: ...@@ -261,7 +263,9 @@ gitlab:setup-pg:
coverage: coverage:
# Don't include dedicated-no-docs-no-db-pull-cache-job here since we need to # Don't include dedicated-no-docs-no-db-pull-cache-job here since we need to
# download artifacts from all the rspec jobs instead of from setup-test-env only # download artifacts from all the rspec jobs instead of from setup-test-env only
extends: .dedicated-runner-default-cache extends:
- .dedicated-runner-default-cache
- .no-docs-and-no-qa
cache: cache:
policy: pull policy: pull
variables: variables:
...@@ -276,6 +280,3 @@ coverage: ...@@ -276,6 +280,3 @@ coverage:
paths: paths:
- coverage/index.html - coverage/index.html
- coverage/assets/ - coverage/assets/
except:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
...@@ -15,7 +15,9 @@ cache gems: ...@@ -15,7 +15,9 @@ cache gems:
- setup-test-env - setup-test-env
gitlab_git_test: gitlab_git_test:
extends: .dedicated-runner extends:
- .dedicated-runner
- .no-docs-and-no-qa
variables: variables:
SETUP_DB: "false" SETUP_DB: "false"
before_script: [] before_script: []
...@@ -23,12 +25,11 @@ gitlab_git_test: ...@@ -23,12 +25,11 @@ gitlab_git_test:
cache: {} cache: {}
script: script:
- spec/support/prepare-gitlab-git-test-for-commit --check-for-changes - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes
except:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
no_ee_check: no_ee_check:
extends: .dedicated-runner extends:
- .dedicated-runner
- .no-docs-and-no-qa
variables: variables:
SETUP_DB: "false" SETUP_DB: "false"
before_script: [] before_script: []
...@@ -38,6 +39,3 @@ no_ee_check: ...@@ -38,6 +39,3 @@ no_ee_check:
- scripts/no-ee-check - scripts/no-ee-check
only: only:
- /.+/@gitlab-org/gitlab-ce - /.+/@gitlab-org/gitlab-ce
except:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
- rspec_profiling/ - rspec_profiling/
retrieve-tests-metadata: retrieve-tests-metadata:
<<: *tests-metadata-state extends:
- .tests-metadata-state
- .no-docs-and-no-qa
stage: prepare stage: prepare
cache: cache:
key: tests_metadata key: tests_metadata
...@@ -25,9 +27,6 @@ retrieve-tests-metadata: ...@@ -25,9 +27,6 @@ retrieve-tests-metadata:
- mkdir -p rspec_profiling/ - mkdir -p rspec_profiling/
- wget -O $FLAKY_RSPEC_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$FLAKY_RSPEC_SUITE_REPORT_PATH || rm $FLAKY_RSPEC_SUITE_REPORT_PATH - wget -O $FLAKY_RSPEC_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$FLAKY_RSPEC_SUITE_REPORT_PATH || rm $FLAKY_RSPEC_SUITE_REPORT_PATH
- '[[ -f $FLAKY_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_SUITE_REPORT_PATH}' - '[[ -f $FLAKY_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_SUITE_REPORT_PATH}'
except:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
update-tests-metadata: update-tests-metadata:
<<: *tests-metadata-state <<: *tests-metadata-state
...@@ -69,9 +68,10 @@ flaky-examples-check: ...@@ -69,9 +68,10 @@ flaky-examples-check:
only: only:
- branches - branches
except: except:
- master refs:
- /(^docs[\/-].*|.*-docs$)/ - master
- /(^qa[\/-].*|.*-qa$)/ - /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
artifacts: artifacts:
expire_in: 30d expire_in: 30d
paths: paths:
......
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