test_frontend.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. # Typecheck, lint and knip run in parallel (all read-only and independent),
  3. # then the tests (with the i18n parity check), then the production build. Exits non-zero if any step fails, so a type or lint error
  4. # can't scroll past unnoticed behind a green test run.
  5. cd frontend || exit 1
  6. npm run typecheck > /tmp/bambuddy-typecheck.$$ 2>&1 &
  7. typecheck_pid=$!
  8. npm run lint > /tmp/bambuddy-lint.$$ 2>&1 &
  9. lint_pid=$!
  10. npm run check:knip > /tmp/bambuddy-knip.$$ 2>&1 &
  11. knip_pid=$!
  12. wait $typecheck_pid
  13. typecheck_rc=$?
  14. wait $lint_pid
  15. lint_rc=$?
  16. wait $knip_pid
  17. knip_rc=$?
  18. cat /tmp/bambuddy-typecheck.$$ /tmp/bambuddy-lint.$$ /tmp/bambuddy-knip.$$
  19. rm -f /tmp/bambuddy-typecheck.$$ /tmp/bambuddy-lint.$$ /tmp/bambuddy-knip.$$
  20. # Console output of passing tests is hidden; a failing test still shows its own.
  21. npx vitest run --silent=passed-only && npm run check:i18n
  22. test_rc=$?
  23. # The production build and its browser baseline check, into a temporary
  24. # directory: the tracked static/ is only rebuilt on purpose.
  25. build_dir=$(mktemp -d)
  26. npx vite build --outDir "$build_dir" --emptyOutDir && node scripts/check-browser-baseline.mjs "$build_dir/assets"
  27. build_rc=$?
  28. rm -rf "$build_dir"
  29. cd ..
  30. if [ $typecheck_rc -ne 0 ] || [ $lint_rc -ne 0 ] || [ $knip_rc -ne 0 ] || [ $test_rc -ne 0 ] || [ $build_rc -ne 0 ]; then
  31. echo "FAILED: typecheck=$typecheck_rc lint=$lint_rc knip=$knip_rc tests=$test_rc build=$build_rc"
  32. exit 1
  33. fi