ci.yml 9.3 KB

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