2022-04-05 05:23:53 -04:00
|
|
|
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
|
2019-02-19 09:51:34 -05:00
|
|
|
|
2017-11-23 11:01:32 -05:00
|
|
|
BUILD_NUMBER ?= local
|
|
|
|
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
PROJECT_NAME = web
|
2019-02-25 08:18:42 -05:00
|
|
|
BUILD_DIR_NAME = $(shell pwd | xargs basename | tr -cd '[a-zA-Z0-9_.\-]')
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2024-02-06 04:34:15 -05:00
|
|
|
export OVERLEAF_CONFIG ?= /overleaf/services/web/test/acceptance/config/settings.test.saas.js
|
|
|
|
export BASE_CONFIG ?= ${OVERLEAF_CONFIG}
|
2021-07-20 05:26:03 -04:00
|
|
|
|
2022-01-06 10:02:36 -05:00
|
|
|
CFG_SAAS=/overleaf/services/web/test/acceptance/config/settings.test.saas.js
|
|
|
|
CFG_SERVER_CE=/overleaf/services/web/test/acceptance/config/settings.test.server-ce.js
|
|
|
|
CFG_SERVER_PRO=/overleaf/services/web/test/acceptance/config/settings.test.server-pro.js
|
2021-07-20 05:26:03 -04:00
|
|
|
|
2019-02-19 09:51:34 -05:00
|
|
|
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
|
|
|
BRANCH_NAME=$(BRANCH_NAME) \
|
|
|
|
PROJECT_NAME=$(PROJECT_NAME) \
|
|
|
|
MOCHA_GREP=${MOCHA_GREP} \
|
2023-08-14 05:06:42 -04:00
|
|
|
docker compose ${DOCKER_COMPOSE_FLAGS}
|
2019-02-19 09:51:34 -05:00
|
|
|
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
MODULE_DIRS := $(shell find modules -mindepth 1 -maxdepth 1 -type d -not -name '.git' )
|
|
|
|
MODULE_MAKEFILES := $(MODULE_DIRS:=/Makefile)
|
2019-05-23 09:12:22 -04:00
|
|
|
MODULE_NAME=$(shell basename $(MODULE))
|
2019-02-19 09:51:34 -05:00
|
|
|
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
$(MODULE_MAKEFILES): Makefile.module
|
2020-07-24 04:55:22 -04:00
|
|
|
cp Makefile.module $@ || diff Makefile.module $@
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
#
|
|
|
|
# Clean
|
|
|
|
#
|
|
|
|
|
2022-01-06 10:02:36 -05:00
|
|
|
clean:
|
|
|
|
-$(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=unit_test_all_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=unit_test_parallel_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=unit_test_parallel_make_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_test_saas_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_test_server_ce_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_test_server_pro_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_1_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_2_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_3_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_4_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_server_ce_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_server_pro_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=frontend_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
-COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
|
|
|
|
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
clean_ci:
|
2019-02-19 09:51:34 -05:00
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
2019-03-07 10:29:48 -05:00
|
|
|
docker container list | grep 'days ago' | cut -d ' ' -f 1 - | xargs -r docker container stop
|
2019-03-04 06:55:29 -05:00
|
|
|
docker image prune -af --filter "until=48h"
|
2019-02-27 12:46:24 -05:00
|
|
|
docker network prune -f
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
#
|
|
|
|
# Tests
|
|
|
|
#
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2023-10-13 05:13:03 -04:00
|
|
|
test: test_unit test_acceptance test_frontend test_frontend_ct
|
2019-05-23 09:12:22 -04:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
test_module: test_unit_module test_acceptance_module
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
#
|
|
|
|
# Unit tests
|
|
|
|
#
|
2019-05-23 09:12:22 -04:00
|
|
|
|
2020-11-27 08:11:12 -05:00
|
|
|
test_unit: test_unit_all
|
|
|
|
test_unit_all:
|
|
|
|
COMPOSE_PROJECT_NAME=unit_test_all_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_unit npm run test:unit:all
|
|
|
|
COMPOSE_PROJECT_NAME=unit_test_all_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
|
|
|
|
test_unit_all_silent:
|
|
|
|
COMPOSE_PROJECT_NAME=unit_test_all_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_unit npm run test:unit:all:silent
|
|
|
|
COMPOSE_PROJECT_NAME=unit_test_all_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
2019-05-23 09:12:22 -04:00
|
|
|
|
2018-05-23 08:10:33 -04:00
|
|
|
test_unit_app:
|
2019-10-23 08:22:37 -04:00
|
|
|
COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --name unit_test_$(BUILD_DIR_NAME) --rm test_unit
|
|
|
|
COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
TEST_SUITES = $(sort $(filter-out \
|
|
|
|
$(wildcard test/unit/src/helpers/*), \
|
|
|
|
$(wildcard test/unit/src/*/*)))
|
|
|
|
|
|
|
|
MOCHA_CMD_LINE = \
|
|
|
|
mocha \
|
|
|
|
--exit \
|
|
|
|
--file test/unit/bootstrap.js \
|
|
|
|
--grep=${MOCHA_GREP} \
|
|
|
|
--reporter spec \
|
|
|
|
--timeout 25000 \
|
|
|
|
|
|
|
|
.PHONY: $(TEST_SUITES)
|
|
|
|
$(TEST_SUITES):
|
|
|
|
$(MOCHA_CMD_LINE) $@
|
|
|
|
|
|
|
|
J ?= 1
|
|
|
|
test_unit_app_parallel_gnu_make: $(TEST_SUITES)
|
|
|
|
test_unit_app_parallel_gnu_make_docker: export COMPOSE_PROJECT_NAME = \
|
|
|
|
unit_test_parallel_make_$(BUILD_DIR_NAME)
|
|
|
|
test_unit_app_parallel_gnu_make_docker:
|
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
$(DOCKER_COMPOSE) run --rm test_unit \
|
|
|
|
make test_unit_app_parallel_gnu_make --output-sync -j $(J)
|
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
|
2020-03-09 09:35:48 -04:00
|
|
|
TEST_UNIT_MODULES = $(MODULE_DIRS:=/test_unit)
|
|
|
|
$(TEST_UNIT_MODULES): %/test_unit: %/Makefile
|
|
|
|
test_unit_modules: $(TEST_UNIT_MODULES)
|
2019-10-23 08:22:37 -04:00
|
|
|
|
2020-03-09 09:35:48 -04:00
|
|
|
test_unit_module:
|
|
|
|
$(MAKE) modules/$(MODULE_NAME)/test_unit
|
2019-10-23 08:22:37 -04:00
|
|
|
|
2020-07-09 09:56:33 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Frontend tests
|
|
|
|
#
|
|
|
|
|
|
|
|
test_frontend:
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_frontend
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
2017-12-14 04:32:38 -05:00
|
|
|
|
2022-03-30 05:49:41 -04:00
|
|
|
#
|
|
|
|
# Frontend component tests in Cypress
|
|
|
|
#
|
|
|
|
|
|
|
|
test_frontend_ct:
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_frontend_ct
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
|
2023-03-20 06:14:49 -04:00
|
|
|
# Note: The below cypress targets are for CI only
|
|
|
|
build_test_frontend_ct:
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) build test_frontend_ct
|
|
|
|
# Note: The 2nd build should use the cache from the 1st build.
|
2023-05-10 07:32:13 -04:00
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_editor_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) build test_frontend_ct
|
2023-03-20 06:14:49 -04:00
|
|
|
|
|
|
|
test_frontend_ct_core: export CYPRESS_RESULTS=./cypress/results/core
|
2023-09-28 11:32:24 -04:00
|
|
|
test_frontend_ct_core: export CYPRESS_SPEC_PATTERN=./{test,modules/**/test}/frontend/**/*.spec.{js,jsx,ts,tsx}
|
|
|
|
test_frontend_ct_core: export CYPRESS_EXCLUDE_SPEC_PATTERN=./test/frontend/features/source-editor/**/*.spec.{js,jsx,ts,tsx}
|
2023-03-20 06:14:49 -04:00
|
|
|
test_frontend_ct_core:
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_frontend_ct
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
|
2023-05-10 07:32:13 -04:00
|
|
|
test_frontend_ct_editor: export CYPRESS_RESULTS=./cypress/results/editor
|
2023-09-28 11:32:24 -04:00
|
|
|
test_frontend_ct_editor: export CYPRESS_SPEC_PATTERN=./test/frontend/features/source-editor/**/*.spec.{js,jsx,ts,tsx}
|
2023-05-10 07:32:13 -04:00
|
|
|
test_frontend_ct_editor:
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_editor_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_editor_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_frontend_ct
|
|
|
|
COMPOSE_PROJECT_NAME=frontend_test_ct_editor_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
2023-03-20 06:14:49 -04:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
#
|
|
|
|
# Acceptance tests
|
|
|
|
#
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2023-04-26 08:11:55 -04:00
|
|
|
# Keep in sync with TEST_ACCEPTANCE_MONGO_INIT in Makefile.module
|
2023-04-18 07:15:34 -04:00
|
|
|
TEST_ACCEPTANCE_MONGO_INIT := \
|
|
|
|
$(DOCKER_COMPOSE) up -d mongo; \
|
|
|
|
$(DOCKER_COMPOSE) exec -T mongo sh -c ' \
|
2024-02-13 05:06:03 -05:00
|
|
|
while ! mongosh --eval "db.version()" > /dev/null; do \
|
2023-04-18 07:15:34 -04:00
|
|
|
echo "Waiting for Mongo..."; \
|
|
|
|
sleep 1; \
|
|
|
|
done; \
|
2024-02-13 05:06:03 -05:00
|
|
|
mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"'
|
2023-04-18 07:15:34 -04:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
test_acceptance: test_acceptance_app test_acceptance_modules
|
2021-07-20 05:26:23 -04:00
|
|
|
test_acceptance_saas: test_acceptance_app_saas test_acceptance_modules_merged_saas
|
|
|
|
test_acceptance_server_ce: test_acceptance_app_server_ce test_acceptance_modules_merged_server_ce
|
|
|
|
test_acceptance_server_pro: test_acceptance_app_server_pro test_acceptance_modules_merged_server_pro
|
|
|
|
|
|
|
|
TEST_ACCEPTANCE_APP := \
|
|
|
|
test_acceptance_app_saas \
|
|
|
|
test_acceptance_app_server_ce \
|
|
|
|
test_acceptance_app_server_pro \
|
|
|
|
|
|
|
|
test_acceptance_app: $(TEST_ACCEPTANCE_APP)
|
|
|
|
test_acceptance_app_saas: export COMPOSE_PROJECT_NAME=acceptance_test_saas_$(BUILD_DIR_NAME)
|
2024-02-06 04:34:15 -05:00
|
|
|
test_acceptance_app_saas: export OVERLEAF_CONFIG=$(CFG_SAAS)
|
2021-07-20 05:26:23 -04:00
|
|
|
test_acceptance_app_server_ce: export COMPOSE_PROJECT_NAME=acceptance_test_server_ce_$(BUILD_DIR_NAME)
|
2024-02-06 04:34:15 -05:00
|
|
|
test_acceptance_app_server_ce: export OVERLEAF_CONFIG=$(CFG_SERVER_CE)
|
2021-07-20 05:26:23 -04:00
|
|
|
test_acceptance_app_server_pro: export COMPOSE_PROJECT_NAME=acceptance_test_server_pro_$(BUILD_DIR_NAME)
|
2024-02-06 04:34:15 -05:00
|
|
|
test_acceptance_app_server_pro: export OVERLEAF_CONFIG=$(CFG_SERVER_PRO)
|
2021-07-20 05:26:23 -04:00
|
|
|
|
|
|
|
$(TEST_ACCEPTANCE_APP):
|
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
2023-04-18 07:15:34 -04:00
|
|
|
$(TEST_ACCEPTANCE_MONGO_INIT)
|
2021-07-20 05:26:23 -04:00
|
|
|
$(DOCKER_COMPOSE) run --rm test_acceptance
|
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2021-07-20 05:26:03 -04:00
|
|
|
# We are using _make magic_ for turning these file-targets into calls to
|
|
|
|
# sub-Makefiles in the individual modules.
|
|
|
|
# These sub-Makefiles need to be kept in sync with the template, hence we
|
|
|
|
# add a dependency on each modules Makefile and cross-link that to the
|
|
|
|
# template at the very top of this file.
|
|
|
|
# Example: `web$ make modules/server-ce-scripts/test_acceptance_server_ce`
|
2024-02-06 04:34:15 -05:00
|
|
|
# Description: Run the acceptance tests of the server-ce-scripts module in an
|
|
|
|
# Overleaf Community Edition Environment.
|
2021-07-20 05:26:03 -04:00
|
|
|
# Break down:
|
|
|
|
# Target: modules/server-ce-scripts/test_acceptance_server_ce
|
|
|
|
# -> depends on modules/server-ce-scripts/Makefile
|
|
|
|
# -> add environment variable BASE_CONFIG=$(CFG_SERVER_CE)
|
2022-01-06 10:02:36 -05:00
|
|
|
# -> BASE_CONFIG=/overleaf/services/web/test/acceptance/config/settings.test.server-ce.js
|
2021-07-20 05:26:03 -04:00
|
|
|
# -> automatic target: `make -C server-ce-scripts test_acceptance_server_ce`
|
|
|
|
# -> automatic target: run `make test_acceptance_server_ce` in module
|
|
|
|
# Target: modules/server-ce-scripts/Makefile
|
|
|
|
# -> depends on Makefile.module
|
|
|
|
# -> automatic target: copies the file when changed
|
2020-03-09 09:35:48 -04:00
|
|
|
TEST_ACCEPTANCE_MODULES = $(MODULE_DIRS:=/test_acceptance)
|
|
|
|
$(TEST_ACCEPTANCE_MODULES): %/test_acceptance: %/Makefile
|
2021-07-20 05:26:03 -04:00
|
|
|
$(TEST_ACCEPTANCE_MODULES): modules/%/test_acceptance:
|
|
|
|
$(MAKE) test_acceptance_module MODULE_NAME=$*
|
|
|
|
|
|
|
|
TEST_ACCEPTANCE_MODULES_SAAS = $(MODULE_DIRS:=/test_acceptance_saas)
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SAAS): %/test_acceptance_saas: %/Makefile
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SAAS): export BASE_CONFIG = $(CFG_SAAS)
|
|
|
|
|
|
|
|
# This line adds `/test_acceptance_saas` suffix to all items in $(MODULE_DIRS).
|
|
|
|
TEST_ACCEPTANCE_MODULES_SERVER_CE = $(MODULE_DIRS:=/test_acceptance_server_ce)
|
|
|
|
# This line adds a dependency on the modules Makefile.
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SERVER_CE): %/test_acceptance_server_ce: %/Makefile
|
|
|
|
# This line adds the environment variable BASE_CONFIG=$(CFG_SERVER_CE) to all
|
|
|
|
# invocations of `web$ make modules/foo/test_acceptance_server_ce`.
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SERVER_CE): export BASE_CONFIG = $(CFG_SERVER_CE)
|
|
|
|
|
|
|
|
TEST_ACCEPTANCE_MODULES_SERVER_PRO = $(MODULE_DIRS:=/test_acceptance_server_pro)
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SERVER_PRO): %/test_acceptance_server_pro: %/Makefile
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SERVER_PRO): export BASE_CONFIG = $(CFG_SERVER_PRO)
|
2017-11-24 12:40:24 -05:00
|
|
|
|
2020-03-09 09:35:48 -04:00
|
|
|
CLEAN_TEST_ACCEPTANCE_MODULES = $(MODULE_DIRS:=/clean_test_acceptance)
|
|
|
|
$(CLEAN_TEST_ACCEPTANCE_MODULES): %/clean_test_acceptance: %/Makefile
|
|
|
|
clean_test_acceptance_modules: $(CLEAN_TEST_ACCEPTANCE_MODULES)
|
|
|
|
clean_ci: clean_test_acceptance_modules
|
|
|
|
|
2021-07-20 05:26:03 -04:00
|
|
|
test_acceptance_module_noop:
|
|
|
|
@echo
|
|
|
|
@echo Module '$(MODULE_NAME)' does not run in ${LABEL}.
|
|
|
|
@echo
|
|
|
|
|
|
|
|
TEST_ACCEPTANCE_MODULE_MAYBE_IN := \
|
|
|
|
test_acceptance_module_maybe_in_saas \
|
|
|
|
test_acceptance_module_maybe_in_server_ce \
|
|
|
|
test_acceptance_module_maybe_in_server_pro \
|
|
|
|
|
|
|
|
test_acceptance_module: $(TEST_ACCEPTANCE_MODULE_MAYBE_IN)
|
|
|
|
test_acceptance_module_maybe_in_saas: export BASE_CONFIG=$(CFG_SAAS)
|
|
|
|
test_acceptance_module_maybe_in_server_ce: export BASE_CONFIG=$(CFG_SERVER_CE)
|
|
|
|
test_acceptance_module_maybe_in_server_pro: export BASE_CONFIG=$(CFG_SERVER_PRO)
|
|
|
|
|
|
|
|
# We need to figure out whether the module is loaded in a given environment.
|
|
|
|
# This information is stored in the (base-)settings.
|
|
|
|
# We get the full list of modules and check for a matching module entry.
|
|
|
|
# Either the grep will find and emit the module, or exits with code 1, which
|
|
|
|
# we handle with a fallback to a noop make target.
|
2023-08-14 05:06:42 -04:00
|
|
|
# Run the node command in a docker compose container which provides the needed
|
2021-07-20 05:26:03 -04:00
|
|
|
# npm dependencies (from disk in dev-env or from the CI image in CI).
|
|
|
|
# Pick the test_unit service which is very light-weight -- the test_acceptance
|
|
|
|
# service would start mongo/redis.
|
|
|
|
$(TEST_ACCEPTANCE_MODULE_MAYBE_IN): test_acceptance_module_maybe_in_%:
|
|
|
|
$(MAKE) $(shell \
|
2024-02-06 04:34:15 -05:00
|
|
|
OVERLEAF_CONFIG=$(BASE_CONFIG) \
|
2021-07-20 05:26:03 -04:00
|
|
|
$(DOCKER_COMPOSE) run --rm test_unit \
|
|
|
|
node test/acceptance/getModuleTargets test_acceptance_$* \
|
|
|
|
| grep -e /$(MODULE_NAME)/ || echo test_acceptance_module_noop LABEL=$* \
|
|
|
|
)
|
|
|
|
|
|
|
|
# See docs for test_acceptance_server_ce how this works.
|
|
|
|
test_acceptance_module_saas: export BASE_CONFIG = $(CFG_SAAS)
|
|
|
|
test_acceptance_module_saas:
|
|
|
|
$(MAKE) modules/$(MODULE_NAME)/test_acceptance_saas
|
|
|
|
|
|
|
|
test_acceptance_module_server_ce: export BASE_CONFIG = $(CFG_SERVER_CE)
|
|
|
|
test_acceptance_module_server_ce:
|
|
|
|
$(MAKE) modules/$(MODULE_NAME)/test_acceptance_server_ce
|
|
|
|
|
|
|
|
test_acceptance_module_server_pro: export BASE_CONFIG = $(CFG_SERVER_PRO)
|
|
|
|
test_acceptance_module_server_pro:
|
|
|
|
$(MAKE) modules/$(MODULE_NAME)/test_acceptance_server_pro
|
|
|
|
|
|
|
|
# See docs for test_acceptance_server_ce how this works.
|
2021-05-17 05:37:23 -04:00
|
|
|
TEST_ACCEPTANCE_MODULES_MERGED_INNER = $(MODULE_DIRS:=/test_acceptance_merged_inner)
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_MERGED_INNER): %/test_acceptance_merged_inner: %/Makefile
|
2021-07-20 05:26:03 -04:00
|
|
|
test_acceptance_modules_merged_inner:
|
|
|
|
$(MAKE) $(shell \
|
2024-02-06 04:34:15 -05:00
|
|
|
OVERLEAF_CONFIG=$(BASE_CONFIG) \
|
2021-07-20 05:26:03 -04:00
|
|
|
node test/acceptance/getModuleTargets test_acceptance_merged_inner \
|
|
|
|
)
|
|
|
|
|
2021-07-21 07:52:39 -04:00
|
|
|
# inner loop for running saas tests in parallel
|
|
|
|
no_more_targets:
|
|
|
|
|
|
|
|
# If we ever have more than 40 modules, we need to add _5 targets to all the places and have it START at 41.
|
|
|
|
test_acceptance_modules_merged_inner_1: export START=1
|
|
|
|
test_acceptance_modules_merged_inner_2: export START=11
|
|
|
|
test_acceptance_modules_merged_inner_3: export START=21
|
|
|
|
test_acceptance_modules_merged_inner_4: export START=31
|
|
|
|
TEST_ACCEPTANCE_MODULES_MERGED_INNER_SPLIT = \
|
|
|
|
test_acceptance_modules_merged_inner_1 \
|
|
|
|
test_acceptance_modules_merged_inner_2 \
|
|
|
|
test_acceptance_modules_merged_inner_3 \
|
|
|
|
test_acceptance_modules_merged_inner_4 \
|
|
|
|
|
|
|
|
# The node script prints one module per line.
|
|
|
|
# Using tail and head we skip over the first n=START entries and print the last 10.
|
|
|
|
# Finally we check with grep for any targets in a batch and print a fallback if none were found.
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_MERGED_INNER_SPLIT):
|
|
|
|
$(MAKE) $(shell \
|
2024-02-06 04:34:15 -05:00
|
|
|
OVERLEAF_CONFIG=$(BASE_CONFIG) \
|
2021-07-21 07:52:39 -04:00
|
|
|
node test/acceptance/getModuleTargets test_acceptance_merged_inner \
|
|
|
|
| tail -n+$(START) | head -n 10 \
|
|
|
|
| grep -e . || echo no_more_targets \
|
|
|
|
)
|
|
|
|
|
2021-07-20 05:26:03 -04:00
|
|
|
# See docs for test_acceptance_server_ce how this works.
|
|
|
|
test_acceptance_modules_merged_saas: export COMPOSE_PROJECT_NAME = \
|
|
|
|
acceptance_test_modules_merged_saas_$(BUILD_DIR_NAME)
|
|
|
|
test_acceptance_modules_merged_saas: export BASE_CONFIG = $(CFG_SAAS)
|
|
|
|
|
|
|
|
test_acceptance_modules_merged_server_ce: export COMPOSE_PROJECT_NAME = \
|
|
|
|
acceptance_test_modules_merged_server_ce_$(BUILD_DIR_NAME)
|
|
|
|
test_acceptance_modules_merged_server_ce: export BASE_CONFIG = $(CFG_SERVER_CE)
|
|
|
|
|
|
|
|
test_acceptance_modules_merged_server_pro: export COMPOSE_PROJECT_NAME = \
|
|
|
|
acceptance_test_modules_merged_server_pro_$(BUILD_DIR_NAME)
|
|
|
|
test_acceptance_modules_merged_server_pro: export BASE_CONFIG = $(CFG_SERVER_PRO)
|
|
|
|
|
|
|
|
# All these variants run the same command.
|
|
|
|
# Each target has a different set of environment defined above.
|
|
|
|
TEST_ACCEPTANCE_MODULES_MERGED_VARIANTS = \
|
|
|
|
test_acceptance_modules_merged_saas \
|
|
|
|
test_acceptance_modules_merged_server_ce \
|
|
|
|
test_acceptance_modules_merged_server_pro \
|
|
|
|
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_MERGED_VARIANTS):
|
2021-05-17 05:37:23 -04:00
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
2023-04-18 07:15:34 -04:00
|
|
|
$(TEST_ACCEPTANCE_MONGO_INIT)
|
2021-05-17 05:37:23 -04:00
|
|
|
$(DOCKER_COMPOSE) run --rm test_acceptance make test_acceptance_modules_merged_inner
|
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
|
2021-07-21 07:52:39 -04:00
|
|
|
# outer loop for running saas tests in parallel
|
|
|
|
TEST_ACCEPTANCE_MODULES_MERGED_SPLIT_SAAS = \
|
|
|
|
test_acceptance_modules_merged_saas_1 \
|
|
|
|
test_acceptance_modules_merged_saas_2 \
|
|
|
|
test_acceptance_modules_merged_saas_3 \
|
|
|
|
test_acceptance_modules_merged_saas_4 \
|
|
|
|
|
|
|
|
test_acceptance_modules_merged_saas_1: export COMPOSE_PROJECT_NAME = \
|
|
|
|
acceptance_test_modules_merged_saas_1_$(BUILD_DIR_NAME)
|
|
|
|
test_acceptance_modules_merged_saas_2: export COMPOSE_PROJECT_NAME = \
|
|
|
|
acceptance_test_modules_merged_saas_2_$(BUILD_DIR_NAME)
|
|
|
|
test_acceptance_modules_merged_saas_3: export COMPOSE_PROJECT_NAME = \
|
|
|
|
acceptance_test_modules_merged_saas_3_$(BUILD_DIR_NAME)
|
|
|
|
test_acceptance_modules_merged_saas_4: export COMPOSE_PROJECT_NAME = \
|
|
|
|
acceptance_test_modules_merged_saas_4_$(BUILD_DIR_NAME)
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_MERGED_SPLIT_SAAS): export BASE_CONFIG = $(CFG_SAAS)
|
|
|
|
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_MERGED_SPLIT_SAAS): test_acceptance_modules_merged_saas_%:
|
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
2023-04-18 07:15:34 -04:00
|
|
|
$(TEST_ACCEPTANCE_MONGO_INIT)
|
2021-07-21 07:52:39 -04:00
|
|
|
$(DOCKER_COMPOSE) run --rm test_acceptance make test_acceptance_modules_merged_inner_$*
|
|
|
|
$(DOCKER_COMPOSE) down -v -t 0
|
|
|
|
|
2021-07-20 05:26:03 -04:00
|
|
|
test_acceptance_modules: $(TEST_ACCEPTANCE_MODULES_MERGED_VARIANTS)
|
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
#
|
|
|
|
# CI tests
|
|
|
|
#
|
|
|
|
|
2017-12-14 04:43:59 -05:00
|
|
|
ci:
|
|
|
|
MOCHA_ARGS="--reporter tap" \
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
$(MAKE) test
|
2017-12-14 04:32:38 -05:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
#
|
|
|
|
# Lint & format
|
|
|
|
#
|
2020-05-22 06:34:57 -04:00
|
|
|
ORG_PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
RUN_LINT_FORMAT ?= \
|
2020-07-02 11:51:38 -04:00
|
|
|
docker run --rm ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
|
|
|
|
2022-01-06 10:02:36 -05:00
|
|
|
NODE_MODULES_PATH := ${PATH}:${PWD}/node_modules/.bin:/overleaf/services/web/node_modules/.bin
|
2020-07-02 11:51:38 -04:00
|
|
|
WITH_NODE_MODULES_PATH = \
|
|
|
|
format_backend \
|
|
|
|
format_frontend \
|
|
|
|
format_misc \
|
2020-12-15 05:23:54 -05:00
|
|
|
format_styles \
|
2021-01-06 04:58:57 -05:00
|
|
|
format_test_app_unit \
|
|
|
|
format_test_app_rest \
|
|
|
|
format_test_modules \
|
2020-07-02 11:51:38 -04:00
|
|
|
$(TEST_SUITES) \
|
|
|
|
|
|
|
|
$(WITH_NODE_MODULES_PATH): export PATH=$(NODE_MODULES_PATH)
|
|
|
|
|
2024-06-03 04:36:42 -04:00
|
|
|
lint: lint_eslint
|
|
|
|
lint_eslint:
|
|
|
|
npm run lint
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2024-07-22 04:10:54 -04:00
|
|
|
lint: lint_stylelint
|
|
|
|
lint_stylelint:
|
|
|
|
npm run lint:styles
|
|
|
|
|
2021-03-22 05:51:07 -04:00
|
|
|
lint: lint_pug
|
|
|
|
lint_pug:
|
|
|
|
bin/lint_pug_templates
|
|
|
|
|
2021-08-16 10:59:04 -04:00
|
|
|
lint: lint_locales
|
|
|
|
lint_locales:
|
|
|
|
bin/lint_locales
|
|
|
|
|
2023-07-20 09:02:28 -04:00
|
|
|
lint: check_extracted_translations
|
|
|
|
check_extracted_translations:
|
|
|
|
bin/check_extracted_translations
|
|
|
|
|
2023-01-09 06:20:22 -05:00
|
|
|
sort_locales:
|
|
|
|
node scripts/translations/sort.js
|
|
|
|
|
2023-01-12 04:51:34 -05:00
|
|
|
cleanup_unused_locales:
|
|
|
|
node scripts/translations/cleanupUnusedLocales.js
|
|
|
|
|
2022-01-17 05:19:53 -05:00
|
|
|
lint: lint_flag_res_send_usage
|
|
|
|
lint_flag_res_send_usage:
|
|
|
|
bin/lint_flag_res_send_usage
|
|
|
|
|
2022-05-26 04:01:50 -04:00
|
|
|
lint: typecheck_frontend
|
2022-03-25 05:30:02 -04:00
|
|
|
typecheck_frontend:
|
2023-07-20 04:14:23 -04:00
|
|
|
npx -p typescript tsc --noEmit
|
2022-03-25 05:30:02 -04:00
|
|
|
|
2024-01-03 09:55:37 -05:00
|
|
|
lint: typecheck_backend
|
|
|
|
typecheck_backend:
|
|
|
|
npx -p typescript tsc -p tsconfig.backend.json --noEmit
|
|
|
|
|
2021-01-21 07:20:47 -05:00
|
|
|
lint_in_docker:
|
2023-08-14 05:47:52 -04:00
|
|
|
$(RUN_LINT_FORMAT) make lint -j2 --output-sync
|
2021-01-21 07:20:47 -05:00
|
|
|
|
|
|
|
format: format_js
|
|
|
|
format_js:
|
|
|
|
npm run --silent format
|
|
|
|
|
|
|
|
format: format_styles
|
|
|
|
format_styles:
|
|
|
|
npm run --silent format:styles
|
2020-05-22 06:34:57 -04:00
|
|
|
|
2019-01-15 05:45:54 -05:00
|
|
|
format_fix:
|
2020-08-03 07:34:22 -04:00
|
|
|
npm run --silent format:fix
|
2019-01-15 05:45:54 -05:00
|
|
|
|
2021-01-21 07:20:47 -05:00
|
|
|
format_styles_fix:
|
|
|
|
npm run --silent format:styles:fix
|
|
|
|
|
|
|
|
format_in_docker:
|
2023-08-14 05:47:52 -04:00
|
|
|
$(RUN_LINT_FORMAT) make format -j2 --output-sync
|
2021-01-21 07:20:47 -05:00
|
|
|
|
2019-10-23 08:22:37 -04:00
|
|
|
#
|
|
|
|
# Build & publish
|
|
|
|
#
|
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
IMAGE_CI ?= ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
2023-11-29 03:56:02 -05:00
|
|
|
IMAGE_REPO ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME)
|
2020-07-02 11:51:38 -04:00
|
|
|
IMAGE_REPO_BRANCH ?= $(IMAGE_REPO):$(BRANCH_NAME)
|
2021-08-03 10:32:13 -04:00
|
|
|
IMAGE_REPO_MAIN ?= $(IMAGE_REPO):main
|
2020-07-02 11:51:38 -04:00
|
|
|
IMAGE_REPO_FINAL ?= $(IMAGE_REPO_BRANCH)-$(BUILD_NUMBER)
|
|
|
|
|
|
|
|
export SENTRY_RELEASE ?= ${COMMIT_SHA}
|
|
|
|
|
2020-05-22 06:34:57 -04:00
|
|
|
build_deps:
|
|
|
|
docker build --pull \
|
2023-02-21 04:07:08 -05:00
|
|
|
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
2020-07-02 11:51:38 -04:00
|
|
|
--cache-from $(IMAGE_REPO_BRANCH)-deps \
|
2021-08-03 10:32:13 -04:00
|
|
|
--cache-from $(IMAGE_REPO_MAIN)-deps \
|
2020-07-02 11:51:38 -04:00
|
|
|
--tag $(IMAGE_REPO_BRANCH)-deps \
|
2020-05-22 06:34:57 -04:00
|
|
|
--target deps \
|
2022-01-06 10:02:36 -05:00
|
|
|
--file Dockerfile \
|
|
|
|
../..
|
2020-05-22 06:34:57 -04:00
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
build_dev:
|
|
|
|
docker build \
|
|
|
|
--build-arg SENTRY_RELEASE \
|
|
|
|
--tag $(IMAGE_CI) \
|
|
|
|
--tag $(IMAGE_CI)-dev \
|
|
|
|
--target dev \
|
2022-01-06 10:02:36 -05:00
|
|
|
--file Dockerfile \
|
|
|
|
../..
|
2020-07-02 11:51:38 -04:00
|
|
|
|
|
|
|
build_webpack:
|
2020-07-16 11:01:34 -04:00
|
|
|
$(MAKE) build_webpack_once \
|
|
|
|
|| $(MAKE) build_webpack_once
|
|
|
|
|
|
|
|
build_webpack_once:
|
2020-07-02 11:51:38 -04:00
|
|
|
docker build \
|
|
|
|
--build-arg SENTRY_RELEASE \
|
|
|
|
--cache-from $(IMAGE_CI)-dev \
|
|
|
|
--cache-from $(IMAGE_CI)-webpack \
|
|
|
|
--tag $(IMAGE_CI)-webpack \
|
|
|
|
--target webpack \
|
2022-01-06 10:02:36 -05:00
|
|
|
--file Dockerfile \
|
|
|
|
../..
|
2020-07-02 11:51:38 -04:00
|
|
|
|
2024-07-03 04:49:13 -04:00
|
|
|
build_pug:
|
|
|
|
docker build \
|
|
|
|
--build-arg SENTRY_RELEASE \
|
|
|
|
--cache-from $(IMAGE_CI)-dev \
|
|
|
|
--tag $(IMAGE_CI)-pug \
|
|
|
|
--target pug \
|
|
|
|
--file Dockerfile \
|
|
|
|
../..
|
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
build:
|
|
|
|
docker build \
|
|
|
|
--build-arg SENTRY_RELEASE \
|
|
|
|
--cache-from $(IMAGE_CI)-webpack \
|
2024-07-03 04:49:13 -04:00
|
|
|
--cache-from $(IMAGE_CI)-pug \
|
2020-07-02 11:51:38 -04:00
|
|
|
--cache-from $(IMAGE_REPO_FINAL) \
|
|
|
|
--tag $(IMAGE_REPO_FINAL) \
|
2023-11-08 09:44:54 -05:00
|
|
|
--target app \
|
2022-01-06 10:02:36 -05:00
|
|
|
--file Dockerfile \
|
|
|
|
../..
|
2019-02-19 09:51:34 -05:00
|
|
|
|
|
|
|
publish:
|
2024-07-18 12:40:04 -04:00
|
|
|
docker push $(IMAGE_REPO_FINAL)
|
2019-02-19 09:51:34 -05:00
|
|
|
|
|
|
|
tar:
|
2019-02-25 08:18:42 -05:00
|
|
|
COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm tar
|
|
|
|
COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
2019-01-29 05:10:13 -05:00
|
|
|
|
2023-12-14 04:41:03 -05:00
|
|
|
build_storybook:
|
2023-12-14 05:41:27 -05:00
|
|
|
npm run lezer-latex:generate
|
2023-12-14 04:41:03 -05:00
|
|
|
npm run build-storybook
|
2023-12-14 05:41:27 -05:00
|
|
|
if [ -n "$(BRANCH_NAME)" ]; then \
|
2023-12-14 04:41:03 -05:00
|
|
|
echo "Renaming storybook-static -> $(BRANCH_NAME)."; \
|
|
|
|
d=$$(dirname "$(BRANCH_NAME)"); \
|
|
|
|
mkdir -p "storybook-output/$$d"; \
|
|
|
|
mv storybook-static "storybook-output/$$d/$$(basename "$(BRANCH_NAME)")/"; \
|
|
|
|
fi
|
|
|
|
|
2020-03-09 09:35:48 -04:00
|
|
|
MODULE_TARGETS = \
|
2021-07-20 05:26:03 -04:00
|
|
|
$(TEST_ACCEPTANCE_MODULES_SAAS) \
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SERVER_CE) \
|
|
|
|
$(TEST_ACCEPTANCE_MODULES_SERVER_PRO) \
|
2021-05-17 05:37:23 -04:00
|
|
|
$(TEST_ACCEPTANCE_MODULES_MERGED_INNER) \
|
2020-03-09 09:35:48 -04:00
|
|
|
$(CLEAN_TEST_ACCEPTANCE_MODULES) \
|
|
|
|
$(TEST_UNIT_MODULES) \
|
|
|
|
|
|
|
|
$(MODULE_TARGETS):
|
|
|
|
$(MAKE) -C $(dir $@) $(notdir $@) BUILD_DIR_NAME=$(BUILD_DIR_NAME)
|
|
|
|
|
2017-11-23 11:01:32 -05:00
|
|
|
.PHONY:
|
2020-03-09 09:35:48 -04:00
|
|
|
$(MODULE_TARGETS) \
|
2019-11-28 05:20:22 -05:00
|
|
|
compile_modules compile_modules_full clean_ci \
|
|
|
|
test test_module test_unit test_unit_app \
|
2023-10-13 05:13:03 -04:00
|
|
|
test_unit_modules test_unit_module test_frontend \
|
|
|
|
test_acceptance test_acceptance_app test_acceptance_modules \
|
|
|
|
test_acceptance_module ci format format_fix lint \
|
|
|
|
build publish tar
|