Files
computer-playbook/roles/test-e2e-playwright/files/archive_playwright_reports.sh
kevinveenbirkenbachandClaude Opus 4.7 0aa34b903e feat(playwright): persist artifacts per variant+pass, add Time column
- Matrix-deploy orchestrator now pushes `VARIANT_INDEX` (0-based round
  id) alongside the existing `ASYNC_ENABLED` extra var for both PASS 1
  (sync) and PASS 2 (async) runs. Test-e2e-playwright's archive step
  consumes both to derive a per-(variant, pass) destination so a
  subsequent round cannot overwrite the previous one's reports.
- New `roles/test-e2e-playwright/files/archive_playwright_reports.sh`
  moves the playwright-junit.xml / playwright-report/ / test-results/
  outputs into `variant-<N>/<sync|async>/` under the role's reports
  dir, idempotently (re-running the same tuple replaces rather than
  fails). `run_one.yml` invokes the script via `ansible.builtin.script`
  so the YAML stays a single 7-line task.
- `VARIANT_INDEX: 0` lives in `defaults/main.yml` to keep the variable
  defined for dev / non-matrix invocations. Role defaults are not
  considered SPOT, so the `| default(0)` belt-and-suspenders inside
  the script invocation stays valid against the spot-default lint.
- Summary script now renders an 8-column table: Time | App | Variant |
  Pass | Test | Status | Duration | Message. Per-test ISO timestamps
  are derived from the JUnit `<testsuite timestamp>` attribute plus the
  cumulative duration of preceding cases; file mtime is the fallback
  when the attribute is absent. App / Variant / Pass are extracted
  from the artefact path layout produced by the archive script.
- Matrix-deploy unit tests refreshed to expect the new
  `extra_ansible_vars` shape; summary unit tests gain coverage for
  `_to_iso_z`, `_parse_iso_timestamp`, the four supported path
  layouts, and the file-mtime fallback (55 tests total).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 15:30:06 +02:00

35 lines
887 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Usage: archive_playwright_reports.sh <reports_dir> <variant_index> <async_enabled>
#
# Move playwright-junit.xml / playwright-report/ / test-results/ from
# <reports_dir> into <reports_dir>/variant-N/{sync|async}/ so subsequent
# invocations of the test-e2e-playwright role cannot overwrite them.
# Idempotent: an existing slot is replaced rather than refused.
if [ "$#" -ne 3 ]; then
echo "usage: $0 <reports_dir> <variant_index> <async_enabled>" >&2
exit 2
fi
reports_dir="$1"
variant_index="$2"
async_enabled="$3"
case "$async_enabled" in
true | True | TRUE | 1) pass="async" ;;
*) pass="sync" ;;
esac
subdir="variant-${variant_index}/${pass}"
cd "$reports_dir"
mkdir -p "$subdir"
for item in playwright-junit.xml playwright-report test-results; do
if [ -e "$item" ]; then
rm -rf "${subdir:?}/$item"
mv "$item" "$subdir/"
fi
done