mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2180 from overleaf/as-clean-up-makefile
Clean up how tests are run in Makefile GitOrigin-RevId: 9b52ead16392cca09bdf7edc4365f10dc468ccf2
This commit is contained in:
parent
9902edcfbb
commit
082f790fb6
8 changed files with 82 additions and 63 deletions
|
@ -9,6 +9,7 @@ DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
||||||
BRANCH_NAME=$(BRANCH_NAME) \
|
BRANCH_NAME=$(BRANCH_NAME) \
|
||||||
PROJECT_NAME=$(PROJECT_NAME) \
|
PROJECT_NAME=$(PROJECT_NAME) \
|
||||||
MOCHA_GREP=${MOCHA_GREP} \
|
MOCHA_GREP=${MOCHA_GREP} \
|
||||||
|
SHARELATEX_CONFIG=/app/test/acceptance/config/settings.test.coffee \
|
||||||
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
||||||
|
|
||||||
MODULE_DIRS := $(shell find modules -mindepth 1 -maxdepth 1 -type d -not -name '.git' )
|
MODULE_DIRS := $(shell find modules -mindepth 1 -maxdepth 1 -type d -not -name '.git' )
|
||||||
|
@ -57,6 +58,10 @@ $(MODULE_MAKEFILES): Makefile.module
|
||||||
cp Makefile.module $$makefile; \
|
cp Makefile.module $$makefile; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#
|
||||||
|
# Clean
|
||||||
|
#
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f public/stylesheets/*.css*
|
rm -f public/stylesheets/*.css*
|
||||||
|
|
||||||
|
@ -66,20 +71,44 @@ clean_ci:
|
||||||
docker image prune -af --filter "until=48h"
|
docker image prune -af --filter "until=48h"
|
||||||
docker network prune -f
|
docker network prune -f
|
||||||
|
|
||||||
|
#
|
||||||
|
# Tests
|
||||||
|
#
|
||||||
|
|
||||||
test: test_unit test_frontend test_acceptance
|
test: test_unit test_frontend test_acceptance
|
||||||
|
|
||||||
test_module: test_unit_module_run test_acceptance_module_run
|
test_module: test_unit_module test_acceptance_module
|
||||||
|
|
||||||
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
|
# Unit tests
|
||||||
|
#
|
||||||
|
|
||||||
test_unit_module: test_unit_module_run
|
test_unit: test_unit_app test_unit_modules
|
||||||
|
|
||||||
test_unit_module_run:
|
|
||||||
COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --name unit_test_$(BUILD_DIR_NAME) --rm test_unit bin/unit_test_module $(MODULE_NAME) --grep=$(MOCHA_GREP)
|
|
||||||
|
|
||||||
test_unit_app:
|
test_unit_app:
|
||||||
npm -q run test:unit:app -- ${MOCHA_ARGS}
|
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
|
||||||
|
|
||||||
|
test_unit_modules:
|
||||||
|
@set -e; \
|
||||||
|
for dir in $(MODULE_DIRS); \
|
||||||
|
do \
|
||||||
|
if [ -e $$dir/test/unit ]; then \
|
||||||
|
$(MAKE) test_unit_module MODULE=$$dir; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
test_unit_module: $(MODULE_MAKEFILES)
|
||||||
|
@if [ -e modules/$(MODULE_NAME)/test/unit ]; then \
|
||||||
|
COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(DOCKER_COMPOSE) down -v -t 0 \
|
||||||
|
&& cd modules/$(MODULE_NAME) && COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(MAKE) test_unit \
|
||||||
|
&& cd $(CURDIR) && COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(DOCKER_COMPOSE) down -v -t 0; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Frontend unit tests
|
||||||
|
#
|
||||||
|
|
||||||
test_frontend: compile build_test_frontend test_frontend_run
|
test_frontend: compile build_test_frontend test_frontend_run
|
||||||
|
|
||||||
|
@ -90,39 +119,45 @@ test_frontend_run:
|
||||||
|
|
||||||
test_frontend_build_run: build_test_frontend test_frontend_run
|
test_frontend_build_run: build_test_frontend test_frontend_run
|
||||||
|
|
||||||
test_acceptance: test_acceptance_app_run test_acceptance_modules_run
|
#
|
||||||
|
# Acceptance tests
|
||||||
|
#
|
||||||
|
|
||||||
test_acceptance_app: test_acceptance_app_run
|
test_acceptance: test_acceptance_app test_acceptance_modules
|
||||||
|
|
||||||
test_acceptance_module: test_acceptance_module_run
|
test_acceptance_app:
|
||||||
|
|
||||||
test_acceptance_run: test_acceptance_app_run test_acceptance_modules_run
|
|
||||||
|
|
||||||
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) 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/src
|
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm test_acceptance
|
||||||
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
||||||
|
|
||||||
test_acceptance_modules_run:
|
test_acceptance_modules:
|
||||||
@set -e; \
|
@set -e; \
|
||||||
for dir in $(MODULE_DIRS); \
|
for dir in $(MODULE_DIRS); \
|
||||||
do \
|
do \
|
||||||
if [ -e $$dir/test/acceptance ]; then \
|
if [ -e $$dir/test/acceptance ]; then \
|
||||||
$(MAKE) test_acceptance_module_run MODULE=$$dir; \
|
$(MAKE) test_acceptance_module MODULE=$$dir; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
||||||
test_acceptance_module_run: $(MODULE_MAKEFILES)
|
test_acceptance_module: $(MODULE_MAKEFILES)
|
||||||
@if [ -e modules/$(MODULE_NAME)/test/acceptance ]; then \
|
@if [ -e modules/$(MODULE_NAME)/test/acceptance ]; then \
|
||||||
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(DOCKER_COMPOSE) down -v -t 0 \
|
COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(DOCKER_COMPOSE) down -v -t 0 \
|
||||||
&& cd modules/$(MODULE_NAME) && COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(MAKE) test_acceptance \
|
&& cd modules/$(MODULE_NAME) && COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(MAKE) test_acceptance \
|
||||||
&& cd $(CURDIR) && COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(DOCKER_COMPOSE) down -v -t 0; \
|
&& cd $(CURDIR) && COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) $(DOCKER_COMPOSE) down -v -t 0; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# CI tests
|
||||||
|
#
|
||||||
|
|
||||||
ci:
|
ci:
|
||||||
MOCHA_ARGS="--reporter tap" \
|
MOCHA_ARGS="--reporter tap" \
|
||||||
$(MAKE) test
|
$(MAKE) test
|
||||||
|
|
||||||
|
#
|
||||||
|
# Lint & format
|
||||||
|
#
|
||||||
|
|
||||||
format:
|
format:
|
||||||
npm -q run format
|
npm -q run format
|
||||||
|
|
||||||
|
@ -131,7 +166,11 @@ format_fix:
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
npm -q run lint
|
npm -q run lint
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build & publish
|
||||||
|
#
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
||||||
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
||||||
|
@ -148,6 +187,10 @@ tar:
|
||||||
COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0
|
||||||
|
|
||||||
.PHONY:
|
.PHONY:
|
||||||
all add install update test test_unit test_frontend test_acceptance \
|
css_full css minify minify_css minify_es compile compile_full \
|
||||||
test_acceptance_start_service test_acceptance_stop_service \
|
compile_css_full compile_modules compile_modules_full clean clean_frontend \
|
||||||
test_acceptance_run ci ci_clean compile clean css
|
clean_css clean_tests clean_ci test test_module test_unit test_unit_app \
|
||||||
|
test_unit_modules test_unit_module test_frontend test_frontend_run \
|
||||||
|
test_frontend_build_run test_acceptance test_acceptance_app \
|
||||||
|
test_acceptance_modules test_acceptance_module ci format format_fix lint \
|
||||||
|
build build_test_frontend publish tar
|
|
@ -2,15 +2,18 @@ MODULE_NAME := $(notdir $(shell pwd))
|
||||||
MODULE_DIR := modules/$(MODULE_NAME)
|
MODULE_DIR := modules/$(MODULE_NAME)
|
||||||
PROJECT_NAME = web
|
PROJECT_NAME = web
|
||||||
|
|
||||||
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
|
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml --log-level ERROR
|
||||||
DOCKER_COMPOSE_MODULE_FLAGS := ${DOCKER_COMPOSE_FLAGS} -f $(MODULE_DIR)/docker-compose.yml
|
|
||||||
DOCKER_COMPOSE := cd ../../ && \
|
DOCKER_COMPOSE := cd ../../ && \
|
||||||
MODULE_DIR=$(MODULE_DIR) \
|
MODULE_DIR=$(MODULE_DIR) \
|
||||||
BUILD_NUMBER=$(BUILD_NUMBER) \
|
BUILD_NUMBER=$(BUILD_NUMBER) \
|
||||||
BRANCH_NAME=$(BRANCH_NAME) \
|
BRANCH_NAME=$(BRANCH_NAME) \
|
||||||
PROJECT_NAME=$(PROJECT_NAME) \
|
PROJECT_NAME=$(PROJECT_NAME) \
|
||||||
MOCHA_GREP=${MOCHA_GREP} \
|
MOCHA_GREP=${MOCHA_GREP} \
|
||||||
docker-compose ${DOCKER_COMPOSE_MODULE_FLAGS}
|
SHARELATEX_CONFIG=/app/$(MODULE_DIR)/test/acceptance/config/settings.test.coffee \
|
||||||
|
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
||||||
|
|
||||||
|
test_unit:
|
||||||
|
${DOCKER_COMPOSE} run --rm test_unit npm -q run test:unit:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/unit/src
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
${DOCKER_COMPOSE} run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
|
${DOCKER_COMPOSE} run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -e;
|
|
||||||
|
|
||||||
MOCHA="node_modules/.bin/mocha --exit --recursive --reporter spec --require test/unit/bootstrap.js"
|
|
||||||
|
|
||||||
$MOCHA "$@" test/unit/src
|
|
||||||
|
|
||||||
for dir in modules/*;
|
|
||||||
do
|
|
||||||
if [ -d $dir/test/unit/src ]; then
|
|
||||||
$MOCHA "$@" $dir/test/unit/src
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -e;
|
|
||||||
|
|
||||||
MOCHA="node_modules/.bin/mocha --exit --recursive --reporter spec --require test/unit/bootstrap.js"
|
|
||||||
|
|
||||||
$MOCHA "$@" test/unit/src
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -e;
|
|
||||||
|
|
||||||
MOCHA="node_modules/.bin/mocha --exit --recursive --reporter spec --require test/unit/bootstrap.js"
|
|
||||||
MODULE=$1
|
|
||||||
|
|
||||||
shift
|
|
||||||
|
|
||||||
$MOCHA "$@" modules/$MODULE/test/unit/src
|
|
|
@ -9,7 +9,7 @@ services:
|
||||||
build: .
|
build: .
|
||||||
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
||||||
user: node
|
user: node
|
||||||
command: npm run test:unit:ci
|
command: npm run test:unit:app
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
build: .
|
build: .
|
||||||
|
@ -22,8 +22,9 @@ services:
|
||||||
PROJECT_HISTORY_ENABLED: 'true'
|
PROJECT_HISTORY_ENABLED: 'true'
|
||||||
ENABLED_LINKED_FILE_TYPES: 'url,project_file,project_output_file,mendeley,zotero'
|
ENABLED_LINKED_FILE_TYPES: 'url,project_file,project_output_file,mendeley,zotero'
|
||||||
LINKED_URL_PROXY: 'http://localhost:6543'
|
LINKED_URL_PROXY: 'http://localhost:6543'
|
||||||
SHARELATEX_CONFIG: /app/test/acceptance/config/settings.test.coffee
|
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
|
SHARELATEX_CONFIG:
|
||||||
|
command: npm run test:acceptance:app
|
||||||
user: root
|
user: root
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
|
|
|
@ -12,7 +12,7 @@ services:
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
environment:
|
environment:
|
||||||
MOCHA_GREP: ${MOCHA_GREP}
|
MOCHA_GREP: ${MOCHA_GREP}
|
||||||
command: npm run test:unit
|
command: npm run test:unit:app
|
||||||
user: node
|
user: node
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
|
@ -27,9 +27,10 @@ services:
|
||||||
PROJECT_HISTORY_ENABLED: 'true'
|
PROJECT_HISTORY_ENABLED: 'true'
|
||||||
LINKED_URL_PROXY: 'http://localhost:6543'
|
LINKED_URL_PROXY: 'http://localhost:6543'
|
||||||
ENABLED_LINKED_FILE_TYPES: 'url,project_file,project_output_file,mendeley,zotero'
|
ENABLED_LINKED_FILE_TYPES: 'url,project_file,project_output_file,mendeley,zotero'
|
||||||
SHARELATEX_CONFIG: /app/test/acceptance/config/settings.test.coffee
|
|
||||||
MOCHA_GREP: ${MOCHA_GREP}
|
MOCHA_GREP: ${MOCHA_GREP}
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
|
SHARELATEX_CONFIG:
|
||||||
|
command: npm run test:acceptance:app
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
- mongo
|
- mongo
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
"public": "./public"
|
"public": "./public"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test:acceptance:run_dir": "mocha --recursive --reporter spec --require test/acceptance/bootstrap.js --timeout 25000 --exit --grep=$MOCHA_GREP $@",
|
"test:acceptance:run_dir": "mocha --recursive --reporter spec --timeout 25000 --exit --grep=$MOCHA_GREP --require test/acceptance/bootstrap.js",
|
||||||
"test:unit": "bin/unit_test --grep=$MOCHA_GREP $@",
|
"test:acceptance:app": "npm run test:acceptance:run_dir -- test/acceptance/src",
|
||||||
"test:unit:ci": "bin/unit_test --timeout 10000",
|
"test:unit:run_dir": "mocha --recursive --reporter spec --timeout 25000 --exit --grep=$MOCHA_GREP --require test/unit/bootstrap.js",
|
||||||
"test:unit:app": "bin/unit_test_app $@",
|
"test:unit:app": "npm run test:unit:run_dir -- test/unit/src",
|
||||||
"test:frontend": "karma start",
|
"test:frontend": "karma start",
|
||||||
"test:frontend:single": "karma start --single-run",
|
"test:frontend:single": "karma start --single-run",
|
||||||
"compile": "make compile",
|
"compile": "make compile",
|
||||||
|
|
Loading…
Reference in a new issue