ci.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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: 8398a7/action-slack@v2
  66. if: always()
  67. with:
  68. status: ${{ job.status }}
  69. author_name: 'test' Job
  70. channel: ci
  71. env:
  72. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  73. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  74. build-dev:
  75. runs-on: ubuntu-latest
  76. needs: resolve-dependencies
  77. strategy:
  78. matrix:
  79. node-version: [10.x, 12.x]
  80. steps:
  81. - uses: actions/checkout@v1
  82. - name: Use Node.js ${{ matrix.node-version }}
  83. uses: actions/setup-node@v1
  84. with:
  85. node-version: ${{ matrix.node-version }}
  86. - name: Cache/Restore node_modules
  87. uses: actions/cache@v1
  88. with:
  89. path: node_modules
  90. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  91. - name: yarn build:dev
  92. run: |
  93. yarn build:dev
  94. - name: Slack Notification
  95. uses: 8398a7/action-slack@v2
  96. if: always()
  97. with:
  98. status: ${{ job.status }}
  99. author_name: 'build-dev' Job
  100. channel: ci
  101. env:
  102. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  103. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  104. build-prod:
  105. runs-on: ubuntu-latest
  106. needs: resolve-dependencies
  107. strategy:
  108. matrix:
  109. node-version: [10.x, 12.x]
  110. steps:
  111. - uses: actions/checkout@v1
  112. - name: Use Node.js ${{ matrix.node-version }}
  113. uses: actions/setup-node@v1
  114. with:
  115. node-version: ${{ matrix.node-version }}
  116. - name: Cache/Restore node_modules
  117. uses: actions/cache@v1
  118. with:
  119. path: node_modules
  120. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}--build-prod
  121. restore-keys: |
  122. ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  123. - name: Launch MongoDB
  124. uses: wbari/start-mongoDB@v0.2
  125. with:
  126. mongoDBVersion: 3.6
  127. - name: yarn build:prod:analyze
  128. run: |
  129. yarn build:prod:analyze
  130. - name: shrink dependencies for production
  131. run: |
  132. yarn install --production
  133. - name: yarn server:prod:ci
  134. run: |
  135. yarn server:prod:ci
  136. env:
  137. MONGO_URI: mongodb://localhost:27017/growi
  138. - name: Slack Notification
  139. uses: 8398a7/action-slack@v2
  140. if: always()
  141. with:
  142. status: ${{ job.status }}
  143. author_name: 'build-prod' Job
  144. channel: ci
  145. env:
  146. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  147. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}