ci.yml 9.8 KB

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