ci-slackbot-proxy.yml 7.5 KB

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