mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 20:53:12 -05:00
run unit and acceptance tests in parallel (#1545)
GitOrigin-RevId: fefdfa04d9b9496bf6c98b37331fc4a084de065a
This commit is contained in:
parent
5d8b8ff012
commit
2421593d85
4 changed files with 39 additions and 18 deletions
11
services/web/Dockerfile.frontend.ci
Normal file
11
services/web/Dockerfile.frontend.ci
Normal file
|
@ -0,0 +1,11 @@
|
|||
ARG PROJECT_NAME
|
||||
ARG BRANCH_NAME
|
||||
ARG BUILD_NUMBER
|
||||
|
||||
FROM ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
||||
|
||||
USER root
|
||||
|
||||
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
|
||||
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
|
||||
apt-get update && apt-get install -y google-chrome-stable
|
|
@ -4,6 +4,7 @@ DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
|
|||
BUILD_NUMBER ?= local
|
||||
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||
PROJECT_NAME = web
|
||||
BUILD_DIR_NAME = $(shell pwd | xargs basename | tr -cd '[a-zA-Z0-9_.\-]')
|
||||
|
||||
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
||||
BRANCH_NAME=$(BRANCH_NAME) \
|
||||
|
@ -212,15 +213,19 @@ clean_ci:
|
|||
test: test_unit test_frontend test_acceptance
|
||||
|
||||
test_unit:
|
||||
@[ ! -d test/unit ] && echo "web has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit
|
||||
@[ ! -d test/unit ] && echo "web has no unit tests" || COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --name unit_test_$(BUILD_DIR_NAME) --rm test_unit
|
||||
|
||||
test_unit_app:
|
||||
npm -q run test:unit:app -- ${MOCHA_ARGS}
|
||||
|
||||
test_frontend: test_clean compile test_frontend_run
|
||||
test_frontend: compile build_test_frontend test_frontend_run
|
||||
|
||||
test_frontend_run:
|
||||
$(DOCKER_COMPOSE) up test_frontend
|
||||
COMPOSE_PROJECT_NAME=frontend_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
||||
COMPOSE_PROJECT_NAME=frontend_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_frontend
|
||||
COMPOSE_PROJECT_NAME=frontend_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
||||
|
||||
test_frontend_build_run: build_test_frontend test_frontend_run
|
||||
|
||||
test_acceptance: compile test_acceptance_app_run test_acceptance_modules_run
|
||||
|
||||
|
@ -230,8 +235,10 @@ test_acceptance_module: compile test_acceptance_module_run
|
|||
|
||||
test_acceptance_run: test_acceptance_app_run test_acceptance_modules_run
|
||||
|
||||
test_acceptance_app_run: test_clean
|
||||
$(DOCKER_COMPOSE) run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} test/acceptance/js
|
||||
test_acceptance_app_run:
|
||||
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
||||
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_acceptance npm -q run test:acceptance:run_dir test/acceptance/js
|
||||
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
||||
|
||||
test_acceptance_modules_run:
|
||||
@set -e; \
|
||||
|
@ -242,14 +249,13 @@ test_acceptance_modules_run:
|
|||
fi; \
|
||||
done
|
||||
|
||||
test_acceptance_module_run: $(MODULE_MAKEFILES) test_clean
|
||||
test_acceptance_module_run: $(MODULE_MAKEFILES)
|
||||
@if [ -e $(MODULE)/test/acceptance ]; then \
|
||||
cd $(MODULE) && $(MAKE) test_acceptance; \
|
||||
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE) $(DOCKER_COMPOSE) down -v -t 0; \
|
||||
cd $(MODULE) && COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE) $(MAKE) test_acceptance; \
|
||||
cd $(CURDIR) && COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE) $(DOCKER_COMPOSE) down -v -t 0; \
|
||||
fi
|
||||
|
||||
test_clean:
|
||||
$(DOCKER_COMPOSE) down -v -t 0
|
||||
|
||||
ci:
|
||||
MOCHA_ARGS="--reporter tap" \
|
||||
$(MAKE) test
|
||||
|
@ -262,18 +268,21 @@ format_fix:
|
|||
|
||||
lint:
|
||||
npm -q run lint
|
||||
|
||||
|
||||
build:
|
||||
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
||||
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
||||
.
|
||||
|
||||
build_test_frontend:
|
||||
COMPOSE_PROJECT_NAME=frontend_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) build test_frontend
|
||||
|
||||
publish:
|
||||
docker push $(DOCKER_REPO)/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
||||
|
||||
tar:
|
||||
$(DOCKER_COMPOSE) up tar
|
||||
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
|
||||
|
||||
.PHONY:
|
||||
all add install update test test_unit test_frontend test_acceptance \
|
||||
|
|
|
@ -28,16 +28,18 @@ services:
|
|||
depends_on:
|
||||
- redis
|
||||
- mongo
|
||||
command: npm run test:acceptance:app
|
||||
|
||||
test_frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.frontend
|
||||
volumes:
|
||||
- .:/app
|
||||
dockerfile: Dockerfile.frontend.ci
|
||||
args:
|
||||
PROJECT_NAME: $PROJECT_NAME
|
||||
BRANCH_NAME: $BRANCH_NAME
|
||||
BUILD_NUMBER: $BUILD_NUMBER
|
||||
working_dir: /app
|
||||
command: npm run test:frontend -- --single-run
|
||||
user: node
|
||||
|
||||
tar:
|
||||
build: .
|
||||
|
@ -52,4 +54,3 @@ services:
|
|||
|
||||
mongo:
|
||||
image: mongo:3.4.6
|
||||
container_name: mongo-ci-$BUILD_NUMBER
|
||||
|
|
|
@ -18,7 +18,7 @@ services:
|
|||
test_acceptance:
|
||||
image: node:6.15.1
|
||||
volumes:
|
||||
- .:/app:ro
|
||||
- .:/app
|
||||
working_dir: /app
|
||||
environment:
|
||||
REDIS_HOST: redis
|
||||
|
|
Loading…
Reference in a new issue