From 3a071c247ab157592542560dd16ef6a3ab9025b9 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 20 Mar 2023 10:14:49 +0000 Subject: [PATCH] Merge pull request #12285 from overleaf/jpa-parallel-cypress-tests [web] run core and module cypress tests in parallel GitOrigin-RevId: d71fb94d05a8c554623e401bec8fffca5417177b --- services/web/Makefile | 20 ++++++++++++++++++++ services/web/cypress.config.ts | 4 +++- services/web/docker-compose.ci.yml | 4 +++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/services/web/Makefile b/services/web/Makefile index 5cd642efcb..b55ce27f70 100644 --- a/services/web/Makefile +++ b/services/web/Makefile @@ -146,6 +146,26 @@ test_frontend_ct: 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 +# 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. + COMPOSE_PROJECT_NAME=frontend_test_ct_modules_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) build test_frontend_ct + +test_frontend_ct_core: export CYPRESS_RESULTS=./cypress/results/core +test_frontend_ct_core: export CYPRESS_SPEC_PATTERN=./test/frontend/**/*.spec.{js,ts,tsx} +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 + +test_frontend_ct_modules: export CYPRESS_RESULTS=./cypress/results/modules +test_frontend_ct_modules: export CYPRESS_SPEC_PATTERN=./modules/**/test/frontend/**/*.spec.{js,ts,tsx} +test_frontend_ct_modules: + COMPOSE_PROJECT_NAME=frontend_test_ct_modules_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0 + COMPOSE_PROJECT_NAME=frontend_test_ct_modules_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_frontend_ct + COMPOSE_PROJECT_NAME=frontend_test_ct_modules_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0 + # # Acceptance tests # diff --git a/services/web/cypress.config.ts b/services/web/cypress.config.ts index 0845cc0736..412a197841 100644 --- a/services/web/cypress.config.ts +++ b/services/web/cypress.config.ts @@ -18,7 +18,9 @@ export default defineConfig({ setupNodeEvents(on, config) { // }, - specPattern: './{test,modules/**/test}/frontend/**/*.spec.{js,ts,tsx}', + specPattern: + process.env.CYPRESS_SPEC_PATTERN || + './{test,modules/**/test}/frontend/**/*.spec.{js,ts,tsx}', }, retries: { runMode: 3, diff --git a/services/web/docker-compose.ci.yml b/services/web/docker-compose.ci.yml index 1abf6d5176..9958acc88c 100644 --- a/services/web/docker-compose.ci.yml +++ b/services/web/docker-compose.ci.yml @@ -74,8 +74,10 @@ services: CYPRESS_IMAGE: $CYPRESS_IMAGE working_dir: /overleaf/services/web entrypoint: bash + environment: + CYPRESS_SPEC_PATTERN: ${CYPRESS_SPEC_PATTERN:-} volumes: - - ./cypress/results:/overleaf/services/web/cypress/results/ + - ${CYPRESS_RESULTS:-./cypress/results}:/overleaf/services/web/cypress/results/ command: - "-c" - "if npm run cypress:run-ct; then exit 0; else mkdir -p ./cypress/results && touch ./cypress/results/.cypress_fail; fi;"