ci.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. name: Node CI for growi
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - rc/**
  7. - chore/**
  8. - support/prepare-v**
  9. pull_request:
  10. branches:
  11. - master
  12. types: [opened, reopened, synchronize]
  13. jobs:
  14. lint:
  15. runs-on: ubuntu-latest
  16. strategy:
  17. matrix:
  18. node-version: [14.x]
  19. steps:
  20. - uses: actions/checkout@v2
  21. - uses: actions/setup-node@v2
  22. with:
  23. node-version: ${{ matrix.node-version }}
  24. cache: 'yarn'
  25. cache-dependency-path: '**/yarn.lock'
  26. - name: Cache/Restore node_modules
  27. id: cache-dependencies
  28. uses: actions/cache@v2
  29. with:
  30. path: |
  31. **/node_modules
  32. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  33. restore-keys: |
  34. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  35. - name: lerna bootstrap
  36. run: |
  37. npx lerna bootstrap -- --frozen-lockfile
  38. - name: lerna run lint for plugins
  39. run: |
  40. yarn lerna run lint --scope @growi/plugin-*
  41. - name: lerna run lint for app
  42. run: |
  43. yarn lerna run lint --scope @growi/app --scope @growi/core --scope @growi/ui
  44. - name: Slack Notification
  45. uses: weseek/ghaction-slack-notification@master
  46. if: failure()
  47. with:
  48. type: ${{ job.status }}
  49. job_name: '*Node CI for growi - lint (${{ matrix.node-version }})*'
  50. channel: '#ci'
  51. isCompactMode: true
  52. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  53. test:
  54. runs-on: ubuntu-latest
  55. strategy:
  56. matrix:
  57. node-version: [14.x]
  58. services:
  59. mongodb:
  60. image: mongo:4.4
  61. ports:
  62. - 27017/tcp
  63. mongodb36:
  64. image: mongo:3.6
  65. ports:
  66. - 27017/tcp
  67. steps:
  68. - uses: actions/checkout@v2
  69. - uses: actions/setup-node@v2
  70. with:
  71. node-version: ${{ matrix.node-version }}
  72. cache: 'yarn'
  73. cache-dependency-path: '**/yarn.lock'
  74. - name: Cache/Restore node_modules
  75. id: cache-dependencies
  76. uses: actions/cache@v2
  77. with:
  78. path: |
  79. **/node_modules
  80. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  81. restore-keys: |
  82. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  83. - name: lerna bootstrap
  84. run: |
  85. npx lerna bootstrap -- --frozen-lockfile
  86. - name: yarn test
  87. working-directory: ./packages/app
  88. run: |
  89. yarn test
  90. env:
  91. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_test
  92. - name: yarn test with MongoDB 3.6
  93. working-directory: ./packages/app
  94. run: |
  95. yarn test
  96. env:
  97. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi_test
  98. - name: Upload coverage report as artifact
  99. uses: actions/upload-artifact@v2
  100. with:
  101. name: Coverage Report
  102. path: packages/app/coverage
  103. - name: Slack Notification
  104. uses: weseek/ghaction-slack-notification@master
  105. if: failure()
  106. with:
  107. type: ${{ job.status }}
  108. job_name: '*Node CI for growi - test (${{ matrix.node-version }})*'
  109. channel: '#ci'
  110. isCompactMode: true
  111. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  112. launch-dev:
  113. runs-on: ubuntu-latest
  114. strategy:
  115. matrix:
  116. node-version: [14.x]
  117. services:
  118. mongodb:
  119. image: mongo:4.4
  120. ports:
  121. - 27017/tcp
  122. steps:
  123. - uses: actions/checkout@v2
  124. - uses: actions/setup-node@v2
  125. with:
  126. node-version: ${{ matrix.node-version }}
  127. cache: 'yarn'
  128. cache-dependency-path: '**/yarn.lock'
  129. - name: Cache/Restore node_modules
  130. id: cache-dependencies
  131. uses: actions/cache@v2
  132. with:
  133. path: |
  134. **/node_modules
  135. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  136. restore-keys: |
  137. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  138. - name: lerna bootstrap
  139. run: |
  140. npx lerna bootstrap -- --frozen-lockfile
  141. - name: yarn dev:ci
  142. working-directory: ./packages/app
  143. run: |
  144. cp config/ci/.env.local.for-ci .env.development.local
  145. yarn dev:ci
  146. env:
  147. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_dev
  148. - name: Slack Notification
  149. uses: weseek/ghaction-slack-notification@master
  150. if: failure()
  151. with:
  152. type: ${{ job.status }}
  153. job_name: '*Node CI for growi - launch-dev (${{ matrix.node-version }})*'
  154. channel: '#ci'
  155. isCompactMode: true
  156. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  157. build-prod-node14:
  158. runs-on: ubuntu-latest
  159. strategy:
  160. matrix:
  161. node-version: [14.x]
  162. outputs:
  163. PROD_FILES: ${{ steps.archive-prod-files.outputs.file }}
  164. steps:
  165. - uses: actions/checkout@v2
  166. - uses: actions/setup-node@v2
  167. with:
  168. node-version: ${{ matrix.node-version }}
  169. cache: 'yarn'
  170. cache-dependency-path: '**/yarn.lock'
  171. - name: Cache/Restore node_modules
  172. id: cache-dependencies
  173. uses: actions/cache@v2
  174. with:
  175. path: |
  176. **/node_modules
  177. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  178. restore-keys: |
  179. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  180. - name: lerna bootstrap
  181. run: |
  182. npx lerna bootstrap -- --frozen-lockfile
  183. - name: Remove unnecessary packages
  184. run: |
  185. rm -rf packages/slackbot-proxy
  186. - name: Build
  187. run: |
  188. yarn lerna run build
  189. env:
  190. ANALYZE_BUNDLE_SIZE: 1
  191. - name: Archive production files
  192. id: archive-prod-files
  193. run: |
  194. tar -cf production.tar packages/**/dist packages/app/public
  195. echo ::set-output name=file::production.tar
  196. - name: Upload production files as artifact
  197. uses: actions/upload-artifact@v2
  198. with:
  199. name: Production Files
  200. path: ${{ steps.archive-prod-files.outputs.file }}
  201. - name: Upload report as artifact
  202. uses: actions/upload-artifact@v2
  203. with:
  204. name: Bundle Analyzing Report
  205. path: packages/app/report/bundle-analyzer.html
  206. - name: Slack Notification
  207. uses: weseek/ghaction-slack-notification@master
  208. if: failure()
  209. with:
  210. type: ${{ job.status }}
  211. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  212. channel: '#ci'
  213. isCompactMode: true
  214. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  215. launch-prod-node14:
  216. needs: [build-prod-node14]
  217. runs-on: ubuntu-latest
  218. strategy:
  219. matrix:
  220. node-version: [14.x]
  221. services:
  222. mongodb:
  223. image: mongo:4.4
  224. ports:
  225. - 27017/tcp
  226. mongodb36:
  227. image: mongo:3.6
  228. ports:
  229. - 27017/tcp
  230. steps:
  231. - uses: actions/checkout@v2
  232. - uses: actions/setup-node@v2
  233. with:
  234. node-version: ${{ matrix.node-version }}
  235. cache: 'yarn'
  236. cache-dependency-path: '**/yarn.lock'
  237. - name: Get Date
  238. id: get-date
  239. run: |
  240. echo "::set-output name=dateYmdHM::$(/bin/date -u "+%Y%m%d%H%M")"
  241. echo "::set-output name=dateYm::$(/bin/date -u "+%Y%m")"
  242. - name: Cache/Restore node_modules (not reused)
  243. id: cache-dependencies
  244. uses: actions/cache@v2
  245. with:
  246. path: |
  247. **/node_modules
  248. key: node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYmdHM }}
  249. restore-keys: |
  250. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  251. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  252. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYm }}
  253. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  254. - name: Remove unnecessary packages
  255. run: |
  256. rm -rf packages/slackbot-proxy
  257. - name: lerna bootstrap --production
  258. run: |
  259. npx lerna bootstrap -- --production
  260. - name: Download production files artifact
  261. uses: actions/download-artifact@v2
  262. with:
  263. name: Production Files
  264. - name: Extract procution files artifact
  265. run: |
  266. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  267. - name: yarn server:ci
  268. working-directory: ./packages/app
  269. run: |
  270. cp config/ci/.env.local.for-ci .env.production.local
  271. yarn server:ci
  272. env:
  273. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
  274. - name: yarn server:ci with MongoDB 3.6
  275. working-directory: ./packages/app
  276. run: |
  277. cp config/ci/.env.local.for-ci .env.production.local
  278. yarn server:ci
  279. env:
  280. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi
  281. - name: Slack Notification
  282. uses: weseek/ghaction-slack-notification@master
  283. if: failure()
  284. with:
  285. type: ${{ job.status }}
  286. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  287. channel: '#ci'
  288. isCompactMode: true
  289. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  290. run-cypress-node14:
  291. needs: [build-prod-node14]
  292. if: ${{ github.base_ref != null || github.ref_name == 'master' }}
  293. runs-on: ubuntu-latest
  294. container: cypress/base:14.18.1
  295. strategy:
  296. fail-fast: false
  297. matrix:
  298. node-version: [14.x]
  299. # List string expressions that is comma separated ids of tests in "test/cypress/integration"
  300. spec-group: ['1', '2']
  301. services:
  302. mongodb:
  303. image: mongo:4.4
  304. ports:
  305. - 27017/tcp
  306. steps:
  307. - uses: actions/checkout@v2
  308. - uses: actions/setup-node@v2
  309. with:
  310. node-version: ${{ matrix.node-version }}
  311. cache: 'yarn'
  312. cache-dependency-path: '**/yarn.lock'
  313. - name: Cache/Restore node_modules
  314. id: cache-dependencies
  315. uses: actions/cache@v2
  316. with:
  317. path: |
  318. **/node_modules
  319. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  320. restore-keys: |
  321. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  322. - name: Download production files artifact
  323. uses: actions/download-artifact@v2
  324. with:
  325. name: Production Files
  326. - name: Extract procution files artifact
  327. run: |
  328. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  329. # workaround by https://github.com/cypress-io/github-action/issues/407
  330. - name: Setup yarn cache settings
  331. run: yarn config set cache-folder ~/.cache/yarn
  332. - name: Determine spec expression
  333. id: determine-spec-exp
  334. run: |
  335. SPEC=`node bin/github-actions/generate-cypress-spec-arg.js --prefix="test/cypress/integration/" --suffix="-*/**" "${{ matrix.spec-group }}"`
  336. echo "::set-output name=value::$SPEC"
  337. - name: Cypress Run
  338. uses: cypress-io/github-action@v2
  339. with:
  340. working-directory: ./packages/app
  341. install-command: ${{ (steps.cache-dependencies.outputs.cache-hit == 'true' && 'yarn') || 'npx' }} lerna bootstrap
  342. spec: '${{ steps.determine-spec-exp.outputs.value }}'
  343. build: |
  344. cp config/ci/.env.local.for-ci .env.production.local
  345. start: yarn server
  346. wait-on: 'http://localhost:3000'
  347. env:
  348. MONGO_URI: mongodb://mongodb:27017/growi-vrt
  349. - name: Upload results
  350. uses: actions/upload-artifact@v2
  351. with:
  352. name: Cypress Report ${{ matrix.spec-group }}
  353. path: |
  354. packages/app/test/cypress/screenshots
  355. packages/app/test/cypress/videos
  356. - name: Slack Notification
  357. uses: weseek/ghaction-slack-notification@master
  358. if: failure()
  359. with:
  360. type: ${{ job.status }}
  361. job_name: '*Node CI for growi - run-cypress (${{ matrix.node-version }})*'
  362. channel: '#ci'
  363. isCompactMode: true
  364. url: ${{ secrets.SLACK_WEBHOOK_URL }}