2
0

ci.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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: lerna run lint for plugins
  48. run: |
  49. yarn lerna run lint --scope @growi/plugin-*
  50. - name: lerna run lint for app
  51. run: |
  52. yarn lerna run lint --scope @growi/app --scope @growi/core --scope @growi/ui
  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 - lint (${{ matrix.node-version }})*'
  59. channel: '#ci'
  60. isCompactMode: true
  61. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  62. test:
  63. runs-on: ubuntu-latest
  64. strategy:
  65. matrix:
  66. node-version: [14.x]
  67. services:
  68. mongodb:
  69. image: mongo:4.4
  70. ports:
  71. - 27017/tcp
  72. mongodb36:
  73. image: mongo:3.6
  74. ports:
  75. - 27017/tcp
  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-${{ 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-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  98. restore-keys: |
  99. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  100. - name: Install dependencies
  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 test
  110. working-directory: ./packages/app
  111. run: |
  112. yarn test
  113. env:
  114. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_test
  115. - name: yarn test with MongoDB 3.6
  116. working-directory: ./packages/app
  117. run: |
  118. yarn test
  119. env:
  120. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi_test
  121. - name: Upload coverage report as artifact
  122. uses: actions/upload-artifact@v2
  123. with:
  124. name: Coverage Report
  125. path: packages/app/coverage
  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. launch-dev:
  136. runs-on: ubuntu-latest
  137. strategy:
  138. matrix:
  139. node-version: [14.x]
  140. services:
  141. mongodb:
  142. image: mongo:4.4
  143. ports:
  144. - 27017/tcp
  145. steps:
  146. - uses: actions/checkout@v2
  147. - name: Use Node.js ${{ matrix.node-version }}
  148. uses: actions/setup-node@v1
  149. with:
  150. node-version: ${{ matrix.node-version }}
  151. - name: Cache/Restore node_modules
  152. id: cache-dependencies
  153. uses: actions/cache@v2
  154. with:
  155. path: '**/node_modules'
  156. key: ${{ runner.OS }}-node_modules_dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  157. - name: Get Date
  158. id: date
  159. run: |
  160. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  161. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  162. echo ::set-output name=Ym::$(date '+%Y%m')
  163. echo ::set-output name=Y::$(date '+%Y')
  164. - name: Cache/Restore node_modules/.cache/hard-source
  165. uses: actions/cache@v2
  166. with:
  167. path: node_modules/.cache
  168. key: ${{ runner.OS }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  169. restore-keys: |
  170. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  171. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  172. ${{ runner.os }}-hard_source_webpack-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  173. - name: Get yarn cache dir
  174. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  175. id: cache-yarn
  176. run: echo "::set-output name=dir::$(yarn cache dir)"
  177. - name: Cache/Restore yarn cache
  178. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  179. uses: actions/cache@v2
  180. with:
  181. path: ${{ steps.cache-yarn.outputs.dir }}
  182. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  183. restore-keys: |
  184. ${{ runner.os }}-yarn-
  185. - name: Install dependencies
  186. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  187. run: |
  188. npx lerna bootstrap
  189. - name: Print dependencies
  190. run: |
  191. echo -n "node " && node -v
  192. echo -n "npm " && npm -v
  193. yarn list --depth=0
  194. - name: yarn dev:ci
  195. working-directory: ./packages/app
  196. run: |
  197. cp config/ci/.env.local.for-ci .env.development.local
  198. yarn dev:ci
  199. env:
  200. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_dev
  201. - name: Slack Notification
  202. uses: weseek/ghaction-slack-notification@master
  203. if: failure()
  204. with:
  205. type: ${{ job.status }}
  206. job_name: '*Node CI for growi - build-dev (${{ matrix.node-version }})*'
  207. channel: '#ci'
  208. isCompactMode: true
  209. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  210. launch-prod:
  211. runs-on: ubuntu-latest
  212. strategy:
  213. matrix:
  214. node-version: [12.x, 14.x]
  215. services:
  216. mongodb:
  217. image: mongo:4.4
  218. ports:
  219. - 27017/tcp
  220. mongodb36:
  221. image: mongo:3.6
  222. ports:
  223. - 27017/tcp
  224. steps:
  225. - uses: actions/checkout@v2
  226. - name: Use Node.js ${{ matrix.node-version }}
  227. uses: actions/setup-node@v1
  228. with:
  229. node-version: ${{ matrix.node-version }}
  230. - name: Get Date
  231. id: date
  232. run: |
  233. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  234. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  235. echo ::set-output name=Ym::$(date '+%Y%m')
  236. echo ::set-output name=Y::$(date '+%Y')
  237. - name: Cache/Restore node_modules
  238. uses: actions/cache@v2
  239. with:
  240. path: '**/node_modules'
  241. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  242. restore-keys: |
  243. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  244. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  245. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  246. - name: Get yarn cache dir
  247. id: cache-yarn
  248. run: echo "::set-output name=dir::$(yarn cache dir)"
  249. - name: Cache/Restore yarn cache
  250. uses: actions/cache@v2
  251. with:
  252. path: ${{ steps.cache-yarn.outputs.dir }}
  253. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  254. restore-keys: |
  255. ${{ runner.os }}-yarn-
  256. - name: Install dependencies
  257. run: |
  258. npx lerna bootstrap
  259. - name: Print dependencies
  260. run: |
  261. echo -n "node " && node -v
  262. echo -n "npm " && npm -v
  263. yarn list --depth=0
  264. - name: Build
  265. run: |
  266. yarn lerna run build --scope @growi/core --scope @growi/slack --scope @growi/plugin-* --scope @growi/app
  267. - name: lerna bootstrap --production
  268. run: |
  269. npx lerna bootstrap -- --production
  270. - name: Print dependencies
  271. run: |
  272. echo -n "node " && node -v
  273. echo -n "npm " && npm -v
  274. yarn list --production --depth=0
  275. - name: Get DB name
  276. id: getdbname
  277. run: |
  278. echo ::set-output name=suffix::$(echo '${{ matrix.node-version }}' | sed s/\\.//)
  279. - name: yarn server:ci
  280. working-directory: ./packages/app
  281. run: |
  282. cp config/ci/.env.local.for-ci .env.production.local
  283. yarn server:ci
  284. env:
  285. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  286. - name: yarn server:ci with MongoDB 3.6
  287. working-directory: ./packages/app
  288. run: |
  289. cp config/ci/.env.local.for-ci .env.production.local
  290. yarn server:ci
  291. env:
  292. MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi-${{ steps.getdbname.outputs.suffix }}
  293. - name: Slack Notification
  294. uses: weseek/ghaction-slack-notification@master
  295. if: failure()
  296. with:
  297. type: ${{ job.status }}
  298. job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
  299. channel: '#ci'
  300. isCompactMode: true
  301. url: ${{ secrets.SLACK_WEBHOOK_URL }}