Makefile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
  2. NPM := docker-compose ${DOCKER_COMPOSE_FLAGS} run --rm npm npm -q
  3. BUILD_NUMBER ?= local
  4. BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
  5. PROJECT_NAME = web
  6. all: install test
  7. @echo "Run:"
  8. @echo " make install to set up the project dependencies (in docker)"
  9. @echo " make test to run all the tests for the project (in docker)"
  10. add: docker-shared.yml
  11. $(NPM) install --save ${P}
  12. add_dev: docker-shared.yml
  13. $(NPM) install --save-dev ${P}
  14. install: docker-shared.yml
  15. $(NPM) install
  16. clean:
  17. rm -f app.js
  18. rm -rf app/js
  19. rm -rf test/unit/js
  20. rm -rf test/acceptance/js
  21. for dir in modules/*; \
  22. do \
  23. rm -f $$dir/index.js; \
  24. rm -rf $$dir/app/js; \
  25. rm -rf $$dir/test/unit/js; \
  26. rm -rf $$dir/test/acceptance/js; \
  27. done
  28. # Regenerate docker-shared.yml - not stictly a 'clean',
  29. # but lets `make clean install` work nicely
  30. bin/generate_volumes_file
  31. # Deletes node_modules volume
  32. docker-compose down --volumes
  33. # Need regenerating if you change the web modules you have installed
  34. docker-shared.yml:
  35. bin/generate_volumes_file
  36. test: test_unit test_acceptance
  37. test_unit: docker-shared.yml
  38. docker-compose ${DOCKER_COMPOSE_FLAGS} run --rm test_unit npm -q run test:unit -- ${MOCHA_ARGS}
  39. test_acceptance: test_acceptance_app test_acceptance_modules
  40. test_acceptance_app: test_acceptance_app_start_service test_acceptance_app_run test_acceptance_app_stop_service
  41. test_acceptance_app_start_service: test_acceptance_app_stop_service docker-shared.yml
  42. docker-compose ${DOCKER_COMPOSE_FLAGS} up -d test_acceptance
  43. test_acceptance_app_stop_service: docker-shared.yml
  44. docker-compose ${DOCKER_COMPOSE_FLAGS} stop test_acceptance redis mongo
  45. test_acceptance_app_run: docker-shared.yml
  46. docker-compose ${DOCKER_COMPOSE_FLAGS} exec -T test_acceptance npm -q run test:acceptance -- ${MOCHA_ARGS}
  47. test_acceptance_modules: docker-shared.yml
  48. # Break and error on any module failure
  49. set -e; \
  50. for dir in modules/*; \
  51. do \
  52. if [ -e $$dir/Makefile ]; then \
  53. (make test_acceptance_module MODULE=$$dir) \
  54. fi \
  55. done
  56. test_acceptance_module: docker-shared.yml
  57. cd $(MODULE) && make test_acceptance
  58. .PHONY:
  59. all add install update test test_unit test_acceptance \
  60. test_acceptance_start_service test_acceptance_stop_service \
  61. test_acceptance_run