ci.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. name: Node CI
  2. on: [push]
  3. jobs:
  4. resolve-dependencies:
  5. runs-on: ubuntu-latest
  6. strategy:
  7. matrix:
  8. node-version: [10.x, 12.x]
  9. steps:
  10. - uses: actions/checkout@v1
  11. - name: Use Node.js ${{ matrix.node-version }}
  12. uses: actions/setup-node@v1
  13. with:
  14. node-version: ${{ matrix.node-version }}
  15. - name: Cache/Restore node_modules
  16. id: cache
  17. uses: actions/cache@v1
  18. with:
  19. path: node_modules
  20. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  21. - name: Install dependencies
  22. if: steps.cache.outputs.cache-hit != 'true'
  23. run: |
  24. yarn
  25. - name: Install plugins
  26. if: steps.cache.outputs.cache-hit != 'true'
  27. run: |
  28. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
  29. yarn add -D react-images react-motion
  30. - name: Print dependencies
  31. run: |
  32. echo -n "node " && node -v
  33. echo -n "npm " && npm -v
  34. yarn list --depth=0
  35. test:
  36. runs-on: ubuntu-latest
  37. needs: resolve-dependencies
  38. strategy:
  39. matrix:
  40. node-version: [10.x, 12.x]
  41. steps:
  42. - uses: actions/checkout@v1
  43. - name: Use Node.js ${{ matrix.node-version }}
  44. uses: actions/setup-node@v1
  45. with:
  46. node-version: ${{ matrix.node-version }}
  47. - name: Cache/Restore node_modules
  48. uses: actions/cache@v1
  49. with:
  50. path: node_modules
  51. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  52. - name: yarn lint
  53. run: |
  54. yarn lint
  55. - name: Launch MongoDB
  56. uses: wbari/start-mongoDB@v0.2
  57. with:
  58. mongoDBVersion: 3.6
  59. - name: yarn test
  60. run: |
  61. yarn test
  62. env:
  63. MONGO_URI: mongodb://localhost:27017/growi_test
  64. - name: Slack Notification
  65. uses: homoluctus/slatify@master
  66. if: failure()
  67. with:
  68. type: ${{ job.status }}
  69. job_name: '*test (${{ matrix.node-version }})*'
  70. channel: '#ci'
  71. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  72. build-dev:
  73. runs-on: ubuntu-latest
  74. needs: resolve-dependencies
  75. strategy:
  76. matrix:
  77. node-version: [10.x, 12.x]
  78. steps:
  79. - uses: actions/checkout@v1
  80. - name: Use Node.js ${{ matrix.node-version }}
  81. uses: actions/setup-node@v1
  82. with:
  83. node-version: ${{ matrix.node-version }}
  84. - name: Cache/Restore node_modules
  85. uses: actions/cache@v1
  86. with:
  87. path: node_modules
  88. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  89. - name: yarn build:dev
  90. run: |
  91. yarn build:dev
  92. - name: Slack Notification
  93. uses: homoluctus/slatify@master
  94. if: failure()
  95. with:
  96. type: ${{ job.status }}
  97. job_name: '*build-dev (${{ matrix.node-version }})*'
  98. channel: '#ci'
  99. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  100. build-prod:
  101. runs-on: ubuntu-latest
  102. needs: resolve-dependencies
  103. strategy:
  104. matrix:
  105. node-version: [10.x, 12.x]
  106. steps:
  107. - uses: actions/checkout@v1
  108. - name: Use Node.js ${{ matrix.node-version }}
  109. uses: actions/setup-node@v1
  110. with:
  111. node-version: ${{ matrix.node-version }}
  112. - name: Cache/Restore node_modules
  113. uses: actions/cache@v1
  114. with:
  115. path: node_modules
  116. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  117. - name: Launch MongoDB
  118. uses: wbari/start-mongoDB@v0.2
  119. with:
  120. mongoDBVersion: 3.6
  121. - name: yarn build:prod:analyze
  122. run: |
  123. yarn build:prod:analyze
  124. - name: Shrink dependencies for production
  125. run: |
  126. yarn install --production
  127. - name: yarn server:prod:ci
  128. run: |
  129. yarn server:prod:ci
  130. env:
  131. MONGO_URI: mongodb://localhost:27017/growi
  132. - name: Upload reports
  133. uses: actions/upload-artifact@v1
  134. if: success()
  135. with:
  136. name: report
  137. path: report
  138. - name: Slack Notification
  139. uses: homoluctus/slatify@master
  140. if: failure()
  141. with:
  142. type: ${{ job.status }}
  143. job_name: '*build-prod (${{ matrix.node-version }})*'
  144. channel: '#ci'
  145. url: ${{ secrets.SLACK_WEBHOOK_URL }}