ci.yml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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@v2
  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-dependencies
  21. uses: actions/cache@v1
  22. with:
  23. path: node_modules
  24. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  25. - name: Get yarn cache dir
  26. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  27. id: cache-yarn
  28. run: echo "::set-output name=dir::$(yarn cache dir)"
  29. - name: Cache/Restore yarn cache
  30. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  31. uses: actions/cache@v1
  32. with:
  33. path: ${{ steps.cache-yarn.outputs.dir }}
  34. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  35. restore-keys: |
  36. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  37. - name: Install dependencies
  38. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  39. run: |
  40. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images@1.0.0 react-motion
  41. - name: Print dependencies
  42. run: |
  43. echo -n "node " && node -v
  44. echo -n "npm " && npm -v
  45. yarn list --depth=0
  46. - name: yarn lint
  47. run: |
  48. yarn lint
  49. - name: Slack Notification
  50. uses: homoluctus/slatify@master
  51. if: failure()
  52. with:
  53. type: ${{ job.status }}
  54. job_name: '*test (${{ matrix.node-version }})*'
  55. channel: '#ci'
  56. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  57. test:
  58. runs-on: ubuntu-latest
  59. strategy:
  60. matrix:
  61. node-version: [12.x]
  62. steps:
  63. - uses: actions/checkout@v2
  64. - name: Use Node.js ${{ matrix.node-version }}
  65. uses: actions/setup-node@v1
  66. with:
  67. node-version: ${{ matrix.node-version }}
  68. - name: Cache/Restore node_modules
  69. id: cache-dependencies
  70. uses: actions/cache@v1
  71. with:
  72. path: node_modules
  73. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  74. - name: Get yarn cache dir
  75. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  76. id: cache-yarn
  77. run: echo "::set-output name=dir::$(yarn cache dir)"
  78. - name: Cache/Restore yarn cache
  79. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  80. uses: actions/cache@v1
  81. with:
  82. path: ${{ steps.cache-yarn.outputs.dir }}
  83. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  84. restore-keys: |
  85. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  86. - name: Install dependencies
  87. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  88. run: |
  89. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images@1.0.0 react-motion
  90. - name: Print dependencies
  91. run: |
  92. echo -n "node " && node -v
  93. echo -n "npm " && npm -v
  94. yarn list --depth=0
  95. - name: Launch MongoDB
  96. uses: wbari/start-mongoDB@v0.2
  97. with:
  98. mongoDBVersion: 3.6
  99. - name: yarn test
  100. run: |
  101. yarn test
  102. env:
  103. MONGO_URI: mongodb://localhost:27017/growi_test
  104. - name: Slack Notification
  105. uses: homoluctus/slatify@master
  106. if: failure()
  107. with:
  108. type: ${{ job.status }}
  109. job_name: '*test (${{ matrix.node-version }})*'
  110. channel: '#ci'
  111. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  112. build-dev:
  113. runs-on: ubuntu-latest
  114. strategy:
  115. matrix:
  116. node-version: [12.x]
  117. steps:
  118. - uses: actions/checkout@v2
  119. - name: Use Node.js ${{ matrix.node-version }}
  120. uses: actions/setup-node@v1
  121. with:
  122. node-version: ${{ matrix.node-version }}
  123. - name: Cache/Restore node_modules
  124. id: cache-dependencies
  125. uses: actions/cache@v1
  126. with:
  127. path: node_modules
  128. key: ${{ runner.OS }}-node_modules_dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  129. - name: Get Date
  130. run: |
  131. echo ::set-env name=DateYmdH::$(date '+%Y%m%d%H')
  132. echo ::set-env name=DateYmd::$(date '+%Y%m%d')
  133. echo ::set-env name=DateYm::$(date '+%Y%m')
  134. echo ::set-env name=DateY::$(date '+%Y')
  135. - name: Cache/Restore node_modules/.cache/hard-source
  136. uses: actions/cache@v1
  137. with:
  138. path: node_modules/.cache
  139. key: ${{ runner.OS }}-hard_source_webpack_dev-${{ matrix.node-version }}-${{ env.DateYmdH }}
  140. restore-keys: |
  141. ${{ runner.os }}-hard_source_webpack_dev-${{ matrix.node-version }}-${{ env.DateYmd }}
  142. ${{ runner.os }}-hard_source_webpack_dev-${{ matrix.node-version }}-${{ env.DateYm }}
  143. ${{ runner.os }}-hard_source_webpack_dev-${{ matrix.node-version }}-${{ env.DateY }}
  144. - name: Get yarn cache dir
  145. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  146. id: cache-yarn
  147. run: echo "::set-output name=dir::$(yarn cache dir)"
  148. - name: Cache/Restore yarn cache
  149. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  150. uses: actions/cache@v1
  151. with:
  152. path: ${{ steps.cache-yarn.outputs.dir }}
  153. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  154. restore-keys: |
  155. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  156. - name: Install dependencies
  157. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  158. run: |
  159. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images@1.0.0 react-motion
  160. - name: Print dependencies
  161. run: |
  162. echo -n "node " && node -v
  163. echo -n "npm " && npm -v
  164. yarn list --depth=0
  165. - name: yarn build:dev
  166. run: |
  167. yarn build:dev
  168. - name: Slack Notification
  169. uses: homoluctus/slatify@master
  170. if: failure()
  171. with:
  172. type: ${{ job.status }}
  173. job_name: '*build-dev (${{ matrix.node-version }})*'
  174. channel: '#ci'
  175. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  176. build-prod:
  177. runs-on: ubuntu-latest
  178. strategy:
  179. matrix:
  180. node-version: [10.x, 12.x]
  181. steps:
  182. - uses: actions/checkout@v2
  183. - name: Use Node.js ${{ matrix.node-version }}
  184. uses: actions/setup-node@v1
  185. with:
  186. node-version: ${{ matrix.node-version }}
  187. - name: Get Date
  188. run: |
  189. echo ::set-env name=DateYmdHM::$(date '+%Y%m%d%H%M')
  190. echo ::set-env name=DateYmdH::$(date '+%Y%m%d%H')
  191. echo ::set-env name=DateYmd::$(date '+%Y%m%d')
  192. echo ::set-env name=DateYm::$(date '+%Y%m')
  193. echo ::set-env name=DateY::$(date '+%Y')
  194. - name: Cache/Restore node_modules
  195. uses: actions/cache@v1
  196. with:
  197. path: node_modules
  198. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ env.DateYmdHM }}
  199. restore-keys: |
  200. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ env.DateYmdH }}
  201. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ env.DateYmd }}
  202. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ env.DateYm }}
  203. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ env.DateY }}
  204. - name: Get yarn cache dir
  205. id: cache-yarn
  206. run: echo "::set-output name=dir::$(yarn cache dir)"
  207. - name: Cache/Restore yarn cache
  208. uses: actions/cache@v1
  209. with:
  210. path: ${{ steps.cache-yarn.outputs.dir }}
  211. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  212. restore-keys: |
  213. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  214. - name: Install dependencies
  215. run: |
  216. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
  217. yarn add -D react-images@1.0.0 react-motion
  218. - name: Print dependencies
  219. run: |
  220. echo -n "node " && node -v
  221. echo -n "npm " && npm -v
  222. yarn list --depth=0
  223. - name: yarn build:prod:analyze
  224. run: |
  225. yarn build:prod:analyze
  226. - name: yarn install --production
  227. run: |
  228. yarn install --production
  229. - name: Print dependencies
  230. run: |
  231. echo -n "node " && node -v
  232. echo -n "npm " && npm -v
  233. yarn list --production --depth=0
  234. - name: Launch MongoDB
  235. uses: wbari/start-mongoDB@v0.2
  236. with:
  237. mongoDBVersion: 3.6
  238. - name: yarn server:prod:ci
  239. run: |
  240. yarn server:prod:ci
  241. env:
  242. MONGO_URI: mongodb://localhost:27017/growi
  243. - name: Upload report as artifact
  244. uses: actions/upload-artifact@v1
  245. with:
  246. name: Report
  247. path: report
  248. - name: Slack Notification
  249. uses: homoluctus/slatify@master
  250. if: failure()
  251. with:
  252. type: ${{ job.status }}
  253. job_name: '*build-prod (${{ matrix.node-version }})*'
  254. channel: '#ci'
  255. url: ${{ secrets.SLACK_WEBHOOK_URL }}