ci.yml 9.8 KB

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