ci.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. if: ${{ false }}
  13. strategy:
  14. matrix:
  15. node-version: [14.x]
  16. steps:
  17. - uses: actions/checkout@v2
  18. - uses: actions/setup-node@v2
  19. with:
  20. node-version: ${{ matrix.node-version }}
  21. cache: 'yarn'
  22. cache-dependency-path: '**/yarn.lock'
  23. - name: Cache/Restore node_modules
  24. id: cache-dependencies
  25. uses: actions/cache@v2
  26. with:
  27. path: |
  28. **/node_modules
  29. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  30. restore-keys: |
  31. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  32. - name: lerna bootstrap
  33. run: |
  34. npx lerna bootstrap -- --frozen-lockfile
  35. - name: lerna run lint for plugins
  36. run: |
  37. yarn lerna run lint --scope @growi/plugin-*
  38. - name: lerna run lint for app
  39. run: |
  40. yarn lerna run lint --scope @growi/app --scope @growi/core --scope @growi/ui
  41. - name: Slack Notification
  42. uses: weseek/ghaction-slack-notification@master
  43. if: failure()
  44. with:
  45. type: ${{ job.status }}
  46. job_name: '*Node CI for growi - lint (${{ matrix.node-version }})*'
  47. channel: '#ci'
  48. isCompactMode: true
  49. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  50. test:
  51. runs-on: ubuntu-latest
  52. if: ${{ false }}
  53. strategy:
  54. matrix:
  55. node-version: [14.x]
  56. services:
  57. mongodb:
  58. image: mongo:4.4
  59. ports:
  60. - 27017/tcp
  61. mongodb36:
  62. image: mongo:3.6
  63. ports:
  64. - 27017/tcp
  65. steps:
  66. - uses: actions/checkout@v2
  67. - uses: actions/setup-node@v2
  68. with:
  69. node-version: ${{ matrix.node-version }}
  70. cache: 'yarn'
  71. cache-dependency-path: '**/yarn.lock'
  72. - name: Cache/Restore node_modules
  73. id: cache-dependencies
  74. uses: actions/cache@v2
  75. with:
  76. path: |
  77. **/node_modules
  78. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  79. restore-keys: |
  80. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  81. - name: lerna bootstrap
  82. run: |
  83. npx lerna bootstrap -- --frozen-lockfile
  84. - name: yarn test
  85. working-directory: ./packages/app
  86. run: |
  87. yarn test
  88. env:
  89. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_test
  90. - name: yarn test with MongoDB 3.6
  91. working-directory: ./packages/app
  92. run: |
  93. yarn test
  94. env:
  95. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi_test
  96. - name: Upload coverage report as artifact
  97. uses: actions/upload-artifact@v2
  98. with:
  99. name: Coverage Report
  100. path: packages/app/coverage
  101. - name: Slack Notification
  102. uses: weseek/ghaction-slack-notification@master
  103. if: failure()
  104. with:
  105. type: ${{ job.status }}
  106. job_name: '*Node CI for growi - test (${{ matrix.node-version }})*'
  107. channel: '#ci'
  108. isCompactMode: true
  109. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  110. launch-dev:
  111. runs-on: ubuntu-latest
  112. if: ${{ false }}
  113. strategy:
  114. matrix:
  115. node-version: [14.x]
  116. services:
  117. mongodb:
  118. image: mongo:4.4
  119. ports:
  120. - 27017/tcp
  121. steps:
  122. - uses: actions/checkout@v2
  123. - uses: actions/setup-node@v2
  124. with:
  125. node-version: ${{ matrix.node-version }}
  126. cache: 'yarn'
  127. cache-dependency-path: '**/yarn.lock'
  128. - name: Cache/Restore node_modules
  129. id: cache-dependencies
  130. uses: actions/cache@v2
  131. with:
  132. path: |
  133. **/node_modules
  134. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  135. restore-keys: |
  136. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  137. - name: lerna bootstrap
  138. run: |
  139. npx lerna bootstrap -- --frozen-lockfile
  140. - name: yarn dev:ci
  141. working-directory: ./packages/app
  142. run: |
  143. cp config/ci/.env.local.for-ci .env.development.local
  144. yarn dev:ci
  145. env:
  146. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_dev
  147. - name: Slack Notification
  148. uses: weseek/ghaction-slack-notification@master
  149. if: failure()
  150. with:
  151. type: ${{ job.status }}
  152. job_name: '*Node CI for growi - launch-dev (${{ matrix.node-version }})*'
  153. channel: '#ci'
  154. isCompactMode: true
  155. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  156. build-prod-node14:
  157. runs-on: ubuntu-latest
  158. strategy:
  159. matrix:
  160. node-version: [14.x]
  161. outputs:
  162. PROD_FILES: ${{ steps.archive-prod-files.outputs.file }}
  163. steps:
  164. - uses: actions/checkout@v2
  165. - uses: actions/setup-node@v2
  166. with:
  167. node-version: ${{ matrix.node-version }}
  168. cache: 'yarn'
  169. cache-dependency-path: '**/yarn.lock'
  170. - name: Cache/Restore node_modules
  171. id: cache-dependencies
  172. uses: actions/cache@v2
  173. with:
  174. path: |
  175. **/node_modules
  176. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  177. restore-keys: |
  178. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  179. - name: lerna bootstrap
  180. run: |
  181. npx lerna bootstrap -- --frozen-lockfile
  182. - name: Remove unnecessary packages
  183. run: |
  184. rm -rf packages/slackbot-proxy
  185. - name: Build
  186. run: |
  187. yarn lerna run build
  188. env:
  189. ANALYZE_BUNDLE_SIZE: 1
  190. - name: Archive production files
  191. id: archive-prod-files
  192. run: |
  193. tar -cf production.tar packages/**/dist packages/app/public
  194. echo ::set-output name=file::production.tar
  195. - name: Upload production files as artifact
  196. uses: actions/upload-artifact@v2
  197. with:
  198. name: Production Files
  199. path: ${{ steps.archive-prod-files.outputs.file }}
  200. - name: Upload report as artifact
  201. uses: actions/upload-artifact@v2
  202. with:
  203. name: Bundle Analyzing Report
  204. path: packages/app/report/bundle-analyzer.html
  205. - name: Slack Notification
  206. uses: weseek/ghaction-slack-notification@master
  207. if: failure()
  208. with:
  209. type: ${{ job.status }}
  210. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  211. channel: '#ci'
  212. isCompactMode: true
  213. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  214. launch-prod-node14:
  215. needs: [build-prod-node14]
  216. runs-on: ubuntu-latest
  217. if: ${{ false }}
  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 for build
  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. runs-on: ubuntu-latest
  293. container: cypress/base:14.18.1
  294. strategy:
  295. fail-fast: false
  296. matrix:
  297. node-version: [14.x]
  298. containers: [1]
  299. services:
  300. mongodb:
  301. image: mongo:4.4
  302. ports:
  303. - 27017/tcp
  304. steps:
  305. - uses: actions/checkout@v2
  306. - name: Cache/Restore node_modules
  307. id: cache-dependencies
  308. uses: actions/cache@v2
  309. with:
  310. path: |
  311. **/node_modules
  312. key: node_modules-cypress-base-3-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  313. restore-keys: |
  314. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  315. - name: Download production files artifact
  316. uses: actions/download-artifact@v2
  317. with:
  318. name: Production Files
  319. - name: Extract procution files artifact
  320. run: |
  321. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  322. # workaround by https://github.com/cypress-io/github-action/issues/407
  323. - name: Setup yarn cache settings
  324. run: yarn config set cache-folder ~/.cache/yarn
  325. - name: Cypress Run
  326. uses: cypress-io/github-action@v2
  327. with:
  328. working-directory: ./packages/app
  329. install-command: npx lerna bootstrap -- --frozen-lockfile
  330. build: |
  331. cp config/ci/.env.local.for-ci .env.production.local
  332. start: yarn server
  333. wait-on: 'http://localhost:3000'
  334. env:
  335. MONGO_URI: mongodb://mongodb:27017/growi-vrt
  336. DEBUG: '@cypress/github-action'
  337. - name: Slack Notification
  338. uses: weseek/ghaction-slack-notification@master
  339. if: failure()
  340. with:
  341. type: ${{ job.status }}
  342. job_name: '*Node CI for growi - run-cypress (${{ matrix.node-version }})*'
  343. channel: '#ci'
  344. isCompactMode: true
  345. url: ${{ secrets.SLACK_WEBHOOK_URL }}