ci-slackbot-proxy.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. name: Node CI for slackbot-proxy
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - rc/**
  7. - tmp/**
  8. paths:
  9. - .github/workflows/ci-slackbot-proxy.yml
  10. - packages/slack/**
  11. - packages/slackbot-proxy/**
  12. - package.json
  13. - yarn.lock
  14. jobs:
  15. test:
  16. runs-on: ubuntu-latest
  17. strategy:
  18. matrix:
  19. node-version: [14.x]
  20. steps:
  21. - uses: actions/checkout@v2
  22. - name: Use Node.js ${{ matrix.node-version }}
  23. uses: actions/setup-node@v1
  24. with:
  25. node-version: ${{ matrix.node-version }}
  26. - name: Cache/Restore node_modules
  27. id: cache-dependencies
  28. uses: actions/cache@v2
  29. with:
  30. path: '**/node_modules'
  31. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  32. - name: Get yarn cache dir
  33. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  34. id: cache-yarn
  35. run: echo "::set-output name=dir::$(yarn cache dir)"
  36. - name: Cache/Restore yarn cache
  37. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  38. uses: actions/cache@v2
  39. with:
  40. path: ${{ steps.cache-yarn.outputs.dir }}
  41. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  42. restore-keys: |
  43. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  44. - name: Install dependencies
  45. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  46. run: |
  47. npx lerna bootstrap
  48. - name: Print dependencies
  49. run: |
  50. echo -n "node " && node -v
  51. echo -n "npm " && npm -v
  52. yarn list --depth=0
  53. - name: yarn test
  54. run: |
  55. yarn lerna run test
  56. - name: Slack Notification
  57. uses: weseek/ghaction-slack-notification@master
  58. if: failure()
  59. with:
  60. type: ${{ job.status }}
  61. job_name: '*Node CI for growi-bot-proxy - test (${{ matrix.node-version }})*'
  62. channel: '#ci'
  63. isCompactMode: true
  64. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  65. launch-dev:
  66. runs-on: ubuntu-latest
  67. strategy:
  68. matrix:
  69. node-version: [14.x]
  70. services:
  71. mysql:
  72. image: mysql:8.0
  73. ports:
  74. - 3306
  75. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  76. env:
  77. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  78. MYSQL_DATABASE: growi-slackbot-proxy
  79. steps:
  80. - uses: actions/checkout@v2
  81. - name: Use Node.js ${{ matrix.node-version }}
  82. uses: actions/setup-node@v1
  83. with:
  84. node-version: ${{ matrix.node-version }}
  85. - name: Cache/Restore node_modules
  86. id: cache-dependencies
  87. uses: actions/cache@v2
  88. with:
  89. path: '**/node_modules'
  90. key: ${{ runner.OS }}-node_modules_dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  91. - name: Get yarn cache dir
  92. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  93. id: cache-yarn
  94. run: echo "::set-output name=dir::$(yarn cache dir)"
  95. - name: Cache/Restore yarn cache
  96. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  97. uses: actions/cache@v2
  98. with:
  99. path: ${{ steps.cache-yarn.outputs.dir }}
  100. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  101. restore-keys: |
  102. ${{ runner.os }}-yarn-
  103. - name: lerna bootstrap
  104. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  105. run: |
  106. npx lerna bootstrap
  107. - name: Print dependencies
  108. run: |
  109. echo -n "node " && node -v
  110. echo -n "npm " && npm -v
  111. yarn list --depth=0
  112. - name: yarn dev:ci
  113. working-directory: ./packages/slackbot-proxy
  114. run: |
  115. cp config/ci/.env.local.for-ci .env.local
  116. yarn dev:ci
  117. env:
  118. TYPEORM_CONNECTION: mysql
  119. TYPEORM_HOST: localhost
  120. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  121. TYPEORM_DATABASE: growi-slackbot-proxy
  122. TYPEORM_USERNAME: root
  123. TYPEORM_PASSWORD:
  124. - name: Slack Notification
  125. uses: weseek/ghaction-slack-notification@master
  126. if: failure()
  127. with:
  128. type: ${{ job.status }}
  129. job_name: '*Node CI for growi-bot-proxy - launch-dev (${{ matrix.node-version }})*'
  130. channel: '#ci'
  131. isCompactMode: true
  132. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  133. launch-prod:
  134. runs-on: ubuntu-latest
  135. strategy:
  136. matrix:
  137. node-version: [14.x]
  138. services:
  139. mysql:
  140. image: mysql:8.0
  141. ports:
  142. - 3306
  143. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  144. env:
  145. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  146. MYSQL_DATABASE: growi-slackbot-proxy
  147. steps:
  148. - uses: actions/checkout@v2
  149. - name: Use Node.js ${{ matrix.node-version }}
  150. uses: actions/setup-node@v1
  151. with:
  152. node-version: ${{ matrix.node-version }}
  153. - name: Get Date
  154. id: date
  155. run: |
  156. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  157. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  158. echo ::set-output name=Ym::$(date '+%Y%m')
  159. echo ::set-output name=Y::$(date '+%Y')
  160. - name: Cache/Restore node_modules
  161. uses: actions/cache@v2
  162. with:
  163. path: '**/node_modules'
  164. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  165. restore-keys: |
  166. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  167. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  168. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  169. - name: Get yarn cache dir
  170. id: cache-yarn
  171. run: echo "::set-output name=dir::$(yarn cache dir)"
  172. - name: Cache/Restore yarn cache
  173. uses: actions/cache@v2
  174. with:
  175. path: ${{ steps.cache-yarn.outputs.dir }}
  176. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  177. restore-keys: |
  178. ${{ runner.os }}-yarn-
  179. - name: lerna bootstrap
  180. run: |
  181. npx lerna bootstrap
  182. - name: Print dependencies
  183. run: |
  184. echo -n "node " && node -v
  185. echo -n "npm " && npm -v
  186. yarn list --depth=0
  187. - name: lerna run build
  188. run: |
  189. yarn lerna run build
  190. - name: lerna bootstrap --production
  191. run: |
  192. npx lerna bootstrap -- --production
  193. - name: Print dependencies
  194. run: |
  195. echo -n "node " && node -v
  196. echo -n "npm " && npm -v
  197. yarn list --production --depth=0
  198. - name: yarn start:prod:ci
  199. working-directory: ./packages/slackbot-proxy
  200. run: |
  201. cp config/ci/.env.local.for-ci .env.local
  202. yarn start:prod:ci
  203. env:
  204. TYPEORM_CONNECTION: mysql
  205. TYPEORM_HOST: localhost
  206. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  207. TYPEORM_DATABASE: growi-slackbot-proxy
  208. TYPEORM_USERNAME: root
  209. TYPEORM_PASSWORD:
  210. - name: Upload report as artifact
  211. uses: actions/upload-artifact@v2
  212. with:
  213. name: Report
  214. path: report
  215. - name: Slack Notification
  216. uses: weseek/ghaction-slack-notification@master
  217. if: failure()
  218. with:
  219. type: ${{ job.status }}
  220. job_name: '*Node CI for growi-bot-proxy - launch-prod (${{ matrix.node-version }})*'
  221. channel: '#ci'
  222. isCompactMode: true
  223. url: ${{ secrets.SLACK_WEBHOOK_URL }}