overleaf/services/web/Makefile.module
Jakob Ackermann 1d95137e13 Merge pull request #4016 from overleaf/jpa-faster-ci-4288
[perf] faster CI

GitOrigin-RevId: 858c0c4947e41961dae35cb20e0fcc2e2f723787
2021-05-18 02:07:44 +00:00

53 lines
1.6 KiB
Text

BUILD_DIR_NAME ?= web
MODULE_NAME := $(notdir $(shell pwd))
MODULE_DIR := modules/$(MODULE_NAME)
PROJECT_NAME = web
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml --log-level ERROR
DOCKER_COMPOSE := cd ../../ && \
MODULE_DIR=$(MODULE_DIR) \
BUILD_NUMBER=$(BUILD_NUMBER) \
BRANCH_NAME=$(BRANCH_NAME) \
PROJECT_NAME=$(PROJECT_NAME) \
MOCHA_GREP=${MOCHA_GREP} \
SHARELATEX_CONFIG=/app/$(MODULE_DIR)/test/acceptance/config/settings.test.coffee \
docker-compose ${DOCKER_COMPOSE_FLAGS}
DOCKER_COMPOSE_TEST_ACCEPTANCE := \
export COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) \
&& $(DOCKER_COMPOSE)
DOCKER_COMPOSE_TEST_UNIT := \
export COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) \
&& $(DOCKER_COMPOSE)
ifeq (,$(wildcard test/unit))
test_unit:
else
test_unit:
${DOCKER_COMPOSE_TEST_UNIT} run --rm test_unit npm -q run test:unit:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/unit/src
${DOCKER_COMPOSE_TEST_UNIT} down
endif
ifeq (,$(wildcard test/acceptance))
test_acceptance:
test_acceptance_merged_inner:
clean_test_acceptance:
else
test_acceptance:
$(MAKE) --no-print-directory clean_test_acceptance
${DOCKER_COMPOSE_TEST_ACCEPTANCE} run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
$(MAKE) --no-print-directory clean_test_acceptance
test_acceptance_merged_inner:
cd ../../ && \
SHARELATEX_CONFIG=/app/$(MODULE_DIR)/test/acceptance/config/settings.test.coffee \
npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
clean_test_acceptance:
${DOCKER_COMPOSE_TEST_ACCEPTANCE} down -v -t 0
endif