ci.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. name: Node CI for growi
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - tmp/**
  7. paths:
  8. - .github/workflows/ci.yml
  9. - .eslint*
  10. - .prettier*
  11. - .stylelint*
  12. - config
  13. - resource
  14. - src
  15. - package.json
  16. - yarn.lock
  17. jobs:
  18. lint:
  19. runs-on: ubuntu-latest
  20. strategy:
  21. matrix:
  22. node-version: [14.x]
  23. steps:
  24. - uses: actions/checkout@v2
  25. - name: Use Node.js ${{ matrix.node-version }}
  26. uses: actions/setup-node@v1
  27. with:
  28. node-version: ${{ matrix.node-version }}
  29. - name: Cache/Restore node_modules
  30. id: cache-dependencies
  31. uses: actions/cache@v2
  32. with:
  33. path: node_modules
  34. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  35. - name: Get yarn cache dir
  36. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  37. id: cache-yarn
  38. run: echo "::set-output name=dir::$(yarn cache dir)"
  39. - name: Cache/Restore yarn cache
  40. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  41. uses: actions/cache@v2
  42. with:
  43. path: ${{ steps.cache-yarn.outputs.dir }}
  44. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  45. restore-keys: |
  46. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  47. - name: Install dependencies
  48. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  49. run: |
  50. yarn add -W growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images@1.0.0 react-motion
  51. - name: Print dependencies
  52. run: |
  53. echo -n "node " && node -v
  54. echo -n "npm " && npm -v
  55. yarn list --depth=0
  56. - name: yarn lint
  57. run: |
  58. yarn lint
  59. - name: Slack Notification
  60. uses: weseek/ghaction-slack-notification@master
  61. if: failure()
  62. with:
  63. type: ${{ job.status }}
  64. job_name: '*Node CI for growi - lint (${{ matrix.node-version }})*'
  65. channel: '#ci'
  66. isCompactMode: true
  67. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  68. test:
  69. runs-on: ubuntu-latest
  70. strategy:
  71. matrix:
  72. node-version: [14.x]
  73. services:
  74. mongodb:
  75. image: mongo:4.4
  76. ports:
  77. - 27017/tcp
  78. mongodb36:
  79. image: mongo:3.6
  80. ports:
  81. - 27017/tcp
  82. steps:
  83. - uses: actions/checkout@v2
  84. - name: Use Node.js ${{ matrix.node-version }}
  85. uses: actions/setup-node@v1
  86. with:
  87. node-version: ${{ matrix.node-version }}
  88. - name: Cache/Restore node_modules
  89. id: cache-dependencies
  90. uses: actions/cache@v2
  91. with:
  92. path: node_modules
  93. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  94. - name: Get yarn cache dir
  95. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  96. id: cache-yarn
  97. run: echo "::set-output name=dir::$(yarn cache dir)"
  98. - name: Cache/Restore yarn cache
  99. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  100. uses: actions/cache@v2
  101. with:
  102. path: ${{ steps.cache-yarn.outputs.dir }}
  103. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  104. restore-keys: |
  105. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  106. - name: Install dependencies
  107. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  108. run: |
  109. yarn add -W growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images@1.0.0 react-motion
  110. - name: Print dependencies
  111. run: |
  112. echo -n "node " && node -v
  113. echo -n "npm " && npm -v
  114. yarn list --depth=0
  115. - name: yarn test
  116. run: |
  117. yarn test
  118. env:
  119. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_test
  120. - name: yarn test with MongoDB 3.6
  121. run: |
  122. yarn test
  123. env:
  124. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi_test
  125. - name: Slack Notification
  126. uses: weseek/ghaction-slack-notification@master
  127. if: failure()
  128. with:
  129. type: ${{ job.status }}
  130. job_name: '*Node CI for growi - test (${{ matrix.node-version }})*'
  131. channel: '#ci'
  132. isCompactMode: true
  133. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  134. build-dev:
  135. runs-on: ubuntu-latest
  136. strategy:
  137. matrix:
  138. node-version: [14.x]
  139. steps:
  140. - uses: actions/checkout@v2
  141. - name: Use Node.js ${{ matrix.node-version }}
  142. uses: actions/setup-node@v1
  143. with:
  144. node-version: ${{ matrix.node-version }}
  145. - name: Cache/Restore node_modules
  146. id: cache-dependencies
  147. uses: actions/cache@v2
  148. with:
  149. path: node_modules
  150. key: ${{ runner.OS }}-node_modules_dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  151. - name: Get Date
  152. id: date
  153. run: |
  154. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  155. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  156. echo ::set-output name=Ym::$(date '+%Y%m')
  157. echo ::set-output name=Y::$(date '+%Y')
  158. - name: Cache/Restore node_modules/.cache/hard-source
  159. uses: actions/cache@v2
  160. with:
  161. path: node_modules/.cache
  162. key: ${{ runner.OS }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  163. restore-keys: |
  164. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  165. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  166. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  167. - name: Get yarn cache dir
  168. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  169. id: cache-yarn
  170. run: echo "::set-output name=dir::$(yarn cache dir)"
  171. - name: Cache/Restore yarn cache
  172. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  173. uses: actions/cache@v2
  174. with:
  175. path: ${{ steps.cache-yarn.outputs.dir }}
  176. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  177. restore-keys: |
  178. ${{ runner.os }}-yarn-
  179. - name: Install dependencies
  180. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  181. run: |
  182. yarn add -W growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images@1.0.0 react-motion
  183. - name: Print dependencies
  184. run: |
  185. echo -n "node " && node -v
  186. echo -n "npm " && npm -v
  187. yarn list --depth=0
  188. - name: yarn build:dev
  189. run: |
  190. yarn build:dev
  191. - name: Slack Notification
  192. uses: weseek/ghaction-slack-notification@master
  193. if: failure()
  194. with:
  195. type: ${{ job.status }}
  196. job_name: '*Node CI for growi - build-dev (${{ matrix.node-version }})*'
  197. channel: '#ci'
  198. isCompactMode: true
  199. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  200. build-prod:
  201. runs-on: ubuntu-latest
  202. strategy:
  203. matrix:
  204. node-version: [12.x, 14.x]
  205. services:
  206. mongodb:
  207. image: mongo:4.4
  208. ports:
  209. - 27017/tcp
  210. mongodb36:
  211. image: mongo:3.6
  212. ports:
  213. - 27017/tcp
  214. steps:
  215. - uses: actions/checkout@v2
  216. - name: Use Node.js ${{ matrix.node-version }}
  217. uses: actions/setup-node@v1
  218. with:
  219. node-version: ${{ matrix.node-version }}
  220. - name: Get Date
  221. id: date
  222. run: |
  223. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  224. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  225. echo ::set-output name=Ym::$(date '+%Y%m')
  226. echo ::set-output name=Y::$(date '+%Y')
  227. - name: Cache/Restore node_modules
  228. uses: actions/cache@v2
  229. with:
  230. path: node_modules
  231. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  232. restore-keys: |
  233. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  234. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  235. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  236. - name: Get yarn cache dir
  237. id: cache-yarn
  238. run: echo "::set-output name=dir::$(yarn cache dir)"
  239. - name: Cache/Restore yarn cache
  240. uses: actions/cache@v2
  241. with:
  242. path: ${{ steps.cache-yarn.outputs.dir }}
  243. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  244. restore-keys: |
  245. ${{ runner.os }}-yarn-
  246. - name: Install dependencies
  247. run: |
  248. yarn add -W growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
  249. yarn add -W -D react-images@1.0.0 react-motion
  250. - name: Print dependencies
  251. run: |
  252. echo -n "node " && node -v
  253. echo -n "npm " && npm -v
  254. yarn list --depth=0
  255. - name: yarn build:prod:analyze
  256. run: |
  257. yarn build:prod:analyze
  258. - name: yarn install --production
  259. run: |
  260. yarn install --production
  261. - name: Print dependencies
  262. run: |
  263. echo -n "node " && node -v
  264. echo -n "npm " && npm -v
  265. yarn list --production --depth=0
  266. - name: Get DB name
  267. id: getdbname
  268. run: |
  269. echo ::set-output name=suffix::$(echo '${{ matrix.node-version }}' | sed s/\\.//)
  270. - name: yarn server:prod:ci
  271. run: |
  272. yarn server:prod:ci
  273. env:
  274. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  275. - name: yarn server:prod:ci with MongoDB 3.6
  276. run: |
  277. yarn server:prod:ci
  278. env:
  279. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  280. - name: Upload report as artifact
  281. uses: actions/upload-artifact@v2
  282. with:
  283. name: Report
  284. path: report
  285. - name: Slack Notification
  286. uses: weseek/ghaction-slack-notification@master
  287. if: failure()
  288. with:
  289. type: ${{ job.status }}
  290. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  291. channel: '#ci'
  292. isCompactMode: true
  293. url: ${{ secrets.SLACK_WEBHOOK_URL }}