ci.yml 11 KB

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