1
0
forked from baron/baron-sso
Files
baron-sso/scripts/run_adminfront_ci_tests.sh
2026-04-09 16:45:26 +09:00

113 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
job_name="${1:-adminfront-tests}"
mkdir -p reports
if [ -n "${CI:-}" ]; then
playwright_install_cmd=(npx playwright install --with-deps)
playwright_install_desc="npx playwright install --with-deps"
else
playwright_install_cmd=(npx playwright install)
playwright_install_desc="npx playwright install"
fi
playwright_cache_dir="${HOME}/.cache/ms-playwright"
playwright_chromium_complete="${playwright_cache_dir}/chromium-1208/INSTALLATION_COMPLETE"
playwright_firefox_complete="${playwright_cache_dir}/firefox-1509/INSTALLATION_COMPLETE"
playwright_webkit_complete="${playwright_cache_dir}/webkit-2248/INSTALLATION_COMPLETE"
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
if [ -f "$playwright_chromium_complete" ] && \
[ -f "$playwright_firefox_complete" ] && \
[ -f "$playwright_webkit_complete" ]; then
echo "Playwright browsers already installed"
else
"${playwright_install_cmd[@]}"
fi
) 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 && ${playwright_install_desc}\`"
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. \`${playwright_install_desc}\`"
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"