2
0

ci.yml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. mongodb36:
  201. image: mongo:3.6
  202. ports:
  203. - 27017/tcp
  204. steps:
  205. - uses: actions/checkout@v2
  206. - name: Use Node.js ${{ matrix.node-version }}
  207. uses: actions/setup-node@v1
  208. with:
  209. node-version: ${{ matrix.node-version }}
  210. - name: Get Date
  211. id: date
  212. run: |
  213. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  214. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  215. echo ::set-output name=Ym::$(date '+%Y%m')
  216. echo ::set-output name=Y::$(date '+%Y')
  217. - name: Cache/Restore node_modules
  218. uses: actions/cache@v2
  219. with:
  220. path: node_modules
  221. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  222. restore-keys: |
  223. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  224. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  225. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  226. - name: Get yarn cache dir
  227. id: cache-yarn
  228. run: echo "::set-output name=dir::$(yarn cache dir)"
  229. - name: Cache/Restore yarn cache
  230. uses: actions/cache@v2
  231. with:
  232. path: ${{ steps.cache-yarn.outputs.dir }}
  233. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  234. restore-keys: |
  235. ${{ runner.os }}-yarn-
  236. - name: Install dependencies
  237. run: |
  238. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
  239. yarn add -D react-images@1.0.0 react-motion
  240. - name: Print dependencies
  241. run: |
  242. echo -n "node " && node -v
  243. echo -n "npm " && npm -v
  244. yarn list --depth=0
  245. - name: yarn build:prod:analyze
  246. run: |
  247. yarn build:prod:analyze
  248. - name: yarn install --production
  249. run: |
  250. yarn install --production
  251. - name: Print dependencies
  252. run: |
  253. echo -n "node " && node -v
  254. echo -n "npm " && npm -v
  255. yarn list --production --depth=0
  256. - name: Get DB name
  257. id: getdbname
  258. run: |
  259. echo ::set-output name=suffix::$(echo '${{ matrix.node-version }}' | sed s/\\.//)
  260. - name: yarn server:prod:ci
  261. run: |
  262. yarn server:prod:ci
  263. env:
  264. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  265. - name: yarn server:prod:ci with MongoDB 3.6
  266. run: |
  267. yarn server:prod:ci
  268. env:
  269. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  270. - name: Upload report as artifact
  271. uses: actions/upload-artifact@v2
  272. with:
  273. name: Report
  274. path: report
  275. - name: Slack Notification
  276. uses: weseek/ghaction-slack-notification@master
  277. if: failure()
  278. with:
  279. type: ${{ job.status }}
  280. job_name: '*build-prod (${{ matrix.node-version }})*'
  281. channel: '#ci'
  282. isCompactMode: true
  283. url: ${{ secrets.SLACK_WEBHOOK_URL }}