#!/usr/bin/env bash set -euo pipefail job_name="${1:-adminfront-tests}" mkdir -p reports set +e ( cd adminfront npm ci ) 2>&1 | tee reports/adminfront-install.log install_exit_code=${PIPESTATUS[0]} set -e if [ "$install_exit_code" -ne 0 ]; then { echo "# Adminfront Test Failure Report" echo echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`" echo "- Job: \`${job_name}\`" echo "- Reason: \`Dependency install failed\`" echo "- Exit Code: \`$install_exit_code\`" echo echo "## Command" echo "\`cd adminfront && npm ci\`" echo echo "## Install Log Tail (last 200 lines)" echo '```text' tail -n 200 reports/adminfront-install.log echo '```' } > reports/adminfront-test-failure-report.md exit 1 fi set +e ( cd adminfront npx playwright install --with-deps ) 2>&1 | tee reports/adminfront-provision.log provision_exit_code=${PIPESTATUS[0]} set -e if [ "$provision_exit_code" -ne 0 ]; then { echo "# Adminfront Test Failure Report" echo echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`" echo "- Job: \`${job_name}\`" echo "- Reason: \`Browser provisioning failed\`" echo "- Exit Code: \`$provision_exit_code\`" echo echo "## Command" echo "\`cd adminfront && npx playwright install --with-deps\`" echo echo "## Provision Log Tail (last 200 lines)" echo '```text' tail -n 200 reports/adminfront-provision.log echo '```' } > reports/adminfront-test-failure-report.md exit 1 fi set +e ( cd adminfront npm test ) 2>&1 | tee reports/adminfront-test.log test_exit_code=${PIPESTATUS[0]} set -e if [ "$test_exit_code" -ne 0 ]; then { echo "# Adminfront Test Failure Report" echo echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`" echo "- Job: \`${job_name}\`" echo "- Exit Code: \`$test_exit_code\`" echo echo "## Commands" echo "1. \`cd adminfront\`" echo "2. \`npm ci\`" echo "3. \`npx playwright install --with-deps\`" echo "4. \`npm test\`" echo echo "## Log Tail (last 200 lines)" echo '```text' tail -n 200 reports/adminfront-test.log echo '```' } > reports/adminfront-test-failure-report.md fi exit "$test_exit_code"