-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.yml
79 lines (67 loc) · 2.86 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
- hosts: localhost
connection: local
gather_facts: no
vars:
workspace_root: .
artifacts_file: commentinfo.md
build_reports_dir: build_reports
behat_base_url: http://drupal.192.168.56.132.xip.io # WITHOUT TRAILING SLASH
behat_drupal_root: /var/www/docroot
resources_path: /var/www/tests/behat/resources
behat_root: '../tests/behat'
config_file: behat.yml
features_dir: features
browser: 'chrome'
selenium_url: 127.0.0.1:4444/wd/hub
run_javascript_tests: 'no'
update_dependencies: 'yes'
selenium_jar_path: /var/lib/selenium/selenium.jar
chrome_driver_path: /var/lib/chrome-driver/chromedriver
tasks:
- name: Install behat dependencies from composer.json
shell: "cd {{ behat_root }} && composer up"
when: update_dependencies == 'yes'
- name: Create dynamic behat.yml
template: src={{ behat_root }}/behat.yml.j2 dest={{ behat_root }}/behat.yml
- name: Ensure that xvfb is run
service: name=xvfb state=started
when: run_javascript_tests == 'yes'
- name: Export display and enable Chrome
shell: firefox & # Add exclusion for firefox
environment:
DISPLAY: ':99'
when: run_javascript_tests == 'yes'
- name: Run Selenium standalone with Chrome
become: yes
shell: java -jar {{ selenium_jar_path }} -log selenium.log -Dwebdriver.chrome.driver={{ chrome_driver_path }} &
environment:
DISPLAY: ':99'
when: run_javascript_tests == 'yes' and browser == 'chrome'
- name: Run Selenium standalone with Firefox
become: yes
shell: java -jar {{ selenium_jar_path }} -log selenium.log &
environment:
DISPLAY: ':99'
when: run_javascript_tests == 'yes' and browser == 'firefox'
- name: Wait until Selenium starts
wait_for: port=4444 delay=10 host=127.0.0.1
when: run_javascript_tests == 'yes'
- name: Create directory for build reports
become: yes
file: path={{ behat_drupal_root }}/{{ build_reports_dir }} state=directory mode=0777
- name: Run full Behat tests
ignore_errors: yes
environment:
DISPLAY: ':99'
shell: 'echo "Behat tests: standard file {{ behat_base_url }}/{{ build_reports_dir }}/report.html" >> {{ workspace_root }}/{{ artifacts_file }} && cd {{ behat_root }} && bin/behat --config {{ config_file }} {{ features_dir }}'
when: run_javascript_tests == 'yes'
- name: Run headless Behat tests
ignore_errors: yes
shell: 'echo "Behat tests: standard file {{ behat_base_url }}/{{ build_reports_dir }}/report.html" >> {{ workspace_root }}/{{ artifacts_file }} && cd {{ behat_root }} && bin/behat --config {{ config_file }} {{ features_dir }} --tags "~@javascript"'
when: run_javascript_tests == 'no'
post_tasks:
- name: Kill the Selenium process
become: yes
shell: kill `ps wuax | grep 'java -jar {{ selenium_jar_path }}' | grep -v grep | awk '{print $2}'`
when: run_javascript_tests == 'yes'