perf(test-e2e-playwright): stage each role's Playwright tree as one tarball

ansible.builtin.copy moved the 66-file Nextcloud tree file by file at about 0.46 s each (30.8 s per run in the deploy log), and the shared helpers followed in a loop of their own. The role tree is now packed on the controller and unpacked in one unarchive, together with a helper archive packed once per run, the pattern the persona flows already use. A replica of the real tasks staged a tree identical to the copy result (71/71 files, root-owned, 0644/0755) in 1.4 s instead of 24.3 s.

test_playwright_helpers_staged now checks the helper glob where it moved: TEST_E2E_PLAYWRIGHT_HELPERS_DIR in vars/main.yml and the fileglob query in 01_setup.yml.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-28 16:26:38 +01:00
1 parent 8ab950f13c
commit 1002909f8c
4 files changed
+40 -17

No files matched your search

@@ -20,6 +20,18 @@
become: false
changed_when: false
- name: 📦 Pack the shared Playwright helpers for a single transfer per role
ansible.builtin.command:
argv: >-
{{
['tar', '-cf', TEST_E2E_PLAYWRIGHT_HELPERS_ARCHIVE, '-C', TEST_E2E_PLAYWRIGHT_HELPERS_DIR]
+ (query('fileglob', TEST_E2E_PLAYWRIGHT_HELPERS_DIR ~ '/*.js')
| map('basename') | reject('equalto', 'playwright.config.js') | list)
}}
delegate_to: localhost
become: false
changed_when: false
- name: ✅ Ensure the shared personas dir exists
ansible.builtin.file:
path: "{{ TEST_E2E_PLAYWRIGHT_SHARED_PERSONAS }}"
+17 -14
View File
@@ -6,6 +6,7 @@
_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 }}"
_playwright_default_package_template: "{{ lookup('path_absolute', 'roles/test-e2e-playwright/templates/package.json.j2') }}"
_playwright_default_config_js: "{{ lookup('path_absolute', 'roles/test-e2e-playwright/files/playwright.config.js') }}"
@@ -142,21 +143,23 @@
dest: "{{ _playwright_stage_dir }}/playwright.config.js"
mode: "0644"
- name: 📋 Copy Playwright tree (spec + companions + addons/ + fixtures/) to staging
ansible.builtin.copy:
src: "{{ _playwright_files_dir }}/"
dest: "{{ _playwright_stage_tests_dir }}/"
mode: "0644"
directory_mode: "0755"
- 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: 📋 Copy shared Playwright helpers into staging tests directory
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ _playwright_stage_tests_dir }}/{{ item | basename }}"
mode: "0644"
when: (item | basename) != 'playwright.config.js'
with_fileglob:
- "{{ lookup('path_absolute', 'roles/test-e2e-playwright/files') }}/*.js"
- 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:
+2
View File
@@ -24,6 +24,8 @@ TEST_E2E_PLAYWRIGHT_SHARED_DIR: "{{ TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR }}/_share
TEST_E2E_PLAYWRIGHT_SHARED_NODE_MODULES: "{{ TEST_E2E_PLAYWRIGHT_SHARED_DIR }}/node_modules"
TEST_E2E_PLAYWRIGHT_SHARED_PERSONAS: "{{ TEST_E2E_PLAYWRIGHT_SHARED_DIR }}/personas"
TEST_E2E_PLAYWRIGHT_PERSONAS_ARCHIVE: "/tmp/infinito-playwright-personas.tar"
TEST_E2E_PLAYWRIGHT_HELPERS_DIR: "{{ lookup('path_absolute', 'roles/test-e2e-playwright/files') }}"
TEST_E2E_PLAYWRIGHT_HELPERS_ARCHIVE: "/tmp/infinito-playwright-helpers.tar"
TEST_E2E_PLAYWRIGHT_SHARED_STAMP: "{{ TEST_E2E_PLAYWRIGHT_SHARED_DIR }}/.installed-version"
TEST_E2E_PLAYWRIGHT_IS_ONION: "{{ lookup('tls', application_id, 'url.base') is search('\\.onion') }}"
@@ -31,7 +31,8 @@ from utils.cache.files import (
_RULE = "playwright-helper-staged"
RUNNER_FILES = PROJECT_ROOT / "roles/test-e2e-playwright/files"
STAGING_TASK = PROJECT_ROOT / "roles/test-e2e-playwright/tasks/02_run_one.yml"
STAGING_TASK = PROJECT_ROOT / "roles/test-e2e-playwright/tasks/01_setup.yml"
STAGING_VARS = PROJECT_ROOT / "roles/test-e2e-playwright/vars/main.yml"
RERUN_SCRIPT = PROJECT_ROOT / "scripts/tests/e2e/rerun-spec.sh"
LINT_SCRIPT = PROJECT_ROOT / "scripts/lint/playwright.sh"
@@ -41,7 +42,11 @@ _MOUNTED_AS_DIRECTORY = frozenset({"personas"})
_NOT_A_HELPER = frozenset({"playwright.config.js"})
_GLOB_MARKER = "roles/test-e2e-playwright/files') }}/*.js"
_GLOB_MARKER = "query('fileglob', TEST_E2E_PLAYWRIGHT_HELPERS_DIR ~ '/*.js')"
_DIR_MARKER = (
"TEST_E2E_PLAYWRIGHT_HELPERS_DIR: "
"\"{{ lookup('path_absolute', 'roles/test-e2e-playwright/files') }}\""
)
_SHELL_GLOB_MARKER = 'roles/test-e2e-playwright/files"/*.js'
_LINT_GLOB_MARKER = '"${HELPERS_SRC}"/*.js'
@@ -88,7 +93,7 @@ def unstaged_requires() -> list[str]:
if f"{name}.js" not in staged:
findings.append(
f"{path}:{index}: requires {name!r}, which is neither a "
f"sibling spec nor staged by 02_run_one.yml"
f"sibling spec nor staged by 01_setup.yml"
)
return findings
@@ -105,6 +110,7 @@ def stagers_without_the_glob() -> list[str]:
findings = []
for path, marker in (
(STAGING_TASK, _GLOB_MARKER),
(STAGING_VARS, _DIR_MARKER),
(RERUN_SCRIPT, _SHELL_GLOB_MARKER),
(LINT_SCRIPT, _LINT_GLOB_MARKER),
):