Files
overleaf-cep/services/web/Makefile.module
T
Jakob Ackermann 9fd0d644cf [agents] refine guidance for running tests (#34977)
* [monorepo] fix handling of quoted MOCHA_GREP

* [agents] refine guidance for running tests

- nudge it towards scoped module targets
- nudge it to really run e2e tests when changed
- nudge it towards a11y cypress matchers
- recommend quoting for MOCHA_GREP

* [web] fix forwarding of mocha args from module Makefile

* [monorepo] use BRANCH_NAME_TAG_SAFE for building the ci image name

* [web] also make BRANCH_NAME_TAG_SAFE available in module Makefile

(It's not really needed, but will make copilot happy.)

GitOrigin-RevId: bfda3c8fe2b4f857ef111ac63f94b35a82ad75f8
2026-06-26 08:07:37 +00:00

75 lines
2.6 KiB
Makefile

BUILD_DIR_NAME ?= web
ifeq ($(BRANCH_NAME),)
export BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
endif
export BRANCH_NAME_TAG_SAFE := $(shell echo "$(BRANCH_NAME)" | sed 's/\//\-\-/g' | cut -c1-96)
export MODULE_NAME := $(notdir $(shell pwd))
export MODULE_DIR := modules/$(MODULE_NAME)
export PROJECT_NAME = web
export RETRIES ?= $(if $(CI),3,0)
export MOCHA_GREP ?=
export OVERLEAF_CONFIG = /overleaf/services/web/$(MODULE_DIR)/test/acceptance/config/settings.test.js
export BASE_CONFIG ?= /overleaf/services/web/test/acceptance/config/settings.test.saas.js
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
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
DOCKER_COMPOSE := cd ../../ && docker compose ${DOCKER_COMPOSE_FLAGS}
ifeq (,$(wildcard test/unit))
test_unit:
else
test_unit: export COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME)_$(MODULE_NAME)
test_unit:
${DOCKER_COMPOSE} run --rm test_unit yarn test:unit:run_dir ${MOCHA_ARGS} $(MODULE_DIR)/test/unit/src
${DOCKER_COMPOSE} down
endif
ALL_TEST_ACCEPTANCE_VARIANTS := \
test_acceptance \
test_acceptance_saas \
test_acceptance_server_ce \
test_acceptance_server_pro \
ifeq (,$(wildcard test/acceptance))
$(ALL_TEST_ACCEPTANCE_VARIANTS) test_acceptance_merged_inner:
@echo
@echo Module $(MODULE_NAME) does not have acceptance tests.
@echo
clean_test_acceptance:
else
ifeq ($(DEBUG),true)
TEST_ACCEPTANCE_DEBUG_PORT := -p 127.0.0.1:19999:19999
TEST_ACCEPTANCE_NPM_SCRIPT := test:acceptance:debug:run_dir
else
TEST_ACCEPTANCE_DEBUG_PORT :=
TEST_ACCEPTANCE_NPM_SCRIPT := test:acceptance:run_dir
endif
test_acceptance_saas: export BASE_CONFIG = $(CFG_SAAS)
test_acceptance_server_ce: export BASE_CONFIG = $(CFG_SERVER_CE)
test_acceptance_server_pro: export BASE_CONFIG = $(CFG_SERVER_PRO)
$(ALL_TEST_ACCEPTANCE_VARIANTS): export COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME)
$(ALL_TEST_ACCEPTANCE_VARIANTS):
$(MAKE) --no-print-directory clean_test_acceptance
${DOCKER_COMPOSE} run --rm $(TEST_ACCEPTANCE_DEBUG_PORT) test_acceptance yarn $(TEST_ACCEPTANCE_NPM_SCRIPT) -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
$(MAKE) --no-print-directory clean_test_acceptance
test_acceptance_merged_inner:
cd ../../ && \
yarn test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
clean_test_acceptance: export COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME)
clean_test_acceptance:
${DOCKER_COMPOSE} down -v -t 0
endif