ci.yml 10.0 KB

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