---
- name: π Define per-role paths
ansible.builtin.set_fact:
_playwright_env_template: "{{ lookup('path_absolute', 'roles', application_id, 'templates/playwright.env.j2') }}"
_playwright_files_dir: "{{ lookup('path_absolute', 'roles', application_id, 'files/playwright') }}"
_playwright_spec_src: "{{ lookup('path_absolute', 'roles', application_id, 'files/playwright/playwright.spec.js') }}"
_playwright_stage_dir: "{{ TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR }}/{{ application_id }}"
_playwright_stage_tests_dir: "{{ TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR }}/{{ application_id }}/tests"
_playwright_tree_archive: "/tmp/infinito-playwright-{{ application_id }}.tar"
_playwright_reports_dir: "{{ TEST_E2E_PLAYWRIGHT_REPORTS_BASE_DIR }}/{{ application_id }}"
- name: β
Assert required Playwright env template exists
ansible.builtin.stat:
path: "{{ _playwright_env_template }}"
register: _env_template_stat
delegate_to: localhost
become: false
- name: π Fail if Playwright env template is missing
ansible.builtin.fail:
msg: "Missing Playwright env template: {{ _playwright_env_template }}"
when: not _env_template_stat.stat.exists
- name: β
Assert required Playwright spec exists
ansible.builtin.stat:
path: "{{ _playwright_spec_src }}"
register: _spec_stat
delegate_to: localhost
become: false
- name: π Fail if Playwright spec is missing
ansible.builtin.fail:
msg: "Missing Playwright spec file: {{ _playwright_spec_src }}"
when: not _spec_stat.stat.exists
- name: π Check optional application vars file
ansible.builtin.stat:
path: "{{ lookup('path_absolute', 'roles', application_id, 'vars/main.yml') }}"
register: _playwright_app_vars_stat
delegate_to: localhost
become: false
- name: βοΈ Load optional application vars
ansible.builtin.include_vars:
file: "{{ lookup('path_absolute', 'roles', application_id, 'vars/main.yml') }}"
when: _playwright_app_vars_stat.stat.exists
- name: π Recreate staging directory
ansible.builtin.file:
path: "{{ _playwright_stage_dir }}"
state: absent
- name: π Create staging directory
ansible.builtin.file:
path: "{{ _playwright_stage_dir }}"
state: directory
mode: "0755"
- name: π Create staging tests directory
ansible.builtin.file:
path: "{{ _playwright_stage_tests_dir }}"
state: directory
mode: "0755"
- name: π Render package.json from template
ansible.builtin.template: # nocheck: stack-host-template (per-host playwright stage dir, runs on every test host)
src: "{{ _playwright_default_package_template }}"
dest: "{{ _playwright_stage_dir }}/package.json"
mode: "0644"
- name: π Copy central default playwright.config.js
ansible.builtin.copy:
src: "{{ _playwright_default_config_js }}"
dest: "{{ _playwright_stage_dir }}/playwright.config.js"
mode: "0644"
- name: π¦ Pack the role's Playwright tree for a single transfer
ansible.builtin.command:
argv: [tar, -cf, "{{ _playwright_tree_archive }}", -C, "{{ _playwright_files_dir }}", .]
delegate_to: localhost
become: false
changed_when: false
- name: π Stage the Playwright tree and the shared helpers
ansible.builtin.unarchive:
src: "{{ playwright_archive }}"
dest: "{{ _playwright_stage_tests_dir }}/"
extra_opts: [--no-same-owner]
loop:
- "{{ _playwright_tree_archive }}"
- "{{ TEST_E2E_PLAYWRIGHT_HELPERS_ARCHIVE }}"
loop_control:
loop_var: playwright_archive
- name: β
Ensure staging volume directory exists
ansible.builtin.file:
path: "{{ _playwright_stage_dir }}/volume"
state: directory
mode: "0755"
- name: π Collect host disk diagnostics before Playwright
ansible.builtin.script: "{{ role_path }}/files/dump_disk_diagnostics.sh"
changed_when: false
when: MODE_DEBUG | bool
- name: π² Pick the network this role is tested on
ansible.builtin.set_fact:
_playwright_network_picks: >-
{{ _playwright_network_picks
| combine({application_id: lookup('domain', application_id)
if lookup('config', application_id, 'networks.reachability.handover', False)
else lookup('network_siblings', lookup('domain', application_id)) | random}) }}
when: application_id not in _playwright_network_picks
- name: π Run Playwright on the picked network
ansible.builtin.include_tasks: 03_run_pass.yml
vars:
_playwright_passes: "{{ lookup('network_siblings', lookup('domain', application_id)) }}"
_playwright_pass_domain: "{{ _playwright_network_picks[application_id] }}"
_playwright_pass_reports_dir: >-
{{ _playwright_reports_dir if _playwright_pass_domain == _playwright_passes[0]
else _playwright_reports_dir ~ '+' ~ (_playwright_pass_domain | network_of) }}