ci.yml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. name: Node CI for growi
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - tmp/**
  7. paths:
  8. - .github/workflows/ci.yml
  9. - packages/app/**
  10. - .eslint*
  11. - .prettier*
  12. - .stylelint*
  13. - config/**
  14. - resource/**
  15. - src/**
  16. - package.json
  17. - yarn.lock
  18. jobs:
  19. lint:
  20. runs-on: ubuntu-latest
  21. strategy:
  22. matrix:
  23. node-version: [14.x]
  24. steps:
  25. - uses: actions/checkout@v2
  26. - name: Use Node.js ${{ matrix.node-version }}
  27. uses: actions/setup-node@v1
  28. with:
  29. node-version: ${{ matrix.node-version }}
  30. - name: Cache/Restore node_modules
  31. id: cache-dependencies
  32. uses: actions/cache@v2
  33. with:
  34. path: '**/node_modules'
  35. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  36. - name: Get yarn cache dir
  37. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  38. id: cache-yarn
  39. run: echo "::set-output name=dir::$(yarn cache dir)"
  40. - name: Cache/Restore yarn cache
  41. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  42. uses: actions/cache@v2
  43. with:
  44. path: ${{ steps.cache-yarn.outputs.dir }}
  45. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  46. restore-keys: |
  47. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  48. - name: Install dependencies
  49. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  50. run: |
  51. npx lerna bootstrap
  52. - name: Print dependencies
  53. run: |
  54. echo -n "node " && node -v
  55. echo -n "npm " && npm -v
  56. yarn list --depth=0
  57. - name: yarn lint
  58. run: |
  59. yarn lint
  60. - name: Slack Notification
  61. uses: weseek/ghaction-slack-notification@master
  62. if: failure()
  63. with:
  64. type: ${{ job.status }}
  65. job_name: '*Node CI for growi - lint (${{ matrix.node-version }})*'
  66. channel: '#ci'
  67. isCompactMode: true
  68. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  69. test:
  70. runs-on: ubuntu-latest
  71. strategy:
  72. matrix:
  73. node-version: [14.x]
  74. services:
  75. mongodb:
  76. image: mongo:4.4
  77. ports:
  78. - 27017/tcp
  79. mongodb36:
  80. image: mongo:3.6
  81. ports:
  82. - 27017/tcp
  83. steps:
  84. - uses: actions/checkout@v2
  85. - name: Use Node.js ${{ matrix.node-version }}
  86. uses: actions/setup-node@v1
  87. with:
  88. node-version: ${{ matrix.node-version }}
  89. - name: Cache/Restore node_modules
  90. id: cache-dependencies
  91. uses: actions/cache@v2
  92. with:
  93. path: '**/node_modules'
  94. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  95. - name: Get yarn cache dir
  96. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  97. id: cache-yarn
  98. run: echo "::set-output name=dir::$(yarn cache dir)"
  99. - name: Cache/Restore yarn cache
  100. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  101. uses: actions/cache@v2
  102. with:
  103. path: ${{ steps.cache-yarn.outputs.dir }}
  104. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  105. restore-keys: |
  106. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  107. - name: Install dependencies
  108. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  109. run: |
  110. npx lerna bootstrap
  111. - name: Print dependencies
  112. run: |
  113. echo -n "node " && node -v
  114. echo -n "npm " && npm -v
  115. yarn list --depth=0
  116. - name: yarn test
  117. run: |
  118. yarn test
  119. env:
  120. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_test
  121. - name: yarn test with MongoDB 3.6
  122. run: |
  123. yarn test
  124. env:
  125. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi_test
  126. - name: Slack Notification
  127. uses: weseek/ghaction-slack-notification@master
  128. if: failure()
  129. with:
  130. type: ${{ job.status }}
  131. job_name: '*Node CI for growi - test (${{ matrix.node-version }})*'
  132. channel: '#ci'
  133. isCompactMode: true
  134. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  135. build-dev:
  136. runs-on: ubuntu-latest
  137. strategy:
  138. matrix:
  139. node-version: [14.x]
  140. steps:
  141. - uses: actions/checkout@v2
  142. - name: Use Node.js ${{ matrix.node-version }}
  143. uses: actions/setup-node@v1
  144. with:
  145. node-version: ${{ matrix.node-version }}
  146. - name: Cache/Restore node_modules
  147. id: cache-dependencies
  148. uses: actions/cache@v2
  149. with:
  150. path: '**/node_modules'
  151. key: ${{ runner.OS }}-node_modules_dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  152. - name: Get Date
  153. id: date
  154. run: |
  155. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  156. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  157. echo ::set-output name=Ym::$(date '+%Y%m')
  158. echo ::set-output name=Y::$(date '+%Y')
  159. - name: Cache/Restore node_modules/.cache/hard-source
  160. uses: actions/cache@v2
  161. with:
  162. path: node_modules/.cache
  163. key: ${{ runner.OS }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  164. restore-keys: |
  165. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  166. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  167. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  168. - name: Get yarn cache dir
  169. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  170. id: cache-yarn
  171. run: echo "::set-output name=dir::$(yarn cache dir)"
  172. - name: Cache/Restore yarn cache
  173. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  174. uses: actions/cache@v2
  175. with:
  176. path: ${{ steps.cache-yarn.outputs.dir }}
  177. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  178. restore-keys: |
  179. ${{ runner.os }}-yarn-
  180. - name: Install dependencies
  181. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  182. run: |
  183. npx lerna bootstrap
  184. - name: Print dependencies
  185. run: |
  186. echo -n "node " && node -v
  187. echo -n "npm " && npm -v
  188. yarn list --depth=0
  189. - name: yarn build:dev
  190. run: |
  191. yarn build:dev
  192. - name: Slack Notification
  193. uses: weseek/ghaction-slack-notification@master
  194. if: failure()
  195. with:
  196. type: ${{ job.status }}
  197. job_name: '*Node CI for growi - build-dev (${{ matrix.node-version }})*'
  198. channel: '#ci'
  199. isCompactMode: true
  200. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  201. build-prod:
  202. runs-on: ubuntu-latest
  203. strategy:
  204. matrix:
  205. node-version: [12.x, 14.x]
  206. services:
  207. mongodb:
  208. image: mongo:4.4
  209. ports:
  210. - 27017/tcp
  211. mongodb36:
  212. image: mongo:3.6
  213. ports:
  214. - 27017/tcp
  215. steps:
  216. - uses: actions/checkout@v2
  217. - name: Use Node.js ${{ matrix.node-version }}
  218. uses: actions/setup-node@v1
  219. with:
  220. node-version: ${{ matrix.node-version }}
  221. - name: Get Date
  222. id: date
  223. run: |
  224. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  225. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  226. echo ::set-output name=Ym::$(date '+%Y%m')
  227. echo ::set-output name=Y::$(date '+%Y')
  228. - name: Cache/Restore node_modules
  229. uses: actions/cache@v2
  230. with:
  231. path: '**/node_modules'
  232. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  233. restore-keys: |
  234. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  235. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  236. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  237. - name: Get yarn cache dir
  238. id: cache-yarn
  239. run: echo "::set-output name=dir::$(yarn cache dir)"
  240. - name: Cache/Restore yarn cache
  241. uses: actions/cache@v2
  242. with:
  243. path: ${{ steps.cache-yarn.outputs.dir }}
  244. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  245. restore-keys: |
  246. ${{ runner.os }}-yarn-
  247. - name: Install dependencies
  248. run: |
  249. npx lerna bootstrap
  250. - name: Print dependencies
  251. run: |
  252. echo -n "node " && node -v
  253. echo -n "npm " && npm -v
  254. yarn list --depth=0
  255. - name: Build
  256. run: |
  257. yarn lerna run build --scope @growi/slack
  258. yarn lerna run build --scope @growi/app
  259. - name: lerna bootstrap --production
  260. run: |
  261. npx lerna bootstrap -- --production
  262. - name: Print dependencies
  263. run: |
  264. echo -n "node " && node -v
  265. echo -n "npm " && npm -v
  266. yarn list --production --depth=0
  267. - name: Get DB name
  268. id: getdbname
  269. run: |
  270. echo ::set-output name=suffix::$(echo '${{ matrix.node-version }}' | sed s/\\.//)
  271. - name: yarn server:prod:ci
  272. run: |
  273. yarn server:prod:ci
  274. env:
  275. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  276. - name: yarn server:prod:ci with MongoDB 3.6
  277. run: |
  278. yarn server:prod:ci
  279. env:
  280. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  281. - name: Upload report as artifact
  282. uses: actions/upload-artifact@v2
  283. with:
  284. name: Report
  285. path: report
  286. - name: Slack Notification
  287. uses: weseek/ghaction-slack-notification@master
  288. if: failure()
  289. with:
  290. type: ${{ job.status }}
  291. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  292. channel: '#ci'
  293. isCompactMode: true
  294. url: ${{ secrets.SLACK_WEBHOOK_URL }}