ci.yml 10 KB

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