diff --git a/.gitlab/ci/base.yml b/.gitlab/ci/base.yml index 91bd7cad8..9f5c65042 100644 --- a/.gitlab/ci/base.yml +++ b/.gitlab/ci/base.yml @@ -38,6 +38,14 @@ variables: APP_RESTART_CMD: "bundle exec rake environment zammad:ci:app:restart" +.variables_rspec_slicing: &variables_rspec_slicing + variables: + RSPEC_EXAMPLE_MATCHES: "." # Default: all. Set this to one of the slices in a job to run only that slice. + RSPEC_EXAMPLE_SLICE_1_OF_4: "^[A-H]" + RSPEC_EXAMPLE_SLICE_2_OF_4: "^[I-P]" + RSPEC_EXAMPLE_SLICE_3_OF_4: "^[Q-S]" + RSPEC_EXAMPLE_SLICE_4_OF_4: "^[^A-S]" # Rest, including lower case and other characters like '#' + .rules_singletest: &rules_singletest rules: - if: $CI_MERGE_REQUEST_ID diff --git a/.gitlab/ci/browser-core.yml b/.gitlab/ci/browser-core.yml index 8ff3dd763..12ac1ca86 100644 --- a/.gitlab/ci/browser-core.yml +++ b/.gitlab/ci/browser-core.yml @@ -82,11 +82,13 @@ include: extends: - .env_base - .variables_es + - .variables_rspec_slicing variables: RAILS_ENV: "test" script: - bundle exec rake zammad:ci:test:prepare - - bundle exec rspec --fail-fast -t type:system -t ~integration + - echo "RSpec filter:" "$RSPEC_EXAMPLE_MATCHES" + - bundle exec rspec --require ./spec/rspec_extensions.rb --example-matches "$RSPEC_EXAMPLE_MATCHES" --fail-fast -t ~integration --profile 10 spec/system .template_browser-core_capybara_chrome: &template_browser-core_capybara_chrome extends: diff --git a/.gitlab/ci/browser-core/capybara_chrome.yml b/.gitlab/ci/browser-core/capybara_chrome.yml index c9b64d1d1..2fe52932a 100644 --- a/.gitlab/ci/browser-core/capybara_chrome.yml +++ b/.gitlab/ci/browser-core/capybara_chrome.yml @@ -1,3 +1,23 @@ -capybara_chrome: +capybara:chrome:1: extends: - .template_browser-core_capybara_chrome + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_1_OF_4 + +capybara:chrome:2: + extends: + - .template_browser-core_capybara_chrome + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_2_OF_4 + +capybara:chrome:3: + extends: + - .template_browser-core_capybara_chrome + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_3_OF_4 + +capybara:chrome:4: + extends: + - .template_browser-core_capybara_chrome + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_4_OF_4 diff --git a/.gitlab/ci/browser-core/capybara_ff.yml b/.gitlab/ci/browser-core/capybara_ff.yml index 8aef82b3c..e8b897aa9 100644 --- a/.gitlab/ci/browser-core/capybara_ff.yml +++ b/.gitlab/ci/browser-core/capybara_ff.yml @@ -1,3 +1,23 @@ -capybara_ff: +capybara:firefox:1: extends: - .template_browser-core_capybara_firefox + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_1_OF_4 + +capybara:firefox:2: + extends: + - .template_browser-core_capybara_firefox + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_2_OF_4 + +capybara:firefox:3: + extends: + - .template_browser-core_capybara_firefox + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_3_OF_4 + +capybara:firefox:4: + extends: + - .template_browser-core_capybara_firefox + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_4_OF_4 diff --git a/.gitlab/ci/browser-integration.yml b/.gitlab/ci/browser-integration.yml index cfd50b0c3..88ed70398 100644 --- a/.gitlab/ci/browser-integration.yml +++ b/.gitlab/ci/browser-integration.yml @@ -18,7 +18,7 @@ include: RAILS_ENV: "test" script: - bundle exec rake zammad:ci:test:prepare - - bundle exec rspec --fail-fast --pattern "spec/system/**/*_spec.rb" -t integration + - bundle exec rspec --fail-fast --pattern "spec/system/**/*_spec.rb" -t integration --profile 10 .template_browser-integration_capybara_chrome: &template_browser-integration_capybara_chrome extends: diff --git a/.gitlab/ci/integration/es.yml b/.gitlab/ci/integration/es.yml index 6b0675201..79464bddf 100644 --- a/.gitlab/ci/integration/es.yml +++ b/.gitlab/ci/integration/es.yml @@ -10,7 +10,7 @@ - bundle exec rake zammad:db:unseeded - bundle exec rails test test/integration/elasticsearch_active_test.rb - bundle exec rails test test/integration/elasticsearch_test.rb - - bundle exec rspec --tag searchindex --tag ~type:system + - bundle exec rspec --tag searchindex --tag ~type:system --profile 10 - bundle exec rails test test/integration/report_test.rb es:7: diff --git a/.gitlab/ci/rspec.yml b/.gitlab/ci/rspec.yml index 9f2181835..656916c9b 100644 --- a/.gitlab/ci/rspec.yml +++ b/.gitlab/ci/rspec.yml @@ -5,20 +5,11 @@ include: .template_rspec: &template_rspec extends: - .env_base - variables: - RAILS_ENV: "test" + - .variables_rspec_slicing script: - bundle exec rake zammad:db:init - - bundle exec rspec --exclude-pattern "spec/{system,integration}/**/*_spec.rb" -t ~searchindex -t ~db_strategy:reset - -.template_rspec_db_reset: &template_rspec_db_reset - extends: - - .env_base - variables: - RAILS_ENV: "test" - script: - - bundle exec rake zammad:db:init - - bundle exec rspec --exclude-pattern "spec/{system,integration}/**/*_spec.rb" -t ~searchindex -t db_strategy:reset + - echo "RSpec filter:" "$RSPEC_EXAMPLE_MATCHES" + - bundle exec rspec --require ./spec/rspec_extensions.rb --example-matches "$RSPEC_EXAMPLE_MATCHES" --exclude-pattern "spec/{system,integration}/**/*_spec.rb" -t ~searchindex --profile 10 # RSpec 3rd party integration tests are independent of the database # therefore we need only one job and choose a random database for each run @@ -41,4 +32,4 @@ rspec:integration: - when: always script: - bundle exec rake zammad:db:init - - bundle exec rspec -t type:integration + - bundle exec rspec -t type:integration --profile 10 diff --git a/.gitlab/ci/rspec/mysql.yml b/.gitlab/ci/rspec/mysql.yml index 2a6312169..576a344f7 100644 --- a/.gitlab/ci/rspec/mysql.yml +++ b/.gitlab/ci/rspec/mysql.yml @@ -1,11 +1,31 @@ -rspec:mysql: +rspec:mysql:1: stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_1_OF_4 extends: - .services_mysql_redis_memcached - .template_rspec -rspec:mysql:db_reset: +rspec:mysql:2: stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_2_OF_4 extends: - .services_mysql_redis_memcached - - .template_rspec_db_reset + - .template_rspec + +rspec:mysql:3: + stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_3_OF_4 + extends: + - .services_mysql_redis_memcached + - .template_rspec + +rspec:mysql:4: + stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_4_OF_4 + extends: + - .services_mysql_redis_memcached + - .template_rspec diff --git a/.gitlab/ci/rspec/postgresql.yml b/.gitlab/ci/rspec/postgresql.yml index ed20db802..66c9ab3ec 100644 --- a/.gitlab/ci/rspec/postgresql.yml +++ b/.gitlab/ci/rspec/postgresql.yml @@ -1,11 +1,31 @@ -rspec:postgresql: +rspec:postgresql:1: stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_1_OF_4 extends: - .services_postgresql_redis_memcached - .template_rspec -rspec:postgresql:db_reset: +rspec:postgresql:2: stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_2_OF_4 extends: - .services_postgresql_redis_memcached - - .template_rspec_db_reset + - .template_rspec + +rspec:postgresql:3: + stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_3_OF_4 + extends: + - .services_postgresql_redis_memcached + - .template_rspec + +rspec:postgresql:4: + stage: test + variables: + RSPEC_EXAMPLE_MATCHES: $RSPEC_EXAMPLE_SLICE_4_OF_4 + extends: + - .services_postgresql_redis_memcached + - .template_rspec diff --git a/spec/rspec_extensions.rb b/spec/rspec_extensions.rb new file mode 100644 index 000000000..aad7445c1 --- /dev/null +++ b/spec/rspec_extensions.rb @@ -0,0 +1,10 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +# Small patch for rspec: don't treat --example-matches/-E as a standalone +# filter that suppresses other exclusion filters, but combine all filters instead. +require 'rspec/core/filter_manager' +class RSpec::Core::InclusionRules + def standalone? + false + end +end