Gruntfile.coffee 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. module.exports = (grunt) ->
  2. grunt.loadNpmTasks 'grunt-contrib-coffee'
  3. grunt.loadNpmTasks 'grunt-contrib-clean'
  4. grunt.loadNpmTasks 'grunt-mocha-test'
  5. grunt.loadNpmTasks 'grunt-available-tasks'
  6. grunt.loadNpmTasks 'grunt-execute'
  7. grunt.loadNpmTasks 'grunt-bunyan'
  8. grunt.loadNpmTasks 'grunt-forever'
  9. grunt.loadNpmTasks 'grunt-shell'
  10. grunt.initConfig
  11. forever:
  12. app:
  13. options:
  14. index: "app.js"
  15. execute:
  16. app:
  17. src: "app.js"
  18. bunyan:
  19. strict: false
  20. coffee:
  21. app_dir:
  22. expand: true,
  23. flatten: false,
  24. cwd: 'app/coffee',
  25. src: ['**/*.coffee'],
  26. dest: 'app/js/',
  27. ext: '.js'
  28. app:
  29. src: 'app.coffee'
  30. dest: 'app.js'
  31. acceptance_tests:
  32. expand: true,
  33. flatten: false,
  34. cwd: 'test/acceptance/coffee',
  35. src: ['**/*.coffee'],
  36. dest: 'test/acceptance/js/',
  37. ext: '.js'
  38. unit_tests:
  39. expand: true,
  40. flatten: false,
  41. cwd: 'test/unit/coffee',
  42. src: ['**/*.coffee'],
  43. dest: 'test/unit/js/',
  44. ext: '.js'
  45. clean:
  46. app: ["app/js"]
  47. acceptance_tests: ["test/acceptance/js"]
  48. unit_tests: ["test/unit/js"]
  49. mochaTest:
  50. unit:
  51. src: ["test/unit/js/#{grunt.option('feature') or '**'}/*.js"]
  52. options:
  53. reporter: grunt.option('reporter') or 'spec'
  54. grep: grunt.option("grep")
  55. acceptance:
  56. src: ["test/acceptance/js/#{grunt.option('feature') or '*'}.js"]
  57. options:
  58. reporter: grunt.option('reporter') or 'spec'
  59. grep: grunt.option("grep")
  60. timeout: 10000
  61. shell:
  62. fullAcceptanceTests:
  63. command: "bash ./test/acceptance/scripts/full-test.sh"
  64. dockerTests:
  65. command: 'docker run -v "$(pwd):/app" --rm sl-acceptance-test-runner'
  66. availabletasks:
  67. tasks:
  68. options:
  69. filter: 'exclude',
  70. tasks: [
  71. 'coffee'
  72. 'clean'
  73. 'mochaTest'
  74. 'availabletasks'
  75. 'execute'
  76. 'bunyan'
  77. ]
  78. groups:
  79. "Compile tasks": [
  80. "compile:server"
  81. "compile:tests"
  82. "compile"
  83. "compile:unit_tests"
  84. "compile:acceptance_tests"
  85. "install"
  86. ]
  87. "Test tasks": [
  88. "test:unit"
  89. "test:acceptance"
  90. ]
  91. "Run tasks": [
  92. "run"
  93. "default"
  94. ]
  95. "Misc": [
  96. "help"
  97. ]
  98. grunt.registerTask 'help', 'Display this help list', 'availabletasks'
  99. grunt.registerTask 'compile:server', 'Compile the server side coffee script', ['clean:app', 'coffee:app', 'coffee:app_dir']
  100. grunt.registerTask 'compile:unit_tests', 'Compile the unit tests', ['clean:unit_tests', 'coffee:unit_tests']
  101. grunt.registerTask 'compile:acceptance_tests', 'Compile the acceptance tests', ['clean:acceptance_tests', 'coffee:acceptance_tests']
  102. grunt.registerTask 'compile:tests', 'Compile all the tests', ['compile:acceptance_tests', 'compile:unit_tests']
  103. grunt.registerTask 'compile', 'Compiles everything need to run document-updater-sharelatex', ['compile:server']
  104. grunt.registerTask 'install', "Compile everything when installing as an npm module", ['compile']
  105. grunt.registerTask 'test:unit', 'Run the unit tests (use --grep=<regex> for individual tests)', ['compile:server', 'compile:unit_tests', 'mochaTest:unit']
  106. grunt.registerTask(
  107. 'test:acceptance:full',
  108. "Start server and run acceptance tests",
  109. ['shell:fullAcceptanceTests']
  110. )
  111. grunt.registerTask(
  112. 'test:acceptance:docker',
  113. "Run acceptance tests inside docker container",
  114. ['shell:dockerTests']
  115. )
  116. grunt.registerTask 'test:acceptance', 'Run the acceptance tests (use --grep=<regex> for individual tests)', ['compile:acceptance_tests', 'mochaTest:acceptance']
  117. grunt.registerTask 'run', "Compile and run the document-updater-sharelatex server", ['compile', 'bunyan', 'execute']
  118. grunt.registerTask 'default', 'run'