From e4d7dc449f56764128275521e0d85993c31cd74b Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 1 Oct 2018 19:41:17 +0200 Subject: [PATCH] Refactoring: DRYed up .gitlab-ci.yml. --- .gitlab-ci.yml | 1187 +++++++---------- lib/tasks/bootstrap.rake | 54 - lib/tasks/zammad/bootstrap/init.rake | 12 + lib/tasks/zammad/bootstrap/reset.rake | 13 + lib/tasks/zammad/ci/app/restart.rake | 14 + lib/tasks/zammad/ci/app/start.rake | 15 + lib/tasks/zammad/ci/app/stop.rake | 15 + lib/tasks/zammad/ci/service/puma/start.rake | 36 + lib/tasks/zammad/ci/service/puma/stop.rake | 26 + .../zammad/ci/service/scheduler/start.rake | 28 + .../zammad/ci/service/scheduler/stop.rake | 28 + .../zammad/ci/service/websocket/start.rake | 32 + .../zammad/ci/service/websocket/stop.rake | 28 + lib/tasks/zammad/ci/settings.rake | 20 + lib/tasks/zammad/ci/test/fail.rake | 13 + lib/tasks/zammad/ci/test/start.rake | 24 + lib/tasks/zammad/ci/test/stop.rake | 25 + lib/tasks/zammad/db/init.rake | 8 + lib/tasks/zammad/db/unseeded.rake | 8 + lib/tasks/zammad/flush.rake | 8 + lib/tasks/zammad/flush/cache.rake | 10 + lib/tasks/zammad/flush/log/rails.rake | 15 + lib/tasks/zammad/flush/log/scheduler.rake | 14 + lib/tasks/zammad/flush/log/websocket.rake | 15 + lib/tasks/zammad/flush/logs.rake | 12 + lib/tasks/zammad/setup/auto_wizard.rake | 19 + lib/tasks/zammad/setup/db_config.rake | 23 + 27 files changed, 909 insertions(+), 793 deletions(-) delete mode 100644 lib/tasks/bootstrap.rake create mode 100644 lib/tasks/zammad/bootstrap/init.rake create mode 100644 lib/tasks/zammad/bootstrap/reset.rake create mode 100644 lib/tasks/zammad/ci/app/restart.rake create mode 100644 lib/tasks/zammad/ci/app/start.rake create mode 100644 lib/tasks/zammad/ci/app/stop.rake create mode 100644 lib/tasks/zammad/ci/service/puma/start.rake create mode 100644 lib/tasks/zammad/ci/service/puma/stop.rake create mode 100644 lib/tasks/zammad/ci/service/scheduler/start.rake create mode 100644 lib/tasks/zammad/ci/service/scheduler/stop.rake create mode 100644 lib/tasks/zammad/ci/service/websocket/start.rake create mode 100644 lib/tasks/zammad/ci/service/websocket/stop.rake create mode 100644 lib/tasks/zammad/ci/settings.rake create mode 100644 lib/tasks/zammad/ci/test/fail.rake create mode 100644 lib/tasks/zammad/ci/test/start.rake create mode 100644 lib/tasks/zammad/ci/test/stop.rake create mode 100644 lib/tasks/zammad/db/init.rake create mode 100644 lib/tasks/zammad/db/unseeded.rake create mode 100644 lib/tasks/zammad/flush.rake create mode 100644 lib/tasks/zammad/flush/cache.rake create mode 100644 lib/tasks/zammad/flush/log/rails.rake create mode 100644 lib/tasks/zammad/flush/log/scheduler.rake create mode 100644 lib/tasks/zammad/flush/log/websocket.rake create mode 100644 lib/tasks/zammad/flush/logs.rake create mode 100644 lib/tasks/zammad/setup/auto_wizard.rake create mode 100644 lib/tasks/zammad/setup/db_config.rake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c38300881..e974fd2ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,20 @@ +variables: + Z_LOCALES: "en-us:de-de" + +.artifacts_error_template: &artifacts_error + artifacts: + expire_in: 2 days + when: on_failure + paths: + - tmp/screenshot* + - log/*.log + before_script: - ruby -v - which ruby - env - test -n "$RNAME" && script/build/test_db_config.sh - - test -n "$RNAME" && bundle install --jobs 8 + - test -n "$RNAME" && bundle install -j $(nproc) stages: - pre @@ -11,6 +22,8 @@ stages: - browser-core - browser-integration +# pre stage + pre:rubocop: stage: pre tags: @@ -41,30 +54,46 @@ pre:github: script: - script/build/sync_repo.sh git@github.com:zammad/zammad.git +# test stage + +## RSpec + +.script_rspec_template: &script_rspec_definition + <<: *artifacts_error + variables: + RAILS_ENV: "test" + script: + - rake zammad:db:init + - bundle exec rspec + - rake db:drop + test:rspec:mysql: stage: test tags: - core - mysql - script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed - - bundle exec rspec - - rake db:drop + <<: *script_rspec_definition test:rspec:postgresql: stage: test tags: - core - postgresql + <<: *script_rspec_definition + +## Unit and Controller tests + +.script_unit_template: &script_unit_definition + <<: *artifacts_error + variables: + RAILS_ENV: "test" script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed - - bundle exec rspec + - rake zammad:db:init + - rake test:units + - ruby -I test/ test/integration/object_manager_test.rb + - ruby -I test/ test/integration/object_manager_attributes_controller_test.rb + - ruby -I test/ test/integration/package_test.rb + - ruby -I test/ test/integration/monitoring_controller_test.rb - rake db:drop test:unit:mysql: @@ -72,95 +101,80 @@ test:unit:mysql: tags: - core - mysql - script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed - - rake test:units - - ruby -I test/ test/integration/object_manager_test.rb - - ruby -I test/ test/integration/object_manager_attributes_controller_test.rb - - ruby -I test/ test/integration/package_test.rb - - ruby -I test/ test/integration/monitoring_controller_test.rb - - rake db:drop + <<: *script_unit_definition test:unit:postgresql: stage: test tags: - core - postgresql - script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed - - rake test:units - - ruby -I test/ test/integration/object_manager_test.rb - - ruby -I test/ test/integration/object_manager_attributes_controller_test.rb - - ruby -I test/ test/integration/package_test.rb - - ruby -I test/ test/integration/monitoring_controller_test.rb - - rake db:drop + <<: *script_unit_definition + +## Integration tests test:integration:email_helper_deliver: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - ruby -I test/ test/integration/email_helper_test.rb - ruby -I test/ test/integration/email_deliver_test.rb - ruby -I test/ test/integration/email_keep_on_server_test.rb - rake db:drop test:integration:twitter: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core-twitter script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed + - rake zammad:db:init - ruby -I test/ test/integration/twitter_test.rb - rake db:drop allow_failure: true test:integration:facebook: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core-facebook script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed + - rake zammad:db:init - ruby -I test/ test/integration/facebook_test.rb - rake db:drop allow_failure: true test:integration:geo: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - ruby -I test/ test/integration/geo_calendar_test.rb - ruby -I test/ test/integration/geo_location_test.rb - ruby -I test/ test/integration/geo_ip_test.rb - rake db:drop test:integration:user_agent: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - ruby -I test/ test/integration/user_agent_test.rb - export ZAMMAD_PROXY_TEST=true - ruby -I test/ test/integration/user_agent_test.rb @@ -168,219 +182,203 @@ test:integration:user_agent: allow_failure: true test:integration:user_device: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - ruby -I test/ test/integration/user_device_controller_test.rb - rake db:drop test:integration:slack: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - echo "gem 'slack-api'" >> Gemfile.local - - bundle install --jobs 8 + - bundle install -j $(nproc) - ruby -I test test/integration/slack_test.rb - rake db:drop test:integration:clearbit: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - ruby -I test test/integration/clearbit_test.rb - rake db:drop allow_failure: true test:integration:telegram: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed + - rake zammad:db:init - ruby -I test test/integration/telegram_controller_test.rb - rake db:drop test:integration:idoit: + <<: *artifacts_error stage: test + variables: + RAILS_ENV: "test" tags: - core script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - rake db:seed + - rake zammad:db:init - ruby -I test test/integration/idoit_controller_test.rb - rake db:drop -test:integration:es_mysql: +### Elasticsearch + +.script_elasticsearch_template: &script_elasticsearch_definition + <<: *artifacts_error stage: test - tags: - - core - - mysql + variables: + RAILS_ENV: "test" + ES_INDEX_RAND: "true" + ES_URL: "http://localhost:9200" script: - - export RAILS_ENV=test - - export ES_INDEX_RAND=true - - export ES_URL="http://localhost:9200" - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - ruby -I test/ test/integration/elasticsearch_active_test.rb - ruby -I test/ test/integration/elasticsearch_test.rb - ruby -I test/ test/integration/report_test.rb - bundle exec rspec --tag searchindex - rake db:drop +test:integration:es_mysql: + tags: + - core + - mysql + <<: *script_elasticsearch_definition + test:integration:es_postgresql: - stage: test tags: - core - postgresql + <<: *script_elasticsearch_definition + +### Zendesk + +.script_integration_zendesk_template: &script_integration_zendesk_definition + <<: *artifacts_error + stage: test + variables: + RAILS_ENV: "test" script: - - export RAILS_ENV=test - - export ES_INDEX_RAND=true - - export ES_URL="http://localhost:9200" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/elasticsearch_active_test.rb - - ruby -I test/ test/integration/elasticsearch_test.rb - - ruby -I test/ test/integration/report_test.rb - - bundle exec rspec --tag searchindex + - rake zammad:db:unseeded + - ruby -I test/ test/integration/zendesk_import_test.rb - rake db:drop + allow_failure: true test:integration:zendesk_mysql: - stage: test tags: - core - mysql - script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/zendesk_import_test.rb - - rake db:drop - allow_failure: true + <<: *script_integration_zendesk_definition test:integration:zendesk_postgresql: - stage: test tags: - core - postgresql + <<: *script_integration_zendesk_definition + +### OTRS + +.script_integration_otrs_template: &script_integration_otrs_definition + <<: *artifacts_error + stage: test script: - - export RAILS_ENV=test - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/zendesk_import_test.rb + - rake zammad:db:unseeded + - ruby -I test/ test/integration/otrs_import_test.rb - rake db:drop - allow_failure: true + +.variables_integration_otrs_6_template: &variables_integration_otrs_6_definition + variables: + RAILS_ENV: "test" + IMPORT_OTRS_ENDPOINT: "https://vz1185.test.znuny.com/otrs/public.pl?Action=ZammadMigrator" test:integration:otrs_6_mysql: - stage: test tags: - core - mysql - script: - - export RAILS_ENV=test - - export IMPORT_OTRS_ENDPOINT="https://vz1185.test.znuny.com/otrs/public.pl?Action=ZammadMigrator" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/otrs_import_test.rb - - rake db:drop + <<: *script_integration_otrs_definition + <<: *variables_integration_otrs_6_definition test:integration:otrs_6_postgresql: - stage: test tags: - core - postgresql - script: - - export RAILS_ENV=test - - export IMPORT_OTRS_ENDPOINT="https://vz1185.test.znuny.com/otrs/public.pl?Action=ZammadMigrator" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/otrs_import_test.rb - - rake db:drop + <<: *script_integration_otrs_definition + <<: *variables_integration_otrs_6_definition test:integration:otrs_5: - stage: test tags: - core - script: - - export RAILS_ENV=test - - export IMPORT_OTRS_ENDPOINT="http://vz1109.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/otrs_import_test.rb - - rake db:drop + variables: + RAILS_ENV: "test" + IMPORT_OTRS_ENDPOINT: "http://vz1109.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" + <<: *script_integration_otrs_definition test:integration:otrs_4: - stage: test tags: - core - script: - - export RAILS_ENV=test - - export IMPORT_OTRS_ENDPOINT="http://vz383.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/otrs_import_test.rb - - rake db:drop + variables: + RAILS_ENV: "test" + IMPORT_OTRS_ENDPOINT: "http://vz383.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" + <<: *script_integration_otrs_definition test:integration:otrs_33: - stage: test tags: - core - script: - - export RAILS_ENV=test - - export IMPORT_OTRS_ENDPOINT="http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/otrs_import_test.rb - - rake db:drop + variables: + RAILS_ENV: "test" + IMPORT_OTRS_ENDPOINT: "http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" + <<: *script_integration_otrs_definition test:integration:otrs_32: - stage: test tags: - core - script: - - export RAILS_ENV=test - - export IMPORT_OTRS_ENDPOINT="http://vz382.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/otrs_import_test.rb - - rake db:drop + variables: + RAILS_ENV: "test" + IMPORT_OTRS_ENDPOINT: "http://vz382.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" + <<: *script_integration_otrs_definition test:integration:otrs_31: - stage: test tags: - core - script: - - export RAILS_ENV=test - - export IMPORT_OTRS_ENDPOINT="http://vz381.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" - - rake db:create - - rake db:migrate - - ruby -I test/ test/integration/otrs_import_test.rb - - rake db:drop + variables: + RAILS_ENV: "test" + IMPORT_OTRS_ENDPOINT: "http://vz381.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator" + <<: *script_integration_otrs_definition + +# Browser tests + +## preparation (asset precompile) browser:build: stage: test tags: - core + variables: + RAILS_ENV: "production" script: - - export RAILS_ENV=production - - rake db:create - - rake db:migrate + - rake zammad:db:unseeded - rake assets:precompile - rake db:drop artifacts: @@ -390,675 +388,386 @@ browser:build: - public/assets/application-* - public/assets/print-* -test:browser:integration:api_client_ruby: +## Browser core tests + +.variables_browser_template: &variables_browser_definition + RAILS_SERVE_STATIC_FILES: "true" + RAILS_ENV: "production" + BROWSER_URL: "http://$IP:$BROWSER_PORT" + APP_RESTART_CMD: "rake zammad:ci:app:restart" + +.test_browser_core_template: &test_browser_core_definition + <<: *artifacts_error stage: browser-core dependencies: - browser:build + +### API clients + +test:browser:integration:api_client_ruby: + <<: *test_browser_core_definition + variables: + <<: *variables_browser_definition + TEST_URL: "http://$IP:$BROWSER_PORT/" tags: - browser script: - RAILS_ENV=test rake db:create - cp contrib/auto_wizard_test.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - git clone git@github.com:zammad/zammad-api-client-ruby.git || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 + - rake zammad:ci:test:start + - git clone git@github.com:zammad/zammad-api-client-ruby.git || rake zammad:ci:test:fail - cd zammad-api-client-ruby - - bundle install --jobs 8 - - export TEST_URL=http://$IP:$BROWSER_PORT/ - - bundle exec rspec || (cd .. && script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0) - - cd .. && script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 + - bundle install -j $(nproc) + - bundle exec rspec || (cd .. && rake zammad:ci:test:fail) + - cd .. && rake zammad:ci:test:stop test:browser:integration:api_client_php: - stage: browser-core - dependencies: - - browser:build + <<: *test_browser_core_definition + variables: + <<: *variables_browser_definition + ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL: "http://$IP:$BROWSER_PORT" + ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME: "master@example.com" + ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD: "test" tags: - browser script: - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_test.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - git clone git@github.com:zammad/zammad-api-client-php || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - wget http://$IP:$BROWSER_PORT/api/v1/getting_started/auto_wizard + - rake zammad:ci:test:start zammad:setup:auto_wizard + - git clone git@github.com:zammad/zammad-api-client-php || rake zammad:ci:test:fail - cd zammad-api-client-php - composer install - - export ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL=http://$IP:$BROWSER_PORT - - export ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME=master@example.com - - export ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD=test - - vendor/bin/phpunit || (cd .. && script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0) - - cd .. && script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 + - vendor/bin/phpunit || (cd .. && rake zammad:ci:test:fail) + - cd .. && rake zammad:ci:test:stop -test:browser:twitter_ff: - stage: browser-integration - dependencies: - - browser:build - tags: - - browser - - twitter - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_test.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - ruby -I test/ test/integration/twitter_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 +### Browser test slices -test:browser:facebook_ff: - stage: browser-integration - dependencies: - - browser:build - tags: - - browser - - facebook - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_test.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - ruby -I test/ test/integration/facebook_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 +#### Templates -test:browser:autowizard_ff: +.script_browser_slice_template: &script_browser_slice_definition stage: browser-core dependencies: - browser:build + script: + # temporary workaround to check Yahoo! mailbox only in test:browser:core:ff_3_* tests + - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_AUTO1 ; fi + - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_AUTO2 ; fi + - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_MANUAL1 ; fi + - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_MANUAL2 ; fi + - env + - script/build/test_slice_tests.sh $TEST_SLICE + - RAILS_ENV=test rake db:create + - rake zammad:ci:test:start[with_elasticsearch] + - rake test:browser || rake zammad:ci:test:fail + - rake zammad:ci:test:stop + +.test_browser_core_postgresql_template: &test_browser_core_postgresql_definition + <<: *test_browser_core_definition tags: - browser - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_example.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - ruby -I test/ test/integration/auto_wizard_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + - postgresql + <<: *script_browser_slice_definition + +.test_browser_core_mysql_template: &test_browser_core_mysql_definition + <<: *test_browser_core_definition + tags: + - browser + - mysql + <<: *script_browser_slice_definition + +#### Firefox test:browser:core:ff_1_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 1 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "1" test:browser:core:ff_2_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 2 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "2" test:browser:core:ff_3_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - script/build/test_slice_tests.sh 3 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "3" test:browser:core:ff_4_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 4 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "4" test:browser:core:ff_5_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 5 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "5" test:browser:core:ff_6_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 6 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "6" test:browser:core:ff_1_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 1 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "1" test:browser:core:ff_2_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 2 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "2" test:browser:core:ff_3_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - script/build/test_slice_tests.sh 3 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "3" test:browser:core:ff_4_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 4 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "4" test:browser:core:ff_5_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 5 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "5" test:browser:core:ff_6_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=firefox - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 6 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + TEST_SLICE: "6" + +### Chrome test:browser:core:chrome_1_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 1 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "1" test:browser:core:chrome_2_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 2 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "2" test:browser:core:chrome_3_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 3 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "3" test:browser:core:chrome_4_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 4 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "4" test:browser:core:chrome_5_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 5 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "5" test:browser:core:chrome_6_mysql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - mysql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 6 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_mysql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "6" test:browser:core:chrome_1_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 1 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "1" test:browser:core:chrome_2_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 2 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "2" test:browser:core:chrome_3_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 3 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "3" test:browser:core:chrome_4_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 4 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "4" test:browser:core:chrome_5_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 5 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "5" test:browser:core:chrome_6_postgresql: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - - postgresql - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - export APP_RESTART_CMD="script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0 0 && script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 0" - - unset MAILBOX_AUTO1 - - unset MAILBOX_AUTO2 - - unset MAILBOX_MANUAL1 - - unset MAILBOX_MANUAL2 - - script/build/test_slice_tests.sh 6 - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - rake test:browser || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 + <<: *test_browser_core_postgresql_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + TEST_SLICE: "6" -test:browser:autowizard_chrome: - stage: browser-core - dependencies: - - browser:build - tags: - - browser - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_example.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 - - ruby -I test/ test/integration/auto_wizard_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 1 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 1 +### Auto wizard -test:browser:integration:twitter_chrome: +.test_browser_integration_template: &test_browser_integration_definition + <<: *artifacts_error stage: browser-integration dependencies: - browser:build + +.script_integration_auto_wizard_template: &script_integration_auto_wizard_definition + script: + - RAILS_ENV=test rake db:create + - cp $AUTO_WIZARD_FILE auto_wizard.json + - rake zammad:ci:test:start[with_elasticsearch] + - ruby -I test/ $TEST_FILE || rake zammad:ci:test:fail + - rake zammad:ci:test:stop + +.browser_core_auto_wizard_template: &browser_core_auto_wizard_definition + <<: *test_browser_core_definition + <<: *script_integration_auto_wizard_definition + +test:browser:autowizard_chrome: + <<: *browser_core_auto_wizard_definition + tags: + - browser + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + AUTO_WIZARD_FILE: "contrib/auto_wizard_example.json" + TEST_FILE: "test/integration/auto_wizard_browser_test.rb" + +test:browser:autowizard_ff: + <<: *browser_core_auto_wizard_definition + tags: + - browser + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + AUTO_WIZARD_FILE: "contrib/auto_wizard_example.json" + TEST_FILE: "test/integration/auto_wizard_browser_test.rb" + +### Browser integration tests + +.browser_integration_auto_wizard_template: &browser_integration_auto_wizard_definition + <<: *test_browser_integration_definition + <<: *script_integration_auto_wizard_definition + +test:browser:integration:twitter_chrome: + <<: *browser_integration_auto_wizard_definition tags: - browser - twitter - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_test.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - ruby -I test/ test/integration/twitter_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json" + TEST_FILE: "test/integration/twitter_browser_test.rb" + +test:browser:integration:twitter_ff: + <<: *browser_integration_auto_wizard_definition + tags: + - browser + - twitter + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json" + TEST_FILE: "test/integration/twitter_browser_test.rb" test:browser:integration:facebook_chrome: - stage: browser-integration - dependencies: - - browser:build + <<: *browser_integration_auto_wizard_definition tags: - browser - facebook - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_test.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - ruby -I test/ test/integration/facebook_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json" + TEST_FILE: "test/integration/facebook_browser_test.rb" -test:browser:integration:otrs_chrome: - stage: browser-integration - dependencies: - - browser:build +test:browser:integration:facebook_ff: + <<: *browser_integration_auto_wizard_definition tags: - browser - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - ruby -I test/ test/integration/otrs_import_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 - -test:browser:integration:zendesk_chrome: - stage: browser-integration - dependencies: - - browser:build - tags: - - browser - script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - - RAILS_ENV=test rake db:create - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - ruby -I test/ test/integration/zendesk_import_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 + - facebook + variables: + <<: *variables_browser_definition + BROWSER: "firefox" + AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json" + TEST_FILE: "test/integration/facebook_browser_test.rb" test:browser:integration:idoit_chrome: - stage: browser-integration - dependencies: - - browser:build + <<: *browser_integration_auto_wizard_definition + variables: + <<: *variables_browser_definition + BROWSER: "chrome" + AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json" + TEST_FILE: "test/integration/idoit_browser_test.rb" + +### Browser integration tests + +.variables_browser_import_template: &variables_browser_import_definition + BROWSER: "chrome" + BROWSER_URL: "http://$IP:$BROWSER_PORT" + +.browser_integration_import_template: &browser_integration_import_definition + <<: *test_browser_integration_definition tags: - browser script: - - export BROWSER=chrome - - export BROWSER_URL=http://$IP:$BROWSER_PORT - RAILS_ENV=test rake db:create - - cp contrib/auto_wizard_test.json auto_wizard.json - - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 0 - - ruby -I test/ test/integration/idoit_browser_test.rb || script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1 0 - - script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 0 + - rake zammad:ci:test:start + - ruby -I test/ $TEST_FILE + - rake zammad:ci:test:stop + +test:browser:integration:otrs_chrome: + <<: *browser_integration_import_definition + variables: + <<: *variables_browser_import_definition + TEST_FILE: "test/integration/otrs_import_browser_test.rb" + +test:browser:integration:zendesk_chrome: + <<: *browser_integration_import_definition + variables: + <<: *variables_browser_import_definition + TEST_FILE: "test/integration/zendesk_import_browser_test.rb" diff --git a/lib/tasks/bootstrap.rake b/lib/tasks/bootstrap.rake deleted file mode 100644 index 8206fc8ca..000000000 --- a/lib/tasks/bootstrap.rake +++ /dev/null @@ -1,54 +0,0 @@ -module BootstrapRakeHelper - APP_CACHE = Dir.glob(Rails.root.join('tmp', 'cache*')) - SERVER_LOG = Rails.root.join('log', "#{Rails.env}.log") - AUTO_WIZARD = { source: Rails.root.join('contrib', 'auto_wizard_test.json'), - dest: Rails.root.join('auto_wizard.json') }.freeze - DB_CONFIG = { source: Rails.root.join('config', 'database', 'database.yml'), - dest: Rails.root.join('config', 'database.yml') }.freeze - - def flush_cache_and_logs - FileUtils.rm_rf(APP_CACHE) - File.write(SERVER_LOG, '') - end - - def run_auto_wizard - FileUtils.ln(AUTO_WIZARD[:source], AUTO_WIZARD[:dest], force: true) - AutoWizard.setup - - # set system init to done - UserInfo.current_user_id = 1 - Setting.set('system_init_done', true) - end - - def add_database_config - raise Errno::ENOENT, 'config/database.yml not found' unless File.exist?(DB_CONFIG[:source]) - - if File.exist?(DB_CONFIG[:dest]) - return if FileUtils.identical?(DB_CONFIG[:source], DB_CONFIG[:dest]) - printf 'config/database.yml: File exists. Overwrite? [y/N] ' - return if STDIN.gets.chomp.downcase != 'y' - end - - FileUtils.cp(DB_CONFIG[:source], DB_CONFIG[:dest]) - end -end - -namespace :bs do - desc 'Bootstrap the application' - task :init => %i[db_config db:create db:migrate db:seed] do - include BootstrapRakeHelper - run_auto_wizard - end - - desc 'Reset the application to its initial state' - task :reset => %i[db:reset] do - include BootstrapRakeHelper - run_auto_wizard - flush_cache_and_logs - end - - task :db_config do - include BootstrapRakeHelper - add_database_config - end -end diff --git a/lib/tasks/zammad/bootstrap/init.rake b/lib/tasks/zammad/bootstrap/init.rake new file mode 100644 index 000000000..cb24ab1dd --- /dev/null +++ b/lib/tasks/zammad/bootstrap/init.rake @@ -0,0 +1,12 @@ +namespace :zammad do + + namespace :bootstrap do + + desc 'Initializes a Zammad for the first time' + task init: %i[ + zammad:setup:db_config + zammad:db:init + zammad:setup:auto_wizard + ] + end +end diff --git a/lib/tasks/zammad/bootstrap/reset.rake b/lib/tasks/zammad/bootstrap/reset.rake new file mode 100644 index 000000000..f220a7b8e --- /dev/null +++ b/lib/tasks/zammad/bootstrap/reset.rake @@ -0,0 +1,13 @@ +namespace :zammad do + + namespace :bootstrap do + + desc 'Resets a Zammad and reinitializes it' + task reset: %i[ + db:drop + zammad:db:init + zammad:setup:auto_wizard + zammad:flush + ] + end +end diff --git a/lib/tasks/zammad/ci/app/restart.rake b/lib/tasks/zammad/ci/app/restart.rake new file mode 100644 index 000000000..d702193a3 --- /dev/null +++ b/lib/tasks/zammad/ci/app/restart.rake @@ -0,0 +1,14 @@ +namespace :zammad do + + namespace :ci do + + namespace :app do + + desc 'Restarts the application' + task restart: %i[ + zammad:ci:app:stop + zammad:ci:app:start + ] + end + end +end diff --git a/lib/tasks/zammad/ci/app/start.rake b/lib/tasks/zammad/ci/app/start.rake new file mode 100644 index 000000000..1266e566d --- /dev/null +++ b/lib/tasks/zammad/ci/app/start.rake @@ -0,0 +1,15 @@ +namespace :zammad do + + namespace :ci do + + namespace :app do + + desc 'Starts the application and uses BROWSER_PORT, RAILS_ENV and WS_PORT ENVs' + task :start do + Rake::Task['zammad:ci:service:puma:start'].invoke(ENV['BROWSER_PORT'], ENV['RAILS_ENV']) + Rake::Task['zammad:ci:service:websocket:start'].invoke(ENV['WS_PORT']) + Rake::Task['zammad:ci:service:scheduler:start'].invoke + end + end + end +end diff --git a/lib/tasks/zammad/ci/app/stop.rake b/lib/tasks/zammad/ci/app/stop.rake new file mode 100644 index 000000000..24c0fddba --- /dev/null +++ b/lib/tasks/zammad/ci/app/stop.rake @@ -0,0 +1,15 @@ +namespace :zammad do + + namespace :ci do + + namespace :app do + + desc 'Stops the application' + task stop: %i[ + zammad:ci:service:scheduler:stop + zammad:ci:service:websocket:stop + zammad:ci:service:puma:stop + ] + end + end +end diff --git a/lib/tasks/zammad/ci/service/puma/start.rake b/lib/tasks/zammad/ci/service/puma/start.rake new file mode 100644 index 000000000..313792d79 --- /dev/null +++ b/lib/tasks/zammad/ci/service/puma/start.rake @@ -0,0 +1,36 @@ +namespace :zammad do + + namespace :ci do + + namespace :service do + + namespace :puma do + + desc 'Starts the puma application webserver' + task :start, [:port, :env] do |_task, args| + + port = args.fetch(:port, '3000') + env = args.fetch(:env, 'production') + command = [ + 'bundle', + 'exec', + 'puma', + '--pidfile', + 'tmp/pids/server.pid', + '-d', + '-p', + port, + '-e', + env + ] + + stdout, stderr, status = Open3.capture3(*command) + + next if status.success? + + abort("Error while starting Puma - error status #{status.exitstatus}: #{stderr}") + end + end + end + end +end diff --git a/lib/tasks/zammad/ci/service/puma/stop.rake b/lib/tasks/zammad/ci/service/puma/stop.rake new file mode 100644 index 000000000..21408ccc0 --- /dev/null +++ b/lib/tasks/zammad/ci/service/puma/stop.rake @@ -0,0 +1,26 @@ +namespace :zammad do + + namespace :ci do + + namespace :service do + + namespace :puma do + + desc 'Stops the puma application webserver' + task :stop do + + file = Rails.root.join('tmp', 'pids', 'server.pid') + pid = File.read(file).to_i + + Process.kill('SIGTERM', pid) + + sleep 5 + + next if !File.exist?(file) + + Process.kill('SIGKILL', pid) + end + end + end + end +end diff --git a/lib/tasks/zammad/ci/service/scheduler/start.rake b/lib/tasks/zammad/ci/service/scheduler/start.rake new file mode 100644 index 000000000..398f90c70 --- /dev/null +++ b/lib/tasks/zammad/ci/service/scheduler/start.rake @@ -0,0 +1,28 @@ +namespace :zammad do + + namespace :ci do + + namespace :service do + + namespace :scheduler do + + desc 'Starts the scheduler' + task :start do + + command = [ + 'bundle', + 'exec', + 'script/scheduler.rb', + 'start', + ] + + stdout, stderr, status = Open3.capture3(*command) + + next if status.success? + + abort("Error while starting scheduler - error status #{status.exitstatus}: #{stderr}") + end + end + end + end +end diff --git a/lib/tasks/zammad/ci/service/scheduler/stop.rake b/lib/tasks/zammad/ci/service/scheduler/stop.rake new file mode 100644 index 000000000..7091b3d17 --- /dev/null +++ b/lib/tasks/zammad/ci/service/scheduler/stop.rake @@ -0,0 +1,28 @@ +namespace :zammad do + + namespace :ci do + + namespace :service do + + namespace :scheduler do + + desc 'Stops the scheduler' + task :stop do + + command = [ + 'bundle', + 'exec', + 'script/scheduler.rb', + 'stop', + ] + + stdout, stderr, status = Open3.capture3(*command) + + next if status.success? + + abort("Error while stopping scheduler - error status #{status.exitstatus}: #{stderr}") + end + end + end + end +end diff --git a/lib/tasks/zammad/ci/service/websocket/start.rake b/lib/tasks/zammad/ci/service/websocket/start.rake new file mode 100644 index 000000000..6b4bd34f8 --- /dev/null +++ b/lib/tasks/zammad/ci/service/websocket/start.rake @@ -0,0 +1,32 @@ +namespace :zammad do + + namespace :ci do + + namespace :service do + + namespace :websocket do + + desc 'Starts the websocket server' + task :start, [:port] do |_task, args| + + port = args.fetch(:port, '6042') + command = [ + 'bundle', + 'exec', + 'script/websocket-server.rb', + 'start', + '-d', + '-p', + port + ] + + stdout, stderr, status = Open3.capture3(*command) + + next if status.success? + + abort("Error while starting websocket server - error status #{status.exitstatus}: #{stderr}") + end + end + end + end +end diff --git a/lib/tasks/zammad/ci/service/websocket/stop.rake b/lib/tasks/zammad/ci/service/websocket/stop.rake new file mode 100644 index 000000000..1499ea77a --- /dev/null +++ b/lib/tasks/zammad/ci/service/websocket/stop.rake @@ -0,0 +1,28 @@ +namespace :zammad do + + namespace :ci do + + namespace :service do + + namespace :websocket do + + desc 'Stops the websocket server' + task :stop do + + command = [ + 'bundle', + 'exec', + 'script/websocket-server.rb', + 'stop', + ] + + stdout, stderr, status = Open3.capture3(*command) + + next if status.success? + + abort("Error while stopping websocket server - error status #{status.exitstatus}: #{stderr}") + end + end + end + end +end diff --git a/lib/tasks/zammad/ci/settings.rake b/lib/tasks/zammad/ci/settings.rake new file mode 100644 index 000000000..63971047c --- /dev/null +++ b/lib/tasks/zammad/ci/settings.rake @@ -0,0 +1,20 @@ +namespace :zammad do + + namespace :ci do + + desc 'Sets all required Settings for performing tests in the CI environment' + task :settings, [:elasticsearch] => :environment do |_task, args| + Setting.set('developer_mode', true) + Setting.set('websocket_port', ENV['WS_PORT']) + Setting.set('fqdn', "#{ENV['IP']}:#{ENV['BROWSER_PORT']}") + Setting.set('chat_agent_idle_timeout', '45') + + next if args[:elasticsearch] != 'with_elasticsearch' + + Setting.set('es_url', 'http://localhost:9200') + Setting.set('es_index', "browser_test_#{ENV['CI_BUILD_ID']}") + + Rake::Task['searchindex:rebuild'].invoke + end + end +end diff --git a/lib/tasks/zammad/ci/test/fail.rake b/lib/tasks/zammad/ci/test/fail.rake new file mode 100644 index 000000000..1c3bd7c08 --- /dev/null +++ b/lib/tasks/zammad/ci/test/fail.rake @@ -0,0 +1,13 @@ +namespace :zammad do + + namespace :ci do + + namespace :test do + + desc 'Stops all of Zammads services and exists the rake task with exit code 1' + task fail: %i[zammad:ci:test:stop] do + abort('Abort further test processing') + end + end + end +end diff --git a/lib/tasks/zammad/ci/test/start.rake b/lib/tasks/zammad/ci/test/start.rake new file mode 100644 index 000000000..646e82adf --- /dev/null +++ b/lib/tasks/zammad/ci/test/start.rake @@ -0,0 +1,24 @@ +namespace :zammad do + + namespace :ci do + + namespace :test do + + desc 'Starts all of Zammads services for CI test' + task :start, [:elasticsearch] do |_task, args| + ENV['RAILS_ENV'] ||= 'production' + ENV['DISABLE_DATABASE_ENVIRONMENT_CHECK'] = 'true' + # we have to enforce the env + # otherwise it will fallback to default (develop) + Rails.env = ENV['RAILS_ENV'] + + Rake::Task['zammad:flush:cache'].invoke + + Rake::Task['zammad:db:init'].invoke + + Rake::Task['zammad:ci:settings'].invoke(args[:elasticsearch]) + Rake::Task['zammad:ci:app:start'].invoke + end + end + end +end diff --git a/lib/tasks/zammad/ci/test/stop.rake b/lib/tasks/zammad/ci/test/stop.rake new file mode 100644 index 000000000..f76f2d8a2 --- /dev/null +++ b/lib/tasks/zammad/ci/test/stop.rake @@ -0,0 +1,25 @@ +namespace :zammad do + + namespace :ci do + + namespace :test do + + desc 'Stop of all Zammad services and cleans up the database(s)' + task :stop do + ENV['RAILS_ENV'] ||= 'production' + ENV['DISABLE_DATABASE_ENVIRONMENT_CHECK'] = 'true' + + # we have to enforce the env + # otherwise it will fallback to default (develop) + Rails.env = ENV['RAILS_ENV'] + + Rake::Task['zammad:ci:app:stop'].invoke + Rake::Task['db:drop:all'].invoke + + next if !SearchIndexBackend.enabled? + + Rake::Task['searchindex:drop'].invoke + end + end + end +end diff --git a/lib/tasks/zammad/db/init.rake b/lib/tasks/zammad/db/init.rake new file mode 100644 index 000000000..8cb342241 --- /dev/null +++ b/lib/tasks/zammad/db/init.rake @@ -0,0 +1,8 @@ +namespace :zammad do + + namespace :db do + + desc 'Initializes (creates, migrates and seeds) the DB' + task init: %i[zammad:db:unseeded db:seed] + end +end diff --git a/lib/tasks/zammad/db/unseeded.rake b/lib/tasks/zammad/db/unseeded.rake new file mode 100644 index 000000000..a2132f974 --- /dev/null +++ b/lib/tasks/zammad/db/unseeded.rake @@ -0,0 +1,8 @@ +namespace :zammad do + + namespace :db do + + desc 'Creates and migrates the DB without seeding' + task unseeded: %i[db:create db:migrate] + end +end diff --git a/lib/tasks/zammad/flush.rake b/lib/tasks/zammad/flush.rake new file mode 100644 index 000000000..33d191aab --- /dev/null +++ b/lib/tasks/zammad/flush.rake @@ -0,0 +1,8 @@ +namespace :zammad do + + desc 'Flushes all logs and caches' + task flush: %i[ + zammad:flush:logs + zammad:flush:cache + ] +end diff --git a/lib/tasks/zammad/flush/cache.rake b/lib/tasks/zammad/flush/cache.rake new file mode 100644 index 000000000..a9cee8a51 --- /dev/null +++ b/lib/tasks/zammad/flush/cache.rake @@ -0,0 +1,10 @@ +namespace :zammad do + + namespace :flush do + + desc 'Flushes all caches' + task :cache do + FileUtils.rm_rf(Rails.root.join('tmp', 'cache*')) + end + end +end diff --git a/lib/tasks/zammad/flush/log/rails.rake b/lib/tasks/zammad/flush/log/rails.rake new file mode 100644 index 000000000..1e40680c1 --- /dev/null +++ b/lib/tasks/zammad/flush/log/rails.rake @@ -0,0 +1,15 @@ +namespace :zammad do + + namespace :flush do + + namespace :log do + + desc 'Flushes all scheduler log files' + task :scheduler do + %w[err out].each do |suffix| + File.write(Rails.root.join('log', "scheduler_#{suffix}.log"), '') + end + end + end + end +end diff --git a/lib/tasks/zammad/flush/log/scheduler.rake b/lib/tasks/zammad/flush/log/scheduler.rake new file mode 100644 index 000000000..b7635a56c --- /dev/null +++ b/lib/tasks/zammad/flush/log/scheduler.rake @@ -0,0 +1,14 @@ +namespace :zammad do + + namespace :flush do + + namespace :log do + + desc 'Flushes the log Rails file of the given or active environment' + task :rails, [:env] do |_task, args| + env = args.fetch(:env, Rails.env) + File.write(Rails.root.join('log', "#{env}.log"), '') + end + end + end +end diff --git a/lib/tasks/zammad/flush/log/websocket.rake b/lib/tasks/zammad/flush/log/websocket.rake new file mode 100644 index 000000000..2040c55e9 --- /dev/null +++ b/lib/tasks/zammad/flush/log/websocket.rake @@ -0,0 +1,15 @@ +namespace :zammad do + + namespace :flush do + + namespace :log do + + desc 'Flushes all websocket server log files' + task :websocket do + %w[err out].each do |suffix| + File.write(Rails.root.join('log', "websocket-server_#{suffix}.log"), '') + end + end + end + end +end diff --git a/lib/tasks/zammad/flush/logs.rake b/lib/tasks/zammad/flush/logs.rake new file mode 100644 index 000000000..7e2b6e974 --- /dev/null +++ b/lib/tasks/zammad/flush/logs.rake @@ -0,0 +1,12 @@ +namespace :zammad do + + namespace :flush do + + desc 'Flushes all logs' + task logs: %i[ + zammad:flush:log:rails + zammad:flush:log:scheduler + zammad:flush:log:websocket + ] + end +end diff --git a/lib/tasks/zammad/setup/auto_wizard.rake b/lib/tasks/zammad/setup/auto_wizard.rake new file mode 100644 index 000000000..1a9094c36 --- /dev/null +++ b/lib/tasks/zammad/setup/auto_wizard.rake @@ -0,0 +1,19 @@ +namespace :zammad do + + namespace :setup do + + desc 'Initializes Zammad via a given auto_wizard JSON file or falls back to contrib/auto_wizard_test.json' + task :auto_wizard, [:source] => :environment do |_task, args| + + root = Rails.root + source = args.fetch(:source, root.join('contrib', 'auto_wizard_test.json')) + + FileUtils.ln(source, root.join('auto_wizard.json'), force: true) + + AutoWizard.setup + + # set system init to done + Setting.set('system_init_done', true) + end + end +end diff --git a/lib/tasks/zammad/setup/db_config.rake b/lib/tasks/zammad/setup/db_config.rake new file mode 100644 index 000000000..aa64b0d63 --- /dev/null +++ b/lib/tasks/zammad/setup/db_config.rake @@ -0,0 +1,23 @@ +namespace :zammad do + + namespace :setup do + + desc 'Copies the database config template file to config/database.yml' + task :db_config do + + config_dir = Rails.root.join('config') + template = config_dir.join('database', 'database.yml') + destination = config_dir.join('database.yml') + + raise Errno::ENOENT, "#{template} not found" unless File.exist?(template) + + if File.exist?(destination) + next if FileUtils.identical?(template, destination) + printf 'config/database.yml: File exists. Overwrite? [y/N] ' + next if STDIN.gets.chomp.downcase != 'y' + end + + FileUtils.cp(template, destination) + end + end +end