ci.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. mkdir packages/app/dist
  189. touch packages/app/dist/dummy
  190. env:
  191. ANALYZE_BUNDLE_SIZE: 1
  192. - name: Archive production files
  193. id: archive-prod-files
  194. run: |
  195. tar -cf production.tar packages/**/dist packages/app/public
  196. echo ::set-output name=file::production.tar
  197. - name: Upload production files as artifact
  198. uses: actions/upload-artifact@v2
  199. with:
  200. name: Production Files
  201. path: ${{ steps.archive-prod-files.outputs.file }}
  202. - name: Upload report as artifact
  203. uses: actions/upload-artifact@v2
  204. with:
  205. name: Bundle Analyzing Report
  206. path: packages/app/report/bundle-analyzer.html
  207. - name: Slack Notification
  208. uses: weseek/ghaction-slack-notification@master
  209. if: failure()
  210. with:
  211. type: ${{ job.status }}
  212. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  213. channel: '#ci'
  214. isCompactMode: true
  215. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  216. launch-prod-node14:
  217. needs: [build-prod-node14]
  218. runs-on: ubuntu-latest
  219. if: ${{ false }}
  220. strategy:
  221. matrix:
  222. node-version: [14.x]
  223. services:
  224. mongodb:
  225. image: mongo:4.4
  226. ports:
  227. - 27017/tcp
  228. mongodb36:
  229. image: mongo:3.6
  230. ports:
  231. - 27017/tcp
  232. steps:
  233. - uses: actions/checkout@v2
  234. - uses: actions/setup-node@v2
  235. with:
  236. node-version: ${{ matrix.node-version }}
  237. cache: 'yarn'
  238. cache-dependency-path: '**/yarn.lock'
  239. - name: Get Date
  240. id: get-date
  241. run: |
  242. echo "::set-output name=dateYmdHM::$(/bin/date -u "+%Y%m%d%H%M")"
  243. echo "::set-output name=dateYm::$(/bin/date -u "+%Y%m")"
  244. - name: Cache/Restore node_modules for build
  245. id: cache-dependencies
  246. uses: actions/cache@v2
  247. with:
  248. path: |
  249. **/node_modules
  250. key: node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYmdHM }}
  251. restore-keys: |
  252. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  253. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  254. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYm }}
  255. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  256. - name: Remove unnecessary packages
  257. run: |
  258. rm -rf packages/slackbot-proxy
  259. - name: lerna bootstrap --production
  260. run: |
  261. npx lerna bootstrap -- --production
  262. - name: Download production files artifact
  263. uses: actions/download-artifact@v2
  264. with:
  265. name: Production Files
  266. - name: Extract procution files artifact
  267. run: |
  268. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  269. - name: yarn server:ci
  270. working-directory: ./packages/app
  271. run: |
  272. cp config/ci/.env.local.for-ci .env.production.local
  273. yarn server:ci
  274. env:
  275. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
  276. - name: yarn server:ci with MongoDB 3.6
  277. working-directory: ./packages/app
  278. run: |
  279. cp config/ci/.env.local.for-ci .env.production.local
  280. yarn server:ci
  281. env:
  282. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi
  283. - name: Slack Notification
  284. uses: weseek/ghaction-slack-notification@master
  285. if: failure()
  286. with:
  287. type: ${{ job.status }}
  288. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  289. channel: '#ci'
  290. isCompactMode: true
  291. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  292. run-cypress-node14:
  293. needs: [build-prod-node14]
  294. runs-on: ubuntu-latest
  295. container: cypress/base:14.18.1
  296. strategy:
  297. fail-fast: false
  298. matrix:
  299. node-version: [14.x]
  300. containers: [1]
  301. services:
  302. mongodb:
  303. image: mongo:4.4
  304. ports:
  305. - 27017/tcp
  306. steps:
  307. - uses: actions/checkout@v2
  308. - name: Download production files artifact
  309. uses: actions/download-artifact@v2
  310. with:
  311. name: Production Files
  312. - name: Extract procution files artifact
  313. run: |
  314. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  315. - name: Setup yarn cache settings
  316. run: yarn config set cache-folder ~/.cache/yarn
  317. - name: Cypress Run
  318. uses: cypress-io/github-action@v2
  319. with:
  320. working-directory: ./packages/app
  321. cache-key: node_modules-cypress-base-2-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  322. install-command: npx lerna bootstrap -- --frozen-lockfile
  323. runTests: false
  324. # build: |
  325. # cp config/ci/.env.local.for-ci .env.production.local
  326. # start: yarn server
  327. # wait-on: 'http://localhost:3000'
  328. env:
  329. MONGO_URI: mongodb://mongodb:27017/growi-vrt
  330. - name: Slack Notification
  331. uses: weseek/ghaction-slack-notification@master
  332. if: failure()
  333. with:
  334. type: ${{ job.status }}
  335. job_name: '*Node CI for growi - run-cypress (${{ matrix.node-version }})*'
  336. channel: '#ci'
  337. isCompactMode: true
  338. url: ${{ secrets.SLACK_WEBHOOK_URL }}