ci.yml 9.4 KB

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