Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # This file was auto-generated, do not edit it directly.
  2. # Instead run bin/update_build_scripts from
  3. # https://github.com/overleaf/internal/
  4. BUILD_NUMBER ?= local
  5. BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
  6. PROJECT_NAME = clsi
  7. BUILD_DIR_NAME = $(shell pwd | xargs basename | tr -cd '[a-zA-Z0-9_.\-]')
  8. DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
  9. DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
  10. BRANCH_NAME=$(BRANCH_NAME) \
  11. PROJECT_NAME=$(PROJECT_NAME) \
  12. MOCHA_GREP=${MOCHA_GREP} \
  13. docker compose ${DOCKER_COMPOSE_FLAGS}
  14. DOCKER_COMPOSE_TEST_ACCEPTANCE = \
  15. COMPOSE_PROJECT_NAME=test_acceptance_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
  16. DOCKER_COMPOSE_TEST_UNIT = \
  17. COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
  18. clean:
  19. -docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
  20. -docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
  21. -docker rmi us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
  22. -$(DOCKER_COMPOSE_TEST_UNIT) down --rmi local
  23. -$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down --rmi local
  24. HERE=$(shell pwd)
  25. MONOREPO=$(shell cd ../../ && pwd)
  26. # Run the linting commands in the scope of the monorepo.
  27. # Eslint and prettier (plus some configs) are on the root.
  28. RUN_LINTING = docker run --rm -v $(MONOREPO):$(MONOREPO) -w $(HERE) node:18.20.2 npm run --silent
  29. # Same but from the top of the monorepo
  30. RUN_LINTING_MONOREPO = docker run --rm -v $(MONOREPO):$(MONOREPO) -w $(MONOREPO) node:18.20.2 npm run --silent
  31. format:
  32. $(RUN_LINTING) format
  33. format_fix:
  34. $(RUN_LINTING) format:fix
  35. lint:
  36. $(RUN_LINTING) lint
  37. lint_fix:
  38. $(RUN_LINTING) lint:fix
  39. typecheck:
  40. $(RUN_LINTING) types:check
  41. test: format lint typecheck test_unit test_acceptance
  42. test_unit:
  43. ifneq (,$(wildcard test/unit))
  44. $(DOCKER_COMPOSE_TEST_UNIT) run --rm test_unit
  45. $(MAKE) test_unit_clean
  46. endif
  47. test_clean: test_unit_clean
  48. test_unit_clean:
  49. ifneq (,$(wildcard test/unit))
  50. $(DOCKER_COMPOSE_TEST_UNIT) down -v -t 0
  51. endif
  52. test_acceptance: test_acceptance_clean test_acceptance_pre_run test_acceptance_run
  53. $(MAKE) test_acceptance_clean
  54. test_acceptance_debug: test_acceptance_clean test_acceptance_pre_run test_acceptance_run_debug
  55. $(MAKE) test_acceptance_clean
  56. test_acceptance_run:
  57. ifneq (,$(wildcard test/acceptance))
  58. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance
  59. endif
  60. test_acceptance_run_debug:
  61. ifneq (,$(wildcard test/acceptance))
  62. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run -p 127.0.0.9:19999:19999 --rm test_acceptance npm run test:acceptance -- --inspect=0.0.0.0:19999 --inspect-brk
  63. endif
  64. test_clean: test_acceptance_clean
  65. test_acceptance_clean:
  66. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0
  67. test_acceptance_pre_run:
  68. ifneq (,$(wildcard test/acceptance/js/scripts/pre-run))
  69. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
  70. endif
  71. benchmarks:
  72. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance npm run benchmarks
  73. build:
  74. docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  75. || docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \
  76. || echo 'nothing cached for gcr.io/overleaf-ops'
  77. docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  78. || docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):main-deps \
  79. || echo 'nothing cached for us-east1-docker.pkg.dev/overleaf-ops/ol-docker'
  80. docker build \
  81. --pull \
  82. --build-arg BUILDKIT_INLINE_CACHE=1 \
  83. --tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  84. --cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  85. --cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \
  86. --tag us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  87. --cache-from us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  88. --cache-from us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):main-deps \
  89. --target base \
  90. --file Dockerfile \
  91. ../..
  92. docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
  93. --tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
  94. --cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  95. --tag us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
  96. --cache-from us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  97. --file Dockerfile \
  98. ../..
  99. tar:
  100. $(DOCKER_COMPOSE) up tar
  101. publish:
  102. docker push $(DOCKER_REPO)/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
  103. .PHONY: clean \
  104. format format_fix \
  105. lint lint_fix \
  106. build_types typecheck \
  107. test test_clean test_unit test_unit_clean \
  108. test_acceptance test_acceptance_debug test_acceptance_pre_run \
  109. test_acceptance_run test_acceptance_run_debug test_acceptance_clean \
  110. benchmarks \
  111. build tar publish \