Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 = spelling
  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_COMPOSE_TEST_UNIT) down --rmi local
  22. -$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down --rmi local
  23. HERE=$(shell pwd)
  24. MONOREPO=$(shell cd ../../ && pwd)
  25. # Run the linting commands in the scope of the monorepo.
  26. # Eslint and prettier (plus some configs) are on the root.
  27. RUN_LINTING = docker run --rm -v $(MONOREPO):$(MONOREPO) -w $(HERE) node:16.17.1 npm run --silent
  28. format:
  29. $(RUN_LINTING) format
  30. format_fix:
  31. $(RUN_LINTING) format:fix
  32. lint:
  33. $(RUN_LINTING) lint
  34. lint_fix:
  35. $(RUN_LINTING) lint:fix
  36. test: format lint test_unit test_acceptance
  37. test_unit:
  38. ifneq (,$(wildcard test/unit))
  39. $(DOCKER_COMPOSE_TEST_UNIT) run --rm test_unit
  40. $(MAKE) test_unit_clean
  41. endif
  42. test_clean: test_unit_clean
  43. test_unit_clean:
  44. ifneq (,$(wildcard test/unit))
  45. $(DOCKER_COMPOSE_TEST_UNIT) down -v -t 0
  46. endif
  47. test_acceptance: test_acceptance_clean test_acceptance_pre_run test_acceptance_run
  48. $(MAKE) test_acceptance_clean
  49. test_acceptance_debug: test_acceptance_clean test_acceptance_pre_run test_acceptance_run_debug
  50. $(MAKE) test_acceptance_clean
  51. test_acceptance_run:
  52. ifneq (,$(wildcard test/acceptance))
  53. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance
  54. endif
  55. test_acceptance_run_debug:
  56. ifneq (,$(wildcard test/acceptance))
  57. $(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
  58. endif
  59. test_clean: test_acceptance_clean
  60. test_acceptance_clean:
  61. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0
  62. test_acceptance_pre_run:
  63. ifneq (,$(wildcard test/acceptance/js/scripts/pre-run))
  64. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
  65. endif
  66. benchmarks:
  67. $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance npm run benchmarks
  68. build:
  69. docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  70. || docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \
  71. || echo 'nothing cached'
  72. docker build \
  73. --pull \
  74. --tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  75. --cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  76. --cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \
  77. --target base \
  78. --file Dockerfile \
  79. ../..
  80. docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
  81. --tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
  82. --cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
  83. --file Dockerfile \
  84. ../..
  85. tar:
  86. $(DOCKER_COMPOSE) up tar
  87. publish:
  88. docker push $(DOCKER_REPO)/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
  89. .PHONY: clean test test_unit test_acceptance test_clean benchmarks build publish