test_frontend.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. npm run test:run
  21. test_rc=$?
  22. # The production build and its browser baseline check, into a temporary
  23. # directory: the tracked static/ is only rebuilt on purpose.
  24. build_dir=$(mktemp -d)
  25. npx vite build --outDir "$build_dir" --emptyOutDir && node scripts/check-browser-baseline.mjs "$build_dir/assets"
  26. build_rc=$?
  27. rm -rf "$build_dir"
  28. cd ..
  29. if [ $typecheck_rc -ne 0 ] || [ $lint_rc -ne 0 ] || [ $knip_rc -ne 0 ] || [ $test_rc -ne 0 ] || [ $build_rc -ne 0 ]; then
  30. echo "FAILED: typecheck=$typecheck_rc lint=$lint_rc knip=$knip_rc tests=$test_rc build=$build_rc"
  31. exit 1
  32. fi