ci.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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@v1
  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
  26. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  27. id: cache-yarn
  28. run: echo "::set-output name=dir::$(yarn cache dir)"
  29. - uses: actions/cache@v1
  30. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  31. with:
  32. path: ${{ steps.cache-yarn.outputs.dir }}
  33. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  34. restore-keys: |
  35. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  36. - name: Install dependencies
  37. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  38. run: |
  39. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  40. - name: Print dependencies
  41. run: |
  42. echo -n "node " && node -v
  43. echo -n "npm " && npm -v
  44. yarn list --depth=0
  45. - name: yarn lint
  46. run: |
  47. yarn lint
  48. - name: Slack Notification
  49. uses: homoluctus/slatify@master
  50. if: failure()
  51. with:
  52. type: ${{ job.status }}
  53. job_name: '*test (${{ matrix.node-version }})*'
  54. channel: '#ci'
  55. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  56. test:
  57. runs-on: ubuntu-latest
  58. strategy:
  59. matrix:
  60. node-version: [12.x]
  61. steps:
  62. - uses: actions/checkout@v1
  63. - name: Use Node.js ${{ matrix.node-version }}
  64. uses: actions/setup-node@v1
  65. with:
  66. node-version: ${{ matrix.node-version }}
  67. - name: Cache/Restore node_modules
  68. id: cache-dependencies
  69. uses: actions/cache@v1
  70. with:
  71. path: node_modules
  72. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  73. - name: Get yarn cache
  74. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  75. id: cache-yarn
  76. run: echo "::set-output name=dir::$(yarn cache dir)"
  77. - uses: actions/cache@v1
  78. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  79. with:
  80. path: ${{ steps.cache-yarn.outputs.dir }}
  81. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  82. restore-keys: |
  83. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  84. - name: Install dependencies
  85. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  86. run: |
  87. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  88. - name: Print dependencies
  89. run: |
  90. echo -n "node " && node -v
  91. echo -n "npm " && npm -v
  92. yarn list --depth=0
  93. - name: Launch MongoDB
  94. uses: wbari/start-mongoDB@v0.2
  95. with:
  96. mongoDBVersion: 3.6
  97. - name: yarn test
  98. run: |
  99. yarn test
  100. env:
  101. MONGO_URI: mongodb://localhost:27017/growi_test
  102. - name: Slack Notification
  103. uses: homoluctus/slatify@master
  104. if: failure()
  105. with:
  106. type: ${{ job.status }}
  107. job_name: '*test (${{ matrix.node-version }})*'
  108. channel: '#ci'
  109. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  110. build-dev:
  111. runs-on: ubuntu-latest
  112. strategy:
  113. matrix:
  114. node-version: [12.x]
  115. steps:
  116. - uses: actions/checkout@v1
  117. - name: Use Node.js ${{ matrix.node-version }}
  118. uses: actions/setup-node@v1
  119. with:
  120. node-version: ${{ matrix.node-version }}
  121. - name: Cache/Restore node_modules
  122. id: cache-dependencies
  123. uses: actions/cache@v1
  124. with:
  125. path: node_modules
  126. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  127. - name: Get yarn cache
  128. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  129. id: cache-yarn
  130. run: echo "::set-output name=dir::$(yarn cache dir)"
  131. - uses: actions/cache@v1
  132. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  133. with:
  134. path: ${{ steps.cache-yarn.outputs.dir }}
  135. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  136. restore-keys: |
  137. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  138. - name: Install dependencies
  139. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  140. run: |
  141. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  142. - name: Print dependencies
  143. run: |
  144. echo -n "node " && node -v
  145. echo -n "npm " && npm -v
  146. yarn list --depth=0
  147. - name: yarn build:dev
  148. run: |
  149. yarn build:dev
  150. - name: Slack Notification
  151. uses: homoluctus/slatify@master
  152. if: failure()
  153. with:
  154. type: ${{ job.status }}
  155. job_name: '*build-dev (${{ matrix.node-version }})*'
  156. channel: '#ci'
  157. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  158. build-prod:
  159. runs-on: ubuntu-latest
  160. strategy:
  161. matrix:
  162. node-version: [10.x, 12.x]
  163. steps:
  164. - uses: actions/checkout@v1
  165. - name: Use Node.js ${{ matrix.node-version }}
  166. uses: actions/setup-node@v1
  167. with:
  168. node-version: ${{ matrix.node-version }}
  169. - name: Get yarn cache
  170. id: cache-yarn
  171. run: echo "::set-output name=dir::$(yarn cache dir)"
  172. - uses: actions/cache@v1
  173. with:
  174. path: ${{ steps.cache-yarn.outputs.dir }}
  175. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  176. restore-keys: |
  177. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  178. - name: Install dependencies
  179. run: |
  180. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
  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: Store env vars for the key of cache-public
  187. run: |
  188. GIT_BRANCH=`echo $GITHUB_REF | sed 's/refs\/heads\///g'`
  189. GIT_BRANCH=`echo $GIT_BRANCH | sed 's/\//-/g'`
  190. TODAY=`date '+%Y%m%d'`
  191. echo ::set-env name=GIT_BRANCH::$GIT_BRANCH
  192. echo ::set-env name=TODAY::$TODAY
  193. - name: Cache/Restore public
  194. id: cache-public
  195. uses: actions/cache@v1
  196. with:
  197. path: public
  198. key: ${{ runner.OS }}-public-${{ matrix.node-version }}-${{ env.GIT_BRANCH }}-${{ env.TODAY }}
  199. restore-keys: |
  200. ${{ runner.OS }}-public-${{ matrix.node-version }}-${{ env.GIT_BRANCH }}-
  201. - name: yarn build:prod
  202. if: steps.cache-public.outputs.cache-hit != 'true'
  203. run: |
  204. yarn build:prod
  205. - name: yarn install --production
  206. run: |
  207. yarn install --production
  208. - name: Print dependencies
  209. run: |
  210. echo -n "node " && node -v
  211. echo -n "npm " && npm -v
  212. yarn list --depth=0
  213. - name: Launch MongoDB
  214. uses: wbari/start-mongoDB@v0.2
  215. with:
  216. mongoDBVersion: 3.6
  217. - name: yarn server:prod:ci
  218. run: |
  219. yarn server:prod:ci
  220. env:
  221. MONGO_URI: mongodb://localhost:27017/growi
  222. - name: Slack Notification
  223. uses: homoluctus/slatify@master
  224. if: failure()
  225. with:
  226. type: ${{ job.status }}
  227. job_name: '*build-prod (${{ matrix.node-version }})*'
  228. channel: '#ci'
  229. url: ${{ secrets.SLACK_WEBHOOK_URL }}