Refactoring: Use GitLab CI cache functionality to cache gem dependencies between pipelines/jobs/runners and replace obsolete zammad-application with zammad-ruby docker image.

This commit is contained in:
Thorsten Eckel 2019-01-05 23:43:22 +01:00
parent 4d0130810f
commit 8df6e3c33b

View file

@ -1,4 +1,4 @@
image: registry.znuny.com/docker/zammad-application:latest image: registry.znuny.com/docker/zammad-ruby:2.4.4
# Global variables added to the ENV of each job # Global variables added to the ENV of each job
variables: variables:
@ -47,11 +47,18 @@ variables:
- name: registry.znuny.com/docker/zammad-postgresql:latest - name: registry.znuny.com/docker/zammad-postgresql:latest
alias: postgresql alias: postgresql
# Initialize env # Cache gems in between jobs and pipelines
before_script: cache:
- test ${CI_JOB_STAGE} != 'pre' && bundle install -j $(nproc) key: "ruby24"
- test ${CI_JOB_STAGE} != 'pre' && ruby script/build/database_config.rb paths:
- vendor/ruby
# Initialize application env
before_script:
- bundle install -j $(nproc) --path vendor
- bundle exec ruby script/build/database_config.rb
# Stages
stages: stages:
- pre - pre
- test - test
@ -64,11 +71,13 @@ stages:
.pre_stage_template: &pre_stage .pre_stage_template: &pre_stage
<<: *docker_env <<: *docker_env
stage: pre stage: pre
before_script:
- '' # disable before_script for pre "non-application" env
pre:rubocop: pre:rubocop:
<<: *pre_stage <<: *pre_stage
script: script:
- bundle install -j $(nproc) - bundle install -j $(nproc) --path vendor
- bundle exec rubocop - bundle exec rubocop
pre:coffeelint: pre:coffeelint:
@ -99,7 +108,7 @@ pre:github:
variables: variables:
RAILS_ENV: "test" RAILS_ENV: "test"
script: script:
- rake zammad:db:init - bundle exec rake zammad:db:init
- bundle exec rspec -t ~type:system - bundle exec rspec -t ~type:system
test:rspec:mysql: test:rspec:mysql:
@ -119,10 +128,10 @@ test:rspec:postgresql:
variables: variables:
RAILS_ENV: "test" RAILS_ENV: "test"
script: script:
- rake zammad:db:init - bundle exec rake zammad:db:init
- rake test:units - bundle exec rake test:units
- ruby -I test/ test/integration/object_manager_test.rb - bundle exec ruby -I test/ test/integration/object_manager_test.rb
- ruby -I test/ test/integration/package_test.rb - bundle exec ruby -I test/ test/integration/package_test.rb
test:unit:mysql: test:unit:mysql:
stage: test stage: test
@ -146,48 +155,48 @@ test:unit:postgresql:
test:integration:email_helper_deliver: test:integration:email_helper_deliver:
<<: *test_integration_definition <<: *test_integration_definition
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- ruby -I test/ test/integration/email_helper_test.rb - bundle exec ruby -I test/ test/integration/email_helper_test.rb
- ruby -I test/ test/integration/email_deliver_test.rb - bundle exec ruby -I test/ test/integration/email_deliver_test.rb
- ruby -I test/ test/integration/email_keep_on_server_test.rb - bundle exec ruby -I test/ test/integration/email_keep_on_server_test.rb
test:integration:facebook: test:integration:facebook:
<<: *test_integration_definition <<: *test_integration_definition
script: script:
- rake zammad:db:init - bundle exec rake zammad:db:init
- ruby -I test/ test/integration/facebook_test.rb - bundle exec ruby -I test/ test/integration/facebook_test.rb
allow_failure: true allow_failure: true
test:integration:geo: test:integration:geo:
<<: *test_integration_definition <<: *test_integration_definition
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- ruby -I test/ test/integration/geo_calendar_test.rb - bundle exec ruby -I test/ test/integration/geo_calendar_test.rb
- ruby -I test/ test/integration/geo_location_test.rb - bundle exec ruby -I test/ test/integration/geo_location_test.rb
- ruby -I test/ test/integration/geo_ip_test.rb - bundle exec ruby -I test/ test/integration/geo_ip_test.rb
test:integration:user_agent: test:integration:user_agent:
<<: *test_integration_definition <<: *test_integration_definition
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- ruby -I test/ test/integration/user_agent_test.rb - bundle exec ruby -I test/ test/integration/user_agent_test.rb
- export ZAMMAD_PROXY_TEST=true - export ZAMMAD_PROXY_TEST=true
- ruby -I test/ test/integration/user_agent_test.rb - bundle exec ruby -I test/ test/integration/user_agent_test.rb
allow_failure: true allow_failure: true
test:integration:slack: test:integration:slack:
<<: *test_integration_definition <<: *test_integration_definition
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- echo "gem 'slack-api'" >> Gemfile.local - echo "gem 'slack-api'" >> Gemfile.local
- bundle install -j $(nproc) - bundle install -j $(nproc)
- ruby -I test test/integration/slack_test.rb - bundle exec ruby -I test test/integration/slack_test.rb
test:integration:clearbit: test:integration:clearbit:
<<: *test_integration_definition <<: *test_integration_definition
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- ruby -I test test/integration/clearbit_test.rb - bundle exec ruby -I test test/integration/clearbit_test.rb
allow_failure: true allow_failure: true
### Elasticsearch ### Elasticsearch
@ -200,10 +209,10 @@ test:integration:clearbit:
ES_INDEX_RAND: "true" ES_INDEX_RAND: "true"
ES_URL: "http://elasticsearch:9200" ES_URL: "http://elasticsearch:9200"
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- ruby -I test/ test/integration/elasticsearch_active_test.rb - bundle exec ruby -I test/ test/integration/elasticsearch_active_test.rb
- ruby -I test/ test/integration/elasticsearch_test.rb - bundle exec ruby -I test/ test/integration/elasticsearch_test.rb
- ruby -I test/ test/integration/report_test.rb - bundle exec ruby -I test/ test/integration/report_test.rb
- bundle exec rspec --tag searchindex - bundle exec rspec --tag searchindex
test:integration:es_mysql: test:integration:es_mysql:
@ -231,8 +240,8 @@ test:integration:es_postgresql:
variables: variables:
RAILS_ENV: "test" RAILS_ENV: "test"
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- ruby -I test/ test/integration/zendesk_import_test.rb - bundle exec ruby -I test/ test/integration/zendesk_import_test.rb
allow_failure: true allow_failure: true
test:integration:zendesk_mysql: test:integration:zendesk_mysql:
@ -249,8 +258,8 @@ test:integration:zendesk_postgresql:
<<: *base_env <<: *base_env
stage: test stage: test
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- ruby -I test/ test/integration/otrs_import_test.rb - bundle exec ruby -I test/ test/integration/otrs_import_test.rb
.variables_integration_otrs_6_template: &variables_integration_otrs_6_definition .variables_integration_otrs_6_template: &variables_integration_otrs_6_definition
variables: variables:
@ -313,8 +322,8 @@ browser:build:
variables: variables:
RAILS_ENV: "production" RAILS_ENV: "production"
script: script:
- rake zammad:db:unseeded - bundle exec rake zammad:db:unseeded
- rake assets:precompile - bundle exec rake assets:precompile
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
@ -350,7 +359,7 @@ browser:build:
<<: *base_env <<: *base_env
stage: browser-core stage: browser-core
script: script:
- rake zammad:ci:test:prepare[with_elasticsearch] - bundle exec rake zammad:ci:test:prepare[with_elasticsearch]
- bundle exec rspec --fail-fast -t type:system - bundle exec rspec --fail-fast -t type:system
.variables_capybara_chrome_template: &variables_capybara_chrome_definition .variables_capybara_chrome_template: &variables_capybara_chrome_definition
@ -387,7 +396,7 @@ test:browser:core:capybara_ff_mysql:
.variables_browser_template: &variables_browser_definition .variables_browser_template: &variables_browser_definition
RAILS_ENV: "production" RAILS_ENV: "production"
APP_RESTART_CMD: "rake zammad:ci:app:restart" APP_RESTART_CMD: "bundle exec rake zammad:ci:app:restart"
.test_browser_core_template: &test_browser_core_definition .test_browser_core_template: &test_browser_core_definition
<<: *base_env <<: *base_env
@ -403,9 +412,9 @@ test:browser:integration:api_client_ruby:
variables: variables:
<<: *variables_browser_definition <<: *variables_browser_definition
script: script:
- RAILS_ENV=test rake db:create - RAILS_ENV=test bundle exec rake db:create
- cp contrib/auto_wizard_test.json auto_wizard.json - cp contrib/auto_wizard_test.json auto_wizard.json
- rake zammad:ci:test:start - bundle exec rake zammad:ci:test:start
- git clone https://github.com/zammad/zammad-api-client-ruby.git - git clone https://github.com/zammad/zammad-api-client-ruby.git
- cd zammad-api-client-ruby - cd zammad-api-client-ruby
- bundle install -j $(nproc) - bundle install -j $(nproc)
@ -420,8 +429,8 @@ test:browser:integration:api_client_php:
ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME: "master@example.com" ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME: "master@example.com"
ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD: "test" ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD: "test"
script: script:
- RAILS_ENV=test rake db:create - RAILS_ENV=test bundle exec rake db:create
- rake zammad:ci:test:start zammad:setup:auto_wizard - bundle exec rake zammad:ci:test:start zammad:setup:auto_wizard
- git clone https://github.com/zammad/zammad-api-client-php.git - git clone https://github.com/zammad/zammad-api-client-php.git
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php --install-dir=/usr/local/bin - php composer-setup.php --install-dir=/usr/local/bin
@ -443,9 +452,9 @@ test:browser:integration:api_client_php:
- if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_MANUAL2 ; fi - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_MANUAL2 ; fi
- env - env
- script/build/test_slice_tests.sh $TEST_SLICE - script/build/test_slice_tests.sh $TEST_SLICE
- RAILS_ENV=test rake db:create - RAILS_ENV=test bundle exec rake db:create
- rake zammad:ci:test:start[with_elasticsearch] - bundle exec rake zammad:ci:test:start[with_elasticsearch]
- rake test:browser - bundle exec rake test:browser
.test_browser_core_postgresql_template: &test_browser_core_postgresql_definition .test_browser_core_postgresql_template: &test_browser_core_postgresql_definition
<<: *test_browser_core_definition <<: *test_browser_core_definition
@ -647,10 +656,10 @@ test:browser:core:chrome_6_postgresql:
.script_integration_auto_wizard_template: &script_integration_auto_wizard_definition .script_integration_auto_wizard_template: &script_integration_auto_wizard_definition
script: script:
- RAILS_ENV=test rake db:create - RAILS_ENV=test bundle exec rake db:create
- cp $AUTO_WIZARD_FILE auto_wizard.json - cp $AUTO_WIZARD_FILE auto_wizard.json
- rake zammad:ci:test:start - bundle exec rake zammad:ci:test:start
- ruby -I test/ $TEST_FILE - bundle exec ruby -I test/ $TEST_FILE
.browser_core_auto_wizard_template: &browser_core_auto_wizard_definition .browser_core_auto_wizard_template: &browser_core_auto_wizard_definition
<<: *test_browser_core_definition <<: *test_browser_core_definition
@ -729,9 +738,9 @@ test:browser:integration:idoit_chrome:
.browser_integration_import_template: &browser_integration_import_definition .browser_integration_import_template: &browser_integration_import_definition
<<: *test_browser_integration_definition <<: *test_browser_integration_definition
script: script:
- RAILS_ENV=test rake db:create - RAILS_ENV=test bundle exec rake db:create
- rake zammad:ci:test:start - bundle exec rake zammad:ci:test:start
- ruby -I test/ $TEST_FILE - bundle exec ruby -I test/ $TEST_FILE
test:browser:integration:otrs_chrome: test:browser:integration:otrs_chrome:
<<: *browser_integration_import_definition <<: *browser_integration_import_definition