ci.yml 6.5 KB

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