ci.yml 9.1 KB

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