ci.yml 9.6 KB

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