makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. NPM := docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} run --rm npm npm
  2. BUILD_NUMBER ?= local
  3. BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
  4. PROJECT_NAME = web
  5. all: install test
  6. @echo "Run:"
  7. @echo " make install to set up the project dependencies (in docker)"
  8. @echo " make test to run all the tests for the project (in docker)"
  9. @echo " make run to run the app (natively)"
  10. add:
  11. $(NPM) install --save ${P}
  12. add_dev:
  13. $(NPM) install --save-dev ${P}
  14. install:
  15. $(NPM) install
  16. clean:
  17. rm app.js
  18. rm -r app/js
  19. rm -r test/unit/js
  20. rm -r test/acceptance/js
  21. test: test_unit test_acceptance
  22. test_unit:
  23. docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} run --rm test_unit npm run test:unit -- ${MOCHA_ARGS}
  24. test_acceptance: test_acceptance_start_service test_acceptance_run test_acceptance_stop_service
  25. test_acceptance_start_service:
  26. docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} up -d test_acceptance
  27. test_acceptance_stop_service:
  28. docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} stop test_acceptance
  29. test_acceptance_run:
  30. docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} exec -T test_acceptance npm run test:acceptance -- ${MOCHA_ARGS}
  31. build:
  32. docker build --pull --tag quay.io/sharelatex/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) .
  33. publish:
  34. docker push quay.io/sharelatex/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
  35. ci:
  36. # When we run the tests locally we mount the local directory as a volumne
  37. # and use a persistent node_modules folder (see docker-compose.yml).
  38. # However, on the CI server, we want to run our tests in the image that we
  39. # have built for deployment, which is what the docker-compose.ci.yml
  40. # override does.
  41. PROJECT_NAME=$(PROJECT_NAME) \
  42. BRANCH_NAME=$(BRANCH_NAME) \
  43. BUILD_NUMBER=$(BUILD_NUMBER) \
  44. DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" \
  45. $(MAKE) build test publish
  46. .PHONY:
  47. add install update test test_unit test_acceptance \
  48. test_acceptance_start_service test_acceptance_stop_service \
  49. test_acceptance_run build publish ci