Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. SHELL := /bin/bash
  2. .SHELLFLAGS := -eu -o pipefail -c
  3. BIN := bin/viewer
  4. .PHONY: build test clean deps e2e-install
  5. build: deps
  6. npm --prefix frontend ci
  7. npm --prefix frontend run build
  8. go build -o $(BIN) ./cmd/viewer
  9. deps:
  10. go mod tidy
  11. e2e-install:
  12. npm --prefix e2e ci
  13. npx --prefix e2e playwright install --with-deps chromium
  14. test: build e2e-install
  15. mkdir -p .cache
  16. set -a; \
  17. if [ -f .env.test ]; then \
  18. . ./.env.test; \
  19. else \
  20. echo "missing .env.test (copy from .env.test.example and fill S3 credentials)"; \
  21. exit 1; \
  22. fi; \
  23. set +a; \
  24. : "$${S3_ENDPOINT:?S3_ENDPOINT is required in .env.test}"; \
  25. : "$${S3_BUCKET:?S3_BUCKET is required in .env.test}"; \
  26. : "$${S3_ACCESS_KEY:?S3_ACCESS_KEY is required in .env.test}"; \
  27. : "$${S3_SECRET_KEY:?S3_SECRET_KEY is required in .env.test}"; \
  28. : "$${PORT:=8080}"; \
  29. : "$${E2E_BASE_URL:=http://127.0.0.1:$${PORT}}"; \
  30. : "$${SCREENSHOT_DIR:=./samples}"; \
  31. if [[ "$${SCREENSHOT_DIR}" != /* ]]; then SCREENSHOT_DIR="$$(pwd)/$${SCREENSHOT_DIR}"; fi; \
  32. mkdir -p "$${SCREENSHOT_DIR}"; \
  33. ./$(BIN) > .cache/e2e-server.log 2>&1 & \
  34. SERVER_PID=$$!; \
  35. trap 'kill $$SERVER_PID >/dev/null 2>&1 || true' EXIT; \
  36. for i in $$(seq 1 60); do \
  37. if curl -fsS "http://127.0.0.1:$${PORT}/healthz" >/dev/null; then break; fi; \
  38. sleep 1; \
  39. done; \
  40. curl -fsS "http://127.0.0.1:$${PORT}/healthz" >/dev/null; \
  41. E2E_BASE_URL="$${E2E_BASE_URL}" SCREENSHOT_DIR="$${SCREENSHOT_DIR}" npm --prefix e2e test
  42. clean:
  43. rm -rf bin .cache frontend/node_modules e2e/node_modules