2
0

ci.yml 10 KB

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