ci-app-prod.yml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. name: Node CI for app production
  2. on:
  3. pull_request:
  4. types: [opened, reopened, synchronize]
  5. jobs:
  6. build-prod-node14:
  7. runs-on: ubuntu-latest
  8. strategy:
  9. matrix:
  10. node-version: [14.x]
  11. outputs:
  12. PROD_FILES: ${{ steps.archive-prod-files.outputs.file }}
  13. steps:
  14. - uses: actions/checkout@v2
  15. - uses: actions/setup-node@v2
  16. with:
  17. node-version: ${{ matrix.node-version }}
  18. cache: 'yarn'
  19. cache-dependency-path: '**/yarn.lock'
  20. - name: Cache/Restore node_modules
  21. id: cache-dependencies
  22. uses: actions/cache@v2
  23. with:
  24. path: |
  25. **/node_modules
  26. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  27. restore-keys: |
  28. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  29. - name: lerna bootstrap
  30. run: |
  31. npx lerna bootstrap -- --frozen-lockfile
  32. - name: Remove unnecessary packages
  33. run: |
  34. rm -rf packages/slackbot-proxy
  35. - name: Build
  36. run: |
  37. yarn lerna run build
  38. env:
  39. ANALYZE_BUNDLE_SIZE: 1
  40. - name: Archive production files
  41. id: archive-prod-files
  42. run: |
  43. tar -cf production.tar packages/**/dist packages/app/public
  44. echo ::set-output name=file::production.tar
  45. - name: Upload production files as artifact
  46. uses: actions/upload-artifact@v2
  47. with:
  48. name: Production Files
  49. path: ${{ steps.archive-prod-files.outputs.file }}
  50. - name: Upload report as artifact
  51. uses: actions/upload-artifact@v2
  52. with:
  53. name: Bundle Analyzing Report
  54. path: packages/app/report/bundle-analyzer.html
  55. - name: Slack Notification
  56. uses: weseek/ghaction-slack-notification@master
  57. if: failure()
  58. with:
  59. type: ${{ job.status }}
  60. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  61. channel: '#ci'
  62. isCompactMode: true
  63. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  64. launch-prod-node14:
  65. needs: [build-prod-node14]
  66. runs-on: ubuntu-latest
  67. strategy:
  68. matrix:
  69. node-version: [14.x]
  70. services:
  71. mongodb:
  72. image: mongo:4.4
  73. ports:
  74. - 27017/tcp
  75. mongodb36:
  76. image: mongo:3.6
  77. ports:
  78. - 27017/tcp
  79. steps:
  80. - uses: actions/checkout@v2
  81. - uses: actions/setup-node@v2
  82. with:
  83. node-version: ${{ matrix.node-version }}
  84. cache: 'yarn'
  85. cache-dependency-path: '**/yarn.lock'
  86. - name: Get Date
  87. id: get-date
  88. run: |
  89. echo "::set-output name=dateYmdHM::$(/bin/date -u "+%Y%m%d%H%M")"
  90. echo "::set-output name=dateYm::$(/bin/date -u "+%Y%m")"
  91. - name: Cache/Restore node_modules (not reused)
  92. id: cache-dependencies
  93. uses: actions/cache@v2
  94. with:
  95. path: |
  96. **/node_modules
  97. key: node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYmdHM }}
  98. restore-keys: |
  99. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  100. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  101. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ steps.get-date.outputs.dateYm }}
  102. node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  103. - name: Remove unnecessary packages
  104. run: |
  105. rm -rf packages/slackbot-proxy
  106. - name: lerna bootstrap --production
  107. run: |
  108. npx lerna bootstrap -- --production
  109. - name: Download production files artifact
  110. uses: actions/download-artifact@v2
  111. with:
  112. name: Production Files
  113. - name: Extract procution files artifact
  114. run: |
  115. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  116. - name: yarn server:ci
  117. working-directory: ./packages/app
  118. run: |
  119. cp config/ci/.env.local.for-ci .env.production.local
  120. yarn server:ci
  121. env:
  122. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
  123. - name: yarn server:ci with MongoDB 3.6
  124. working-directory: ./packages/app
  125. run: |
  126. cp config/ci/.env.local.for-ci .env.production.local
  127. yarn server:ci
  128. env:
  129. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi
  130. - name: Slack Notification
  131. uses: weseek/ghaction-slack-notification@master
  132. if: failure()
  133. with:
  134. type: ${{ job.status }}
  135. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  136. channel: '#ci'
  137. isCompactMode: true
  138. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  139. run-cypress-node14:
  140. needs: [build-prod-node14]
  141. runs-on: ubuntu-latest
  142. container: cypress/base:14.18.1
  143. strategy:
  144. fail-fast: false
  145. matrix:
  146. node-version: [14.x]
  147. # List string expressions that is comma separated ids of tests in "test/cypress/integration"
  148. spec-group: ['1', '2']
  149. services:
  150. mongodb:
  151. image: mongo:4.4
  152. ports:
  153. - 27017/tcp
  154. steps:
  155. - uses: actions/checkout@v2
  156. - uses: actions/setup-node@v2
  157. with:
  158. node-version: ${{ matrix.node-version }}
  159. cache: 'yarn'
  160. cache-dependency-path: '**/yarn.lock'
  161. # workaround by https://github.com/cypress-io/github-action/issues/407
  162. - name: Setup yarn cache settings
  163. run: yarn config set cache-folder ~/.cache/yarn
  164. - name: Cache/Restore node_modules
  165. uses: actions/cache@v2
  166. with:
  167. path: |
  168. **/node_modules
  169. ~/.cache/Cypress
  170. key: node_modules-and-cypress-bin-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  171. restore-keys: |
  172. node_modules-and-cypress-bin-${{ runner.OS }}-node${{ matrix.node-version }}
  173. - name: lerna bootstrap
  174. run: |
  175. npx lerna bootstrap -- --frozen-lockfile
  176. - name: Download production files artifact
  177. uses: actions/download-artifact@v2
  178. with:
  179. name: Production Files
  180. - name: Extract procution files artifact
  181. run: |
  182. tar -xf ${{ needs.build-prod-node14.outputs.PROD_FILES }}
  183. - name: Determine spec expression
  184. id: determine-spec-exp
  185. run: |
  186. SPEC=`node bin/github-actions/generate-cypress-spec-arg.js --prefix="test/cypress/integration/" --suffix="-*/**" "${{ matrix.spec-group }}"`
  187. echo "::set-output name=value::$SPEC"
  188. - name: Cypress Run
  189. uses: cypress-io/github-action@v2
  190. with:
  191. working-directory: ./packages/app
  192. install: false
  193. spec: '${{ steps.determine-spec-exp.outputs.value }}'
  194. build: |
  195. cp config/ci/.env.local.for-ci .env.production.local
  196. start: yarn server
  197. wait-on: 'http://localhost:3000'
  198. env:
  199. MONGO_URI: mongodb://mongodb:27017/growi-vrt
  200. - name: Upload results
  201. if: always()
  202. uses: actions/upload-artifact@v2
  203. with:
  204. name: Cypress Report
  205. path: |
  206. packages/app/test/cypress/screenshots
  207. packages/app/test/cypress/videos
  208. - name: Slack Notification
  209. uses: weseek/ghaction-slack-notification@master
  210. if: failure()
  211. with:
  212. type: ${{ job.status }}
  213. job_name: '*Node CI for growi - run-cypress (${{ matrix.node-version }})*'
  214. channel: '#ci'
  215. isCompactMode: true
  216. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  217. run-reg-suit:
  218. needs: [run-cypress-node14]
  219. if: always()
  220. # use secrets for "VRT" environment
  221. # https://github.com/weseek/growi/settings/environments/376165508/edit
  222. environment: VRT
  223. runs-on: ubuntu-latest
  224. strategy:
  225. matrix:
  226. node-version: [14.x]
  227. steps:
  228. - uses: actions/checkout@v2
  229. with:
  230. ref: ${{ github.head_ref }}
  231. fetch-depth: 0
  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: Cache/Restore node_modules
  238. uses: actions/cache@v2
  239. with:
  240. path: |
  241. **/node_modules
  242. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  243. restore-keys: |
  244. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  245. - name: lerna bootstrap
  246. run: |
  247. npx lerna bootstrap -- --frozen-lockfile
  248. - name: Download screenshots taken by cypress
  249. uses: actions/download-artifact@v2
  250. with:
  251. name: Cypress Report
  252. path: packages/app/test/cypress
  253. - name: Run reg-suit
  254. working-directory: ./packages/app
  255. run: |
  256. yarn reg:run
  257. env:
  258. REG_NOTIFY_GITHUB_PLUGIN_CLIENTID: ${{ secrets.REG_NOTIFY_GITHUB_PLUGIN_CLIENTID }}
  259. AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
  260. AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  261. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  262. - name: Slack Notification
  263. uses: weseek/ghaction-slack-notification@master
  264. if: failure()
  265. with:
  266. type: ${{ job.status }}
  267. job_name: '*Node CI for growi - run-reg-suit (${{ matrix.node-version }})*'
  268. channel: '#ci'
  269. isCompactMode: true
  270. url: ${{ secrets.SLACK_WEBHOOK_URL }}