ci.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. name: Node CI for growi
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - rc/**
  7. - chore/**
  8. - support/prepare-v**
  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. - uses: actions/setup-node@v2
  18. with:
  19. node-version: ${{ matrix.node-version }}
  20. cache: 'yarn'
  21. cache-dependency-path: '**/yarn.lock'
  22. - name: Cache/Restore node_modules
  23. id: cache-dependencies
  24. uses: actions/cache@v2
  25. with:
  26. path: |
  27. **/node_modules
  28. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  29. restore-keys: |
  30. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  31. - name: lerna bootstrap
  32. run: |
  33. npx lerna bootstrap -- --frozen-lockfile
  34. - name: lerna run lint for plugins
  35. run: |
  36. yarn lerna run lint --scope @growi/plugin-*
  37. - name: lerna run lint for app
  38. run: |
  39. yarn lerna run lint --scope @growi/app --scope @growi/core --scope @growi/ui
  40. - name: Slack Notification
  41. uses: weseek/ghaction-slack-notification@master
  42. if: failure()
  43. with:
  44. type: ${{ job.status }}
  45. job_name: '*Node CI for growi - lint (${{ matrix.node-version }})*'
  46. channel: '#ci'
  47. isCompactMode: true
  48. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  49. test:
  50. runs-on: ubuntu-latest
  51. strategy:
  52. matrix:
  53. node-version: [14.x]
  54. services:
  55. mongodb:
  56. image: mongo:4.4
  57. ports:
  58. - 27017/tcp
  59. mongodb36:
  60. image: mongo:3.6
  61. ports:
  62. - 27017/tcp
  63. steps:
  64. - uses: actions/checkout@v2
  65. - uses: actions/setup-node@v2
  66. with:
  67. node-version: ${{ matrix.node-version }}
  68. cache: 'yarn'
  69. cache-dependency-path: '**/yarn.lock'
  70. - name: Cache/Restore node_modules
  71. id: cache-dependencies
  72. uses: actions/cache@v2
  73. with:
  74. path: |
  75. **/node_modules
  76. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  77. restore-keys: |
  78. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  79. - name: lerna bootstrap
  80. run: |
  81. npx lerna bootstrap -- --frozen-lockfile
  82. - name: yarn test
  83. working-directory: ./packages/app
  84. run: |
  85. yarn test
  86. env:
  87. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_test
  88. - name: yarn test with MongoDB 3.6
  89. working-directory: ./packages/app
  90. run: |
  91. yarn test
  92. env:
  93. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi_test
  94. - name: Upload coverage report as artifact
  95. uses: actions/upload-artifact@v2
  96. with:
  97. name: Coverage Report
  98. path: packages/app/coverage
  99. - name: Slack Notification
  100. uses: weseek/ghaction-slack-notification@master
  101. if: failure()
  102. with:
  103. type: ${{ job.status }}
  104. job_name: '*Node CI for growi - test (${{ matrix.node-version }})*'
  105. channel: '#ci'
  106. isCompactMode: true
  107. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  108. launch-dev:
  109. runs-on: ubuntu-latest
  110. strategy:
  111. matrix:
  112. node-version: [14.x]
  113. services:
  114. mongodb:
  115. image: mongo:4.4
  116. ports:
  117. - 27017/tcp
  118. steps:
  119. - uses: actions/checkout@v2
  120. - uses: actions/setup-node@v2
  121. with:
  122. node-version: ${{ matrix.node-version }}
  123. cache: 'yarn'
  124. cache-dependency-path: '**/yarn.lock'
  125. - name: Cache/Restore node_modules
  126. id: cache-dependencies
  127. uses: actions/cache@v2
  128. with:
  129. path: |
  130. **/node_modules
  131. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  132. restore-keys: |
  133. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  134. - name: lerna bootstrap
  135. run: |
  136. npx lerna bootstrap -- --frozen-lockfile
  137. - name: yarn dev:ci
  138. working-directory: ./packages/app
  139. run: |
  140. cp config/ci/.env.local.for-ci .env.development.local
  141. yarn dev:ci
  142. env:
  143. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_dev
  144. - name: Slack Notification
  145. uses: weseek/ghaction-slack-notification@master
  146. if: failure()
  147. with:
  148. type: ${{ job.status }}
  149. job_name: '*Node CI for growi - launch-dev (${{ matrix.node-version }})*'
  150. channel: '#ci'
  151. isCompactMode: true
  152. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  153. install-prod-node14:
  154. runs-on: ubuntu-latest
  155. strategy:
  156. matrix:
  157. node-version: [14.x]
  158. steps:
  159. - uses: actions/checkout@v2
  160. - uses: actions/setup-node@v2
  161. with:
  162. node-version: ${{ matrix.node-version }}
  163. cache: 'yarn'
  164. cache-dependency-path: '**/yarn.lock'
  165. - name: Cache/Restore node_modules
  166. id: cache-dependencies
  167. uses: actions/cache@v2
  168. with:
  169. path: |
  170. **/node_modules
  171. key: node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  172. restore-keys: |
  173. node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  174. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  175. - name: Remove unnecessary packages
  176. run: |
  177. rm -rf packages/slackbot-proxy
  178. - name: lerna bootstrap --production
  179. run: |
  180. npx lerna bootstrap -- --production
  181. - name: Print dependencies
  182. run: |
  183. echo -n "node " && node -v
  184. echo -n "npm " && npm -v
  185. yarn list --depth=0
  186. - name: Slack Notification
  187. uses: weseek/ghaction-slack-notification@master
  188. if: failure()
  189. with:
  190. type: ${{ job.status }}
  191. job_name: '*Node CI for growi - install-prod (${{ matrix.node-version }})*'
  192. channel: '#ci'
  193. isCompactMode: true
  194. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  195. launch-prod-node14:
  196. runs-on: ubuntu-latest
  197. strategy:
  198. matrix:
  199. node-version: [14.x]
  200. outputs:
  201. BUILT_PACKAGES: ${{ steps.archive-built-packages.outputs.file }}
  202. services:
  203. mongodb:
  204. image: mongo:4.4
  205. ports:
  206. - 27017/tcp
  207. mongodb36:
  208. image: mongo:3.6
  209. ports:
  210. - 27017/tcp
  211. steps:
  212. - uses: actions/checkout@v2
  213. - uses: actions/setup-node@v2
  214. with:
  215. node-version: ${{ matrix.node-version }}
  216. cache: 'yarn'
  217. cache-dependency-path: '**/yarn.lock'
  218. - name: Cache/Restore node_modules for build
  219. id: cache-dependencies
  220. uses: actions/cache@v2
  221. with:
  222. path: |
  223. **/node_modules
  224. key: node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  225. restore-keys: |
  226. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  227. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  228. - name: Remove unnecessary packages
  229. run: |
  230. rm -rf packages/slackbot-proxy
  231. - name: lerna bootstrap
  232. run: |
  233. npx lerna bootstrap -- --frozen-lockfile
  234. - name: Build
  235. run: |
  236. yarn lerna run build
  237. env:
  238. ANALYZE_BUNDLE_SIZE: 1
  239. - name: lerna bootstrap --production
  240. run: |
  241. npx lerna bootstrap -- --production
  242. - name: yarn server:ci
  243. working-directory: ./packages/app
  244. run: |
  245. cp config/ci/.env.local.for-ci .env.production.local
  246. yarn server:ci
  247. env:
  248. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
  249. - name: yarn server:ci with MongoDB 3.6
  250. working-directory: ./packages/app
  251. run: |
  252. cp config/ci/.env.local.for-ci .env.production.local
  253. yarn server:ci
  254. env:
  255. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi
  256. - name: Archive built package files
  257. id: archive-built-packages
  258. run: |
  259. tar -cf built-packages.tar packages/**/dist packages/app/public
  260. echo ::set-output name=file::built-packages.tar
  261. - name: Upload built packages as artifact
  262. uses: actions/upload-artifact@v2
  263. with:
  264. name: Built Packages
  265. path: ${{ steps.archive-built-packages.outputs.file }}
  266. - name: Upload report as artifact
  267. uses: actions/upload-artifact@v2
  268. with:
  269. name: Bundle Analyzing Report
  270. path: packages/app/report/bundle-analyzer.html
  271. - name: Slack Notification
  272. uses: weseek/ghaction-slack-notification@master
  273. if: failure()
  274. with:
  275. type: ${{ job.status }}
  276. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  277. channel: '#ci'
  278. isCompactMode: true
  279. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  280. run-cypress-node14:
  281. needs: [install-prod-node14, launch-prod-node14]
  282. runs-on: ubuntu-latest
  283. container: cypress/base:14.18.1
  284. strategy:
  285. fail-fast: false
  286. matrix:
  287. node-version: [14.x]
  288. containers: [1, 2]
  289. services:
  290. mongodb:
  291. image: mongo:4.4
  292. ports:
  293. - 27017/tcp
  294. steps:
  295. - uses: actions/checkout@v2
  296. - name: Cache/Restore node_modules
  297. id: cache-dependencies
  298. uses: actions/cache@v2
  299. with:
  300. path: |
  301. **/node_modules
  302. key: node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  303. restore-keys: |
  304. node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  305. - name: Remove unnecessary packages
  306. run: |
  307. rm -rf packages/slackbot-proxy
  308. - name: Download built artifact
  309. uses: actions/download-artifact@v2
  310. with:
  311. name: Built Packages
  312. - name: Extract built artifact
  313. run: |
  314. tar -xf ${{ needs.launch-prod-node14.outputs.BUILT_PACKAGES }}
  315. - name: yarn server:ci
  316. working-directory: ./packages/app
  317. run: |
  318. cp config/ci/.env.local.for-ci .env.production.local
  319. yarn server:ci
  320. env:
  321. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi-vrt
  322. - name: Slack Notification
  323. uses: weseek/ghaction-slack-notification@master
  324. if: failure()
  325. with:
  326. type: ${{ job.status }}
  327. job_name: '*Node CI for growi - run-cypress (${{ matrix.node-version }})*'
  328. channel: '#ci'
  329. isCompactMode: true
  330. url: ${{ secrets.SLACK_WEBHOOK_URL }}