ci.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. name: Node CI
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - tmp/**
  7. jobs:
  8. lint:
  9. runs-on: ubuntu-latest
  10. strategy:
  11. matrix:
  12. node-version: [12.x]
  13. steps:
  14. - uses: actions/checkout@v1
  15. - name: Use Node.js ${{ matrix.node-version }}
  16. uses: actions/setup-node@v1
  17. with:
  18. node-version: ${{ matrix.node-version }}
  19. - name: Cache/Restore node_modules
  20. id: cache
  21. uses: actions/cache@v1
  22. with:
  23. path: node_modules
  24. key: ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  25. restore-keys: |
  26. ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-
  27. - name: Install dependencies
  28. if: steps.cache.outputs.cache-hit != 'true'
  29. run: |
  30. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  31. - name: Print dependencies
  32. run: |
  33. echo -n "node " && node -v
  34. echo -n "npm " && npm -v
  35. yarn list --depth=0
  36. - name: yarn lint
  37. run: |
  38. yarn lint
  39. - name: Slack Notification
  40. uses: homoluctus/slatify@master
  41. if: failure()
  42. with:
  43. type: ${{ job.status }}
  44. job_name: '*test (${{ matrix.node-version }})*'
  45. channel: '#ci'
  46. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  47. test:
  48. runs-on: ubuntu-latest
  49. strategy:
  50. matrix:
  51. node-version: [12.x]
  52. steps:
  53. - uses: actions/checkout@v1
  54. - name: Use Node.js ${{ matrix.node-version }}
  55. uses: actions/setup-node@v1
  56. with:
  57. node-version: ${{ matrix.node-version }}
  58. - name: Cache/Restore node_modules
  59. id: cache
  60. uses: actions/cache@v1
  61. with:
  62. path: node_modules
  63. key: ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  64. restore-keys: |
  65. ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-
  66. - name: Install dependencies
  67. if: steps.cache.outputs.cache-hit != 'true'
  68. run: |
  69. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  70. - name: Print dependencies
  71. run: |
  72. echo -n "node " && node -v
  73. echo -n "npm " && npm -v
  74. yarn list --depth=0
  75. - name: Launch MongoDB
  76. uses: wbari/start-mongoDB@v0.2
  77. with:
  78. mongoDBVersion: 3.6
  79. - name: yarn test
  80. run: |
  81. yarn test
  82. env:
  83. MONGO_URI: mongodb://localhost:27017/growi_test
  84. - name: Slack Notification
  85. uses: homoluctus/slatify@master
  86. if: failure()
  87. with:
  88. type: ${{ job.status }}
  89. job_name: '*test (${{ matrix.node-version }})*'
  90. channel: '#ci'
  91. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  92. build-dev:
  93. runs-on: ubuntu-latest
  94. strategy:
  95. matrix:
  96. node-version: [12.x]
  97. steps:
  98. - uses: actions/checkout@v1
  99. - name: Use Node.js ${{ matrix.node-version }}
  100. uses: actions/setup-node@v1
  101. with:
  102. node-version: ${{ matrix.node-version }}
  103. - name: Cache/Restore node_modules
  104. id: cache
  105. uses: actions/cache@v1
  106. with:
  107. path: node_modules
  108. key: ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  109. restore-keys: |
  110. ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-
  111. - name: Install dependencies
  112. if: steps.cache.outputs.cache-hit != 'true'
  113. run: |
  114. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  115. - name: Print dependencies
  116. run: |
  117. echo -n "node " && node -v
  118. echo -n "npm " && npm -v
  119. yarn list --depth=0
  120. - name: yarn build:dev
  121. run: |
  122. yarn build:dev
  123. - name: Slack Notification
  124. uses: homoluctus/slatify@master
  125. if: failure()
  126. with:
  127. type: ${{ job.status }}
  128. job_name: '*build-dev (${{ matrix.node-version }})*'
  129. channel: '#ci'
  130. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  131. build-prod:
  132. runs-on: ubuntu-latest
  133. strategy:
  134. matrix:
  135. node-version: [10.x, 12.x]
  136. steps:
  137. - uses: actions/checkout@v1
  138. - name: Use Node.js ${{ matrix.node-version }}
  139. uses: actions/setup-node@v1
  140. with:
  141. node-version: ${{ matrix.node-version }}
  142. - name: Cache/Restore node_modules
  143. id: cache-dependencies
  144. uses: actions/cache@v1
  145. with:
  146. path: node_modules
  147. key: ${{ runner.OS }}-node_modules-prod-${{ matrix.node-version }}-$GITHUB_SHA
  148. restore-keys: |
  149. ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  150. ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-
  151. - name: Install dependencies
  152. run: |
  153. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  154. - name: Print dependencies
  155. run: |
  156. echo -n "node " && node -v
  157. echo -n "npm " && npm -v
  158. yarn list --depth=0
  159. - name: Store env vars for the key of cache-public
  160. run: |
  161. GIT_BRANCH=`echo $GITHUB_REF | sed 's/refs\/heads\///g'`
  162. GIT_BRANCH=`echo $GIT_BRANCH | sed 's/\//-/g'`
  163. TODAY=`date '+%Y%m%d'`
  164. echo ::set-env name=GIT_BRANCH::$GIT_BRANCH
  165. echo ::set-env name=TODAY::$TODAY
  166. - name: Cache/Restore public
  167. id: cache-public
  168. uses: actions/cache@v1
  169. with:
  170. path: node_modules
  171. key: ${{ runner.OS }}-public-prod-${{ matrix.node-version }}-${{ env.GIT_BRANCH }}-${{ env.TODAY }}
  172. restore-keys: |
  173. ${{ runner.OS }}-public-prod-${{ matrix.node-version }}-${{ env.GIT_BRANCH }}-
  174. - name: yarn build:prod
  175. if: steps.cache-public.outputs.cache-hit != 'true'
  176. run: |
  177. yarn build:prod
  178. - name: yarn install --production
  179. run: |
  180. yarn install --production
  181. - name: Print dependencies
  182. run: |
  183. echo -n "node " && node -v
  184. echo -n "npm " && npm -v
  185. yarn list --depth=0
  186. - name: Launch MongoDB
  187. uses: wbari/start-mongoDB@v0.2
  188. with:
  189. mongoDBVersion: 3.6
  190. - name: yarn server:prod:ci
  191. run: |
  192. yarn server:prod:ci
  193. env:
  194. MONGO_URI: mongodb://localhost:27017/growi
  195. - name: Slack Notification
  196. uses: homoluctus/slatify@master
  197. if: failure()
  198. with:
  199. type: ${{ job.status }}
  200. job_name: '*build-prod (${{ matrix.node-version }})*'
  201. channel: '#ci'
  202. url: ${{ secrets.SLACK_WEBHOOK_URL }}