.gitlab-ci.yml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. image: registry.znuny.com/docker/zammad-ruby:2.4.4
  2. # Global variables added to the ENV of each job
  3. variables:
  4. # for faster translation loading
  5. Z_LOCALES: "en-us:de-de"
  6. # Browser tests and variables
  7. RAILS_SERVE_STATIC_FILES: "true"
  8. REMOTE_URL: "http://selenium:24444/wd/hub"
  9. TZ: "Europe/London"
  10. # docker elgalu/selenium variables for parallel browser instance creation
  11. MAX_INSTANCES: "50"
  12. MAX_SESSIONS: "50"
  13. # docker-imap-devel variables required for browser tests
  14. MAILNAME: "mail.test.dc.zammad.com"
  15. MAILBOX_INIT: "zammad@mail.test.dc.zammad.com:zammad"
  16. MAIL_ADDRESS: "zammad@mail.test.dc.zammad.com"
  17. MAIL_PASS: "zammad"
  18. # Artifacts are stored for failed jobs for 2 days
  19. .artifacts_error_template: &artifacts_error
  20. artifacts:
  21. expire_in: 2 days
  22. when: on_failure
  23. paths:
  24. - tmp/screenshot*
  25. - tmp/screenshots/*
  26. - log/*.log
  27. # Workaround to enable usage of mixed SSH and Docker GitLab CI runners
  28. .docker_env_template: &docker_env
  29. tags:
  30. - docker
  31. # Workaround for blocked port 25 access on cloud provider infrastructure
  32. .requires_mail_port_access_template: &requires_mail_port_access
  33. tags:
  34. - mail
  35. .base_env_template: &base_env
  36. <<: *docker_env
  37. <<: *artifacts_error
  38. # General required Docker services for different/random DB envs
  39. .services_mysql_template: &services_mysql
  40. services:
  41. - name: registry.znuny.com/docker/zammad-mysql:latest
  42. alias: mysql
  43. .services_postgresql_template: &services_postgresql
  44. services:
  45. - name: registry.znuny.com/docker/zammad-postgresql:latest
  46. alias: postgresql
  47. .services_random_db_template: &services_random_db
  48. services:
  49. - name: registry.znuny.com/docker/zammad-mysql:latest
  50. alias: mysql
  51. - name: registry.znuny.com/docker/zammad-postgresql:latest
  52. alias: postgresql
  53. # Cache gems in between jobs and pipelines
  54. cache:
  55. key: "ruby24"
  56. paths:
  57. - vendor/ruby
  58. # Initialize application env
  59. before_script:
  60. - bundle install -j $(nproc) --path vendor
  61. - bundle exec ruby script/build/database_config.rb
  62. # Stages
  63. stages:
  64. - pre
  65. - test
  66. - browser-core
  67. - browser-integration
  68. # pre stage
  69. # Workaround to enable usage of mixed SSH and Docker GitLab CI runners
  70. .pre_stage_template: &pre_stage
  71. <<: *docker_env
  72. stage: pre
  73. before_script:
  74. - '' # disable before_script for pre "non-application" env
  75. pre:rubocop:
  76. <<: *pre_stage
  77. script:
  78. - bundle install -j $(nproc) --path vendor
  79. - bundle exec rubocop
  80. pre:coffeelint:
  81. <<: *pre_stage
  82. script:
  83. - coffeelint app/
  84. pre:bundle-audit:
  85. <<: *pre_stage
  86. script:
  87. - gem install bundler-audit
  88. - bundle-audit update
  89. - bundle-audit --ignore CVE-2015-9284
  90. pre:github:
  91. <<: *pre_stage
  92. tags:
  93. - deploy
  94. script:
  95. - script/build/sync_repo.sh git@github.com:zammad/zammad.git
  96. # test stage
  97. ## RSpec
  98. .script_rspec_template: &script_rspec_definition
  99. <<: *base_env
  100. variables:
  101. RAILS_ENV: "test"
  102. script:
  103. - bundle exec rake zammad:db:init
  104. - bundle exec rspec -t ~type:system
  105. test:rspec:mysql:
  106. stage: test
  107. <<: *services_mysql
  108. <<: *script_rspec_definition
  109. test:rspec:postgresql:
  110. stage: test
  111. <<: *services_postgresql
  112. <<: *script_rspec_definition
  113. ## Unit and Controller tests
  114. .script_unit_template: &script_unit_definition
  115. <<: *base_env
  116. variables:
  117. RAILS_ENV: "test"
  118. script:
  119. - bundle exec rake zammad:db:init
  120. - bundle exec rake test:units
  121. - bundle exec rails test test/integration/object_manager_test.rb
  122. - bundle exec rails test test/integration/package_test.rb
  123. test:unit:mysql:
  124. stage: test
  125. <<: *services_mysql
  126. <<: *script_unit_definition
  127. test:unit:postgresql:
  128. stage: test
  129. <<: *services_postgresql
  130. <<: *script_unit_definition
  131. ## Integration tests
  132. .test_integration_template: &test_integration_definition
  133. <<: *base_env
  134. <<: *services_random_db
  135. stage: test
  136. variables:
  137. RAILS_ENV: "test"
  138. test:integration:email_helper_deliver:
  139. <<: *test_integration_definition
  140. <<: *requires_mail_port_access
  141. script:
  142. - bundle exec rake zammad:db:unseeded
  143. - bundle exec rails test test/integration/email_helper_test.rb
  144. - bundle exec rails test test/integration/email_deliver_test.rb
  145. - bundle exec rails test test/integration/email_keep_on_server_test.rb
  146. test:integration:facebook:
  147. <<: *test_integration_definition
  148. script:
  149. - bundle exec rake zammad:db:init
  150. - bundle exec rails test test/integration/facebook_test.rb
  151. allow_failure: true
  152. test:integration:geo:
  153. <<: *test_integration_definition
  154. script:
  155. - bundle exec rake zammad:db:unseeded
  156. - bundle exec rails test test/integration/geo_calendar_test.rb
  157. - bundle exec rails test test/integration/geo_location_test.rb
  158. - bundle exec rails test test/integration/geo_ip_test.rb
  159. test:integration:user_agent:
  160. <<: *test_integration_definition
  161. script:
  162. - bundle exec rake zammad:db:unseeded
  163. - bundle exec rails test test/integration/user_agent_test.rb
  164. - export ZAMMAD_PROXY_TEST=true
  165. - bundle exec rails test test/integration/user_agent_test.rb
  166. allow_failure: true
  167. test:integration:slack:
  168. <<: *test_integration_definition
  169. script:
  170. - bundle exec rake zammad:db:unseeded
  171. - echo "gem 'slack-api'" >> Gemfile.local
  172. - bundle install -j $(nproc)
  173. - bundle exec rails test test/integration/slack_test.rb
  174. test:integration:clearbit:
  175. <<: *test_integration_definition
  176. script:
  177. - bundle exec rake zammad:db:unseeded
  178. - bundle exec rails test test/integration/clearbit_test.rb
  179. allow_failure: true
  180. ### Elasticsearch
  181. test:integration:es:
  182. <<: *base_env
  183. stage: test
  184. services:
  185. - name: registry.znuny.com/docker/zammad-mysql:latest
  186. alias: mysql
  187. - name: registry.znuny.com/docker/zammad-postgresql:latest
  188. alias: postgresql
  189. - name: registry.znuny.com/docker/zammad-elasticsearch:5.6
  190. alias: elasticsearch
  191. variables:
  192. RAILS_ENV: "test"
  193. ES_INDEX_RAND: "true"
  194. ES_URL: "http://elasticsearch:9200"
  195. script:
  196. - bundle exec rake zammad:db:unseeded
  197. - bundle exec rails test test/integration/elasticsearch_active_test.rb
  198. - bundle exec rails test test/integration/elasticsearch_test.rb
  199. - bundle exec rspec --tag searchindex
  200. - bundle exec rails test test/integration/report_test.rb
  201. ### Zendesk
  202. test:integration:zendesk:
  203. <<: *base_env
  204. <<: *services_random_db
  205. stage: test
  206. variables:
  207. RAILS_ENV: "test"
  208. script:
  209. - bundle exec rake zammad:db:unseeded
  210. - bundle exec rails test test/integration/zendesk_import_test.rb
  211. allow_failure: true
  212. ### OTRS
  213. .script_integration_otrs_template: &script_integration_otrs_definition
  214. <<: *base_env
  215. <<: *services_random_db
  216. stage: test
  217. script:
  218. - bundle exec rake zammad:db:unseeded
  219. - bundle exec rails test test/integration/otrs_import_test.rb
  220. test:integration:otrs_6:
  221. <<: *script_integration_otrs_definition
  222. variables:
  223. RAILS_ENV: "test"
  224. IMPORT_OTRS_ENDPOINT: "https://vz1185.test.znuny.com/otrs/public.pl?Action=ZammadMigrator"
  225. test:integration:otrs_5:
  226. <<: *script_integration_otrs_definition
  227. variables:
  228. RAILS_ENV: "test"
  229. IMPORT_OTRS_ENDPOINT: "http://vz1109.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
  230. test:integration:otrs_4:
  231. <<: *script_integration_otrs_definition
  232. variables:
  233. RAILS_ENV: "test"
  234. IMPORT_OTRS_ENDPOINT: "http://vz383.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
  235. test:integration:otrs_33:
  236. <<: *script_integration_otrs_definition
  237. variables:
  238. RAILS_ENV: "test"
  239. IMPORT_OTRS_ENDPOINT: "http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
  240. test:integration:otrs_32:
  241. <<: *script_integration_otrs_definition
  242. variables:
  243. RAILS_ENV: "test"
  244. IMPORT_OTRS_ENDPOINT: "http://vz382.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
  245. test:integration:otrs_31:
  246. <<: *script_integration_otrs_definition
  247. variables:
  248. RAILS_ENV: "test"
  249. IMPORT_OTRS_ENDPOINT: "http://vz381.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator"
  250. # Browser tests
  251. ## preparation (asset precompile)
  252. browser:build:
  253. <<: *base_env
  254. <<: *services_postgresql
  255. stage: test
  256. variables:
  257. RAILS_ENV: "production"
  258. script:
  259. - bundle exec rake zammad:db:unseeded
  260. - bundle exec rake assets:precompile
  261. artifacts:
  262. expire_in: 1 week
  263. paths:
  264. - public/assets/.sprockets-manifest*
  265. - public/assets/application-*
  266. - public/assets/print-*
  267. .services_browser_template: &services_browser_definition
  268. services:
  269. - name: registry.znuny.com/docker/zammad-mysql:latest
  270. alias: mysql
  271. - name: registry.znuny.com/docker/zammad-postgresql:latest
  272. alias: postgresql
  273. - name: registry.znuny.com/docker/zammad-elasticsearch:5.6
  274. alias: elasticsearch
  275. - name: docker.io/elgalu/selenium:3.14.0-p17
  276. alias: selenium
  277. - name: registry.znuny.com/docker/docker-imap-devel:latest
  278. alias: mail
  279. ## Browser core tests
  280. .variables_browser_template: &variables_browser_definition
  281. RAILS_ENV: "production"
  282. APP_RESTART_CMD: "bundle exec rake zammad:ci:app:restart"
  283. .test_browser_core_template: &test_browser_core_definition
  284. <<: *base_env
  285. stage: browser-core
  286. dependencies:
  287. - browser:build
  288. ## Capybara
  289. .test_capybara_template: &test_capybara_definition
  290. <<: *test_browser_core_definition
  291. script:
  292. - bundle exec rake zammad:ci:test:prepare[with_elasticsearch]
  293. - bundle exec rspec --fail-fast -t type:system
  294. .variables_capybara_chrome_template: &variables_capybara_chrome_definition
  295. <<: *test_capybara_definition
  296. variables:
  297. RAILS_ENV: "test"
  298. BROWSER: "chrome"
  299. .variables_capybara_ff_template: &variables_capybara_ff_definition
  300. <<: *test_capybara_definition
  301. variables:
  302. RAILS_ENV: "test"
  303. BROWSER: "firefox"
  304. test:browser:core:capybara_chrome:
  305. <<: *variables_capybara_chrome_definition
  306. <<: *services_browser_definition
  307. test:browser:core:capybara_ff:
  308. <<: *variables_capybara_ff_definition
  309. <<: *services_browser_definition
  310. ### API clients
  311. test:browser:integration:api_client_ruby:
  312. <<: *test_browser_core_definition
  313. <<: *services_random_db
  314. variables:
  315. <<: *variables_browser_definition
  316. script:
  317. - RAILS_ENV=test bundle exec rake db:create
  318. - cp contrib/auto_wizard_test.json auto_wizard.json
  319. - bundle exec rake zammad:ci:test:start
  320. - git clone https://github.com/zammad/zammad-api-client-ruby.git
  321. - cd zammad-api-client-ruby
  322. - bundle install -j $(nproc)
  323. - bundle exec rspec
  324. test:browser:integration:api_client_php:
  325. <<: *test_browser_core_definition
  326. <<: *services_random_db
  327. variables:
  328. <<: *variables_browser_definition
  329. ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL: "http://localhost:3000"
  330. ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME: "master@example.com"
  331. ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD: "test"
  332. script:
  333. - RAILS_ENV=test bundle exec rake db:create
  334. - bundle exec rake zammad:ci:test:start zammad:setup:auto_wizard
  335. - git clone https://github.com/zammad/zammad-api-client-php.git
  336. - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  337. - php composer-setup.php --install-dir=/usr/local/bin
  338. - ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
  339. - cd zammad-api-client-php
  340. - composer install
  341. - vendor/bin/phpunit
  342. ### Browser test slices
  343. #### Templates
  344. .script_browser_slice_template: &script_browser_slice_definition
  345. script:
  346. # temporary workaround to check Yahoo! mailbox only in test:browser:core:ff_3_* tests
  347. - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_AUTO1 ; fi
  348. - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_AUTO2 ; fi
  349. - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_MANUAL1 ; fi
  350. - if [[ $CI_JOB_NAME != test:browser:core:ff_3_* ]]; then unset MAILBOX_MANUAL2 ; fi
  351. - env
  352. - script/build/test_slice_tests.sh $TEST_SLICE
  353. - RAILS_ENV=test bundle exec rake db:create
  354. - bundle exec rake zammad:ci:test:start[with_elasticsearch]
  355. - time bundle exec rails test --fail-fast test/browser
  356. .test_browser_core_base_template: &test_browser_core_base_definition
  357. <<: *test_browser_core_definition
  358. <<: *script_browser_slice_definition
  359. <<: *services_browser_definition
  360. #### Firefox
  361. test:browser:core:ff_1:
  362. <<: *test_browser_core_base_definition
  363. variables:
  364. <<: *variables_browser_definition
  365. BROWSER: "firefox"
  366. TEST_SLICE: "1"
  367. test:browser:core:ff_2:
  368. <<: *test_browser_core_base_definition
  369. variables:
  370. <<: *variables_browser_definition
  371. BROWSER: "firefox"
  372. TEST_SLICE: "2"
  373. test:browser:core:ff_3:
  374. <<: *test_browser_core_base_definition
  375. <<: *requires_mail_port_access
  376. variables:
  377. <<: *variables_browser_definition
  378. BROWSER: "firefox"
  379. TEST_SLICE: "3"
  380. test:browser:core:ff_4:
  381. <<: *test_browser_core_base_definition
  382. variables:
  383. <<: *variables_browser_definition
  384. BROWSER: "firefox"
  385. TEST_SLICE: "4"
  386. test:browser:core:ff_5:
  387. <<: *test_browser_core_base_definition
  388. variables:
  389. <<: *variables_browser_definition
  390. BROWSER: "firefox"
  391. TEST_SLICE: "5"
  392. test:browser:core:ff_6:
  393. <<: *test_browser_core_base_definition
  394. variables:
  395. <<: *variables_browser_definition
  396. BROWSER: "firefox"
  397. TEST_SLICE: "6"
  398. ### Chrome
  399. test:browser:core:chrome_1:
  400. <<: *test_browser_core_base_definition
  401. variables:
  402. <<: *variables_browser_definition
  403. BROWSER: "chrome"
  404. TEST_SLICE: "1"
  405. test:browser:core:chrome_2:
  406. <<: *test_browser_core_base_definition
  407. variables:
  408. <<: *variables_browser_definition
  409. BROWSER: "chrome"
  410. TEST_SLICE: "2"
  411. test:browser:core:chrome_3:
  412. <<: *test_browser_core_base_definition
  413. variables:
  414. <<: *variables_browser_definition
  415. BROWSER: "chrome"
  416. TEST_SLICE: "3"
  417. test:browser:core:chrome_4:
  418. <<: *test_browser_core_base_definition
  419. variables:
  420. <<: *variables_browser_definition
  421. BROWSER: "chrome"
  422. TEST_SLICE: "4"
  423. test:browser:core:chrome_5:
  424. <<: *test_browser_core_base_definition
  425. variables:
  426. <<: *variables_browser_definition
  427. BROWSER: "chrome"
  428. TEST_SLICE: "5"
  429. test:browser:core:chrome_6:
  430. <<: *test_browser_core_base_definition
  431. variables:
  432. <<: *variables_browser_definition
  433. BROWSER: "chrome"
  434. TEST_SLICE: "6"
  435. ### Auto wizard
  436. .auto_wizard_services_template: &auto_wizard_services
  437. services:
  438. - name: registry.znuny.com/docker/zammad-postgresql:latest
  439. alias: postgresql
  440. - name: docker.io/elgalu/selenium:3.14.0-p17
  441. alias: selenium
  442. .test_browser_integration_template: &test_browser_integration_definition
  443. <<: *base_env
  444. <<: *auto_wizard_services
  445. stage: browser-integration
  446. dependencies:
  447. - browser:build
  448. .script_integration_auto_wizard_template: &script_integration_auto_wizard_definition
  449. script:
  450. - RAILS_ENV=test bundle exec rake db:create
  451. - cp $AUTO_WIZARD_FILE auto_wizard.json
  452. - bundle exec rake zammad:ci:test:start
  453. - bundle exec rails test $TEST_FILE
  454. .browser_core_auto_wizard_template: &browser_core_auto_wizard_definition
  455. <<: *test_browser_core_definition
  456. <<: *auto_wizard_services
  457. <<: *script_integration_auto_wizard_definition
  458. test:browser:autowizard_chrome:
  459. <<: *browser_core_auto_wizard_definition
  460. variables:
  461. <<: *variables_browser_definition
  462. BROWSER: "chrome"
  463. AUTO_WIZARD_FILE: "contrib/auto_wizard_example.json"
  464. TEST_FILE: "test/integration/auto_wizard_browser_test.rb"
  465. test:browser:autowizard_ff:
  466. <<: *browser_core_auto_wizard_definition
  467. variables:
  468. <<: *variables_browser_definition
  469. BROWSER: "firefox"
  470. AUTO_WIZARD_FILE: "contrib/auto_wizard_example.json"
  471. TEST_FILE: "test/integration/auto_wizard_browser_test.rb"
  472. ### Browser integration tests
  473. .browser_integration_auto_wizard_template: &browser_integration_auto_wizard_definition
  474. <<: *test_browser_integration_definition
  475. <<: *script_integration_auto_wizard_definition
  476. test:browser:integration:twitter_chrome:
  477. <<: *browser_integration_auto_wizard_definition
  478. variables:
  479. <<: *variables_browser_definition
  480. BROWSER: "chrome"
  481. AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json"
  482. TEST_FILE: "test/integration/twitter_browser_test.rb"
  483. test:browser:integration:twitter_ff:
  484. <<: *browser_integration_auto_wizard_definition
  485. variables:
  486. <<: *variables_browser_definition
  487. BROWSER: "firefox"
  488. AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json"
  489. TEST_FILE: "test/integration/twitter_browser_test.rb"
  490. test:browser:integration:facebook_chrome:
  491. <<: *browser_integration_auto_wizard_definition
  492. variables:
  493. <<: *variables_browser_definition
  494. BROWSER: "chrome"
  495. AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json"
  496. TEST_FILE: "test/integration/facebook_browser_test.rb"
  497. test:browser:integration:facebook_ff:
  498. <<: *browser_integration_auto_wizard_definition
  499. variables:
  500. <<: *variables_browser_definition
  501. BROWSER: "firefox"
  502. AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json"
  503. TEST_FILE: "test/integration/facebook_browser_test.rb"
  504. test:browser:integration:idoit_chrome:
  505. <<: *browser_integration_auto_wizard_definition
  506. variables:
  507. <<: *variables_browser_definition
  508. BROWSER: "chrome"
  509. AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json"
  510. TEST_FILE: "test/integration/idoit_browser_test.rb"
  511. ### Browser integration tests
  512. .variables_browser_import_template: &variables_browser_import_definition
  513. BROWSER: "chrome"
  514. RAILS_SERVE_STATIC_FILES: "true"
  515. RAILS_ENV: "production"
  516. .browser_integration_import_template: &browser_integration_import_definition
  517. <<: *test_browser_integration_definition
  518. script:
  519. - RAILS_ENV=test bundle exec rake db:create
  520. - bundle exec rake zammad:ci:test:start
  521. - bundle exec rails test $TEST_FILE
  522. test:browser:integration:otrs_chrome:
  523. <<: *browser_integration_import_definition
  524. variables:
  525. <<: *variables_browser_import_definition
  526. TEST_FILE: "test/integration/otrs_import_browser_test.rb"
  527. test:browser:integration:zendesk_chrome:
  528. <<: *browser_integration_import_definition
  529. variables:
  530. <<: *variables_browser_import_definition
  531. TEST_FILE: "test/integration/zendesk_import_browser_test.rb"