Makefile 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. all: test-e2e
  2. # We are updating the docker compose config via the host-admin service.
  3. # The host-admin service is running inside docker and has its own file-system layout.
  4. # We need to have both file-system layouts agree on the path for the docker compose project.
  5. # Notable the container labels com.docker.compose.project.working_dir and com.docker.compose.project.config_files need to match when creating containers from the docker host (how you started things) and from host-admin (how tests reconfigure the instance).
  6. export PWD = $(shell pwd)
  7. export MONOREPO = $(shell cd ../../ && pwd)
  8. export TEX_LIVE_DOCKER_IMAGE ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2023.1
  9. export ALL_TEX_LIVE_DOCKER_IMAGES ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2023.1,us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2022.1
  10. export IMAGE_TAG_CE ?= sharelatex/sharelatex:main
  11. export IMAGE_TAG_PRO ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/pro:main
  12. export CYPRESS_SHARD ?=
  13. export COMPOSE_PROJECT_NAME ?= test
  14. export USER_UID=$(shell id -u)
  15. export USER_GID=$(shell id -g)
  16. IMAGE_TAG_PRO_BASE := $(shell echo $(IMAGE_TAG_PRO) | sed -E s/:.+//)
  17. print-debug-logs:
  18. -docker compose logs --timestamps --tail=100 e2e
  19. -docker compose logs --timestamps --tail=100 mongo
  20. -docker compose logs --timestamps --tail=100 redis
  21. -docker compose logs --timestamps --tail=100 mailtrap
  22. -docker compose logs --timestamps --tail=100 saml
  23. -docker compose logs --timestamps --tail=100 ldap
  24. -docker compose logs --timestamps --tail=100 git-bridge
  25. -docker compose logs --timestamps --tail=100 host-admin
  26. -docker compose logs --timestamps sharelatex
  27. -docker compose exec sharelatex bash -c 'tail -n100 /var/log/overleaf/*.log'
  28. test-e2e-native:
  29. docker compose -f docker-compose.yml -f docker-compose.native.yml up --no-log-prefix sharelatex host-admin -d
  30. CYPRESS_BASE_URL='http://127.0.0.1:3231' \
  31. CYPRESS_HOST_ADMIN_URL='http://127.0.0.1:3232' \
  32. CYPRESS_SAML_URL='http://127.0.0.1:3233' \
  33. CYPRESS_MAILTRAP_URL='http://127.0.0.1:3234' \
  34. yarn run cypress:open
  35. # For testing "native" on Linux
  36. test-e2e-native-linux:
  37. docker compose -f docker-compose.yml -f docker-compose.native.yml up --no-log-prefix sharelatex host-admin -d
  38. CYPRESS_BASE_URL='http://127.0.0.1:3231' \
  39. CYPRESS_HOST_ADMIN_URL='http://127.0.0.1:3232' \
  40. CYPRESS_SAML_URL='http://127.0.0.1:3233' \
  41. CYPRESS_MAILTRAP_URL='http://127.0.0.1:3234' \
  42. docker compose -f docker-compose.yml -f docker-compose.native.yml up --no-log-prefix cypress
  43. test-e2e:
  44. docker compose build host-admin
  45. docker compose up --detach --wait host-admin
  46. docker compose up --detach --wait mongo
  47. docker compose up --no-log-prefix --exit-code-from=e2e e2e host-admin
  48. test-e2e-open:
  49. docker compose up --detach --wait host-admin
  50. docker compose up --detach --wait mongo
  51. docker compose up --no-log-prefix --exit-code-from=e2e-open e2e-open host-admin
  52. SHARD_PROJECT_NAMES = \
  53. test-ce-default \
  54. test-ce-custom-1 \
  55. test-pro-default-1 \
  56. test-pro-default-2 \
  57. test-pro-custom-1 \
  58. test-pro-custom-2 \
  59. test-pro-custom-3 \
  60. test-pro-custom-4
  61. CLEAN_SHARDS=$(addprefix clean/,$(SHARD_PROJECT_NAMES))
  62. clean: $(CLEAN_SHARDS)
  63. -docker compose run --no-deps --rm --entrypoint rm host-admin -rf docker-compose.override.yml docker-compose.*_*.yml reports/ data/
  64. -docker compose down --remove-orphans --rmi local --timeout 0 --volumes
  65. $(CLEAN_SHARDS): clean/%:
  66. -COMPOSE_PROJECT_NAME=$* docker compose down --remove-orphans --rmi local --timeout 0 --volumes
  67. prefetch: prefetch_default
  68. prefetch_default: prefetch_default_compose
  69. prefetch_default_compose:
  70. docker compose pull e2e mongo redis
  71. prefetch_default: prefetch_default_compose_build
  72. prefetch_default_compose_build:
  73. docker compose build host-admin
  74. prefetch: prefetch_custom
  75. prefetch_custom: prefetch_custom_compose_pull
  76. prefetch_custom_compose_pull:
  77. docker compose pull saml ldap
  78. prefetch_custom: prefetch_custom_texlive_2023
  79. prefetch_custom_texlive_2023:
  80. docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2023.1
  81. docker tag us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2023.1 quay.io/sharelatex/texlive-full:2023.1
  82. prefetch_custom: prefetch_custom_texlive_2022
  83. prefetch_custom_texlive_2022:
  84. docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2022.1
  85. docker tag us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2022.1 quay.io/sharelatex/texlive-full:2022.1
  86. prefetch_custom: prefetch_old_4_2
  87. prefetch_old_4_2:
  88. docker pull $(IMAGE_TAG_PRO_BASE):4.2
  89. prefetch_custom: prefetch_old_5_0
  90. prefetch_old_5_0:
  91. docker pull $(IMAGE_TAG_PRO_BASE):5.0
  92. prefetch_custom: build_hotfix_5_5_5
  93. build_hotfix_5_5_5:
  94. docker pull $(IMAGE_TAG_PRO_BASE):5.5.4
  95. cd ../../server-pro/hotfix/5.5.5 && docker build --build-arg BASE_IMAGE=$(IMAGE_TAG_PRO_BASE):5.5.4 -t $(IMAGE_TAG_PRO_BASE):5.5.5 .
  96. # Google Cloud Build runs on a very ancient Docker version that does not support the subdir flag.
  97. # Use services -> mailtrap -> build -> context = https://github.com/dbck/docker-mailtrap.git#v1.5.0:build in docker-compose.yml eventually.
  98. prefetch_default_compose_build: build_mailtrap
  99. build_mailtrap:
  100. git clone https://github.com/dbck/docker-mailtrap.git || true && cd docker-mailtrap && git checkout v1.5.0
  101. docker build -t mailtrap docker-mailtrap/build
  102. prefetch_default_compose_build: build_cypress
  103. build_cypress:
  104. docker compose build e2e
  105. .PHONY: test-e2e test-e2e-open