ci.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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. build-prod-node14:
  154. runs-on: ubuntu-latest
  155. strategy:
  156. matrix:
  157. node-version: [14.x]
  158. outputs:
  159. PROD_FILES: ${{ steps.archive-prod-files.outputs.file }}
  160. steps:
  161. - uses: actions/checkout@v2
  162. - uses: actions/setup-node@v2
  163. with:
  164. node-version: ${{ matrix.node-version }}
  165. cache: 'yarn'
  166. cache-dependency-path: '**/yarn.lock'
  167. - name: Cache/Restore node_modules
  168. id: cache-dependencies
  169. uses: actions/cache@v2
  170. with:
  171. path: |
  172. **/node_modules
  173. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  174. restore-keys: |
  175. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  176. - name: lerna bootstrap
  177. run: |
  178. npx lerna bootstrap -- --frozen-lockfile
  179. - name: Remove unnecessary packages
  180. run: |
  181. rm -rf packages/slackbot-proxy
  182. - name: Build
  183. run: |
  184. yarn lerna run build
  185. env:
  186. ANALYZE_BUNDLE_SIZE: 1
  187. - name: Archive production files
  188. id: archive-prod-files
  189. run: |
  190. tar -cf production.tar packages/**/dist packages/app/public
  191. echo ::set-output name=file::production.tar
  192. - name: Upload production files as artifact
  193. uses: actions/upload-artifact@v2
  194. with:
  195. name: Production Files
  196. path: ${{ steps.archive-prod-files.outputs.file }}
  197. - name: Upload report as artifact
  198. uses: actions/upload-artifact@v2
  199. with:
  200. name: Bundle Analyzing Report
  201. path: packages/app/report/bundle-analyzer.html
  202. - name: Slack Notification
  203. uses: weseek/ghaction-slack-notification@master
  204. if: failure()
  205. with:
  206. type: ${{ job.status }}
  207. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  208. channel: '#ci'
  209. isCompactMode: true
  210. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  211. launch-prod-node14:
  212. needs: [build-prod-node14]
  213. runs-on: ubuntu-latest
  214. strategy:
  215. matrix:
  216. node-version: [14.x]
  217. services:
  218. mongodb:
  219. image: mongo:4.4
  220. ports:
  221. - 27017/tcp
  222. mongodb36:
  223. image: mongo:3.6
  224. ports:
  225. - 27017/tcp
  226. steps:
  227. - uses: actions/checkout@v2
  228. - uses: actions/setup-node@v2
  229. with:
  230. node-version: ${{ matrix.node-version }}
  231. cache: 'yarn'
  232. cache-dependency-path: '**/yarn.lock'
  233. - name: Get Date
  234. id: get-date
  235. run: |
  236. echo "::set-output name=dateYmdHM::$(/bin/date -u "+%Y%m%d%H%M")"
  237. echo "::set-output name=dateYm::$(/bin/date -u "+%Y%m")"
  238. - name: Cache/Restore node_modules (not reused)
  239. id: cache-dependencies
  240. uses: actions/cache@v2
  241. with:
  242. path: |
  243. **/node_modules
  244. key: node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYmdHM }}
  245. restore-keys: |
  246. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  247. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  248. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYm }}
  249. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  250. - name: Remove unnecessary packages
  251. run: |
  252. rm -rf packages/slackbot-proxy
  253. - name: lerna bootstrap --production
  254. run: |
  255. npx lerna bootstrap -- --production
  256. - name: Download production files artifact
  257. uses: actions/download-artifact@v2
  258. with:
  259. name: Production Files
  260. - name: Extract procution files artifact
  261. run: |
  262. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  263. - name: yarn server:ci
  264. working-directory: ./packages/app
  265. run: |
  266. cp config/ci/.env.local.for-ci .env.production.local
  267. yarn server:ci
  268. env:
  269. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
  270. - name: yarn server:ci with MongoDB 3.6
  271. working-directory: ./packages/app
  272. run: |
  273. cp config/ci/.env.local.for-ci .env.production.local
  274. yarn server:ci
  275. env:
  276. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi
  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 }}
  286. run-cypress-node14:
  287. needs: [build-prod-node14]
  288. runs-on: ubuntu-latest
  289. container: cypress/base:14.18.1
  290. strategy:
  291. fail-fast: false
  292. matrix:
  293. node-version: [14.x]
  294. # List string expressions that is comma separated ids of tests in "test/cypress/integration"
  295. spec-group: ['1', '2']
  296. services:
  297. mongodb:
  298. image: mongo:4.4
  299. ports:
  300. - 27017/tcp
  301. steps:
  302. - uses: actions/checkout@v2
  303. - uses: actions/setup-node@v2
  304. with:
  305. node-version: ${{ matrix.node-version }}
  306. cache: 'yarn'
  307. cache-dependency-path: '**/yarn.lock'
  308. - name: Cache/Restore node_modules
  309. id: cache-dependencies
  310. uses: actions/cache@v2
  311. with:
  312. path: |
  313. **/node_modules
  314. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  315. restore-keys: |
  316. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  317. - name: Download production files artifact
  318. uses: actions/download-artifact@v2
  319. with:
  320. name: Production Files
  321. - name: Extract procution files artifact
  322. run: |
  323. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  324. # workaround by https://github.com/cypress-io/github-action/issues/407
  325. - name: Setup yarn cache settings
  326. run: yarn config set cache-folder ~/.cache/yarn
  327. - name: Determine spec expression
  328. id: determine-spec-exp
  329. run: |
  330. SPEC=`node bin/github-actions/generate-cypress-spec-arg.js --prefix="test/cypress/integration/" --suffix="-*/**" "${{ matrix.spec-group }}"`
  331. echo "::set-output name=value::$SPEC"
  332. - name: Cypress Run
  333. uses: cypress-io/github-action@v2
  334. with:
  335. working-directory: ./packages/app
  336. install-command: ${{ (steps.cache-dependencies.outputs.cache-hit == 'true' && 'yarn') || 'npx' }} lerna bootstrap
  337. spec: '${{ steps.determine-spec-exp.outputs.value }}'
  338. build: |
  339. cp config/ci/.env.local.for-ci .env.production.local
  340. start: yarn server
  341. wait-on: 'http://localhost:3000'
  342. env:
  343. MONGO_URI: mongodb://mongodb:27017/growi-vrt
  344. - name: Upload results
  345. uses: actions/upload-artifact@v2
  346. with:
  347. name: Cypress Report ${{ matrix.spec-group }}
  348. path: |
  349. packages/app/test/cypress/screenshots
  350. packages/app/test/cypress/videos
  351. - name: Slack Notification
  352. uses: weseek/ghaction-slack-notification@master
  353. if: failure()
  354. with:
  355. type: ${{ job.status }}
  356. job_name: '*Node CI for growi - run-cypress (${{ matrix.node-version }})*'
  357. channel: '#ci'
  358. isCompactMode: true
  359. url: ${{ secrets.SLACK_WEBHOOK_URL }}