ci.yml 10 KB

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