ci.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. name: Node CI
  2. on: [push]
  3. jobs:
  4. resolve-dependencies:
  5. runs-on: ubuntu-latest
  6. strategy:
  7. matrix:
  8. node-version: [10.x, 12.x]
  9. steps:
  10. - uses: actions/checkout@v1
  11. - name: Use Node.js ${{ matrix.node-version }}
  12. uses: actions/setup-node@v1
  13. with:
  14. node-version: ${{ matrix.node-version }}
  15. - name: Cache/Restore node_modules
  16. id: cache
  17. uses: actions/cache@v1
  18. with:
  19. path: node_modules
  20. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  21. - name: install dependencies
  22. if: steps.cache.outputs.cache-hit != 'true'
  23. run: |
  24. yarn
  25. - name: install plugins
  26. if: steps.cache.outputs.cache-hit != 'true'
  27. run: |
  28. yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
  29. yarn add -D react-images react-motion
  30. - name: print dependencies
  31. run: |
  32. echo -n "node " && node -v
  33. echo -n "npm " && npm -v
  34. yarn list --depth=0
  35. test:
  36. runs-on: ubuntu-latest
  37. needs: resolve-dependencies
  38. strategy:
  39. matrix:
  40. node-version: [10.x, 12.x]
  41. steps:
  42. - uses: actions/checkout@v1
  43. - name: Use Node.js ${{ matrix.node-version }}
  44. uses: actions/setup-node@v1
  45. with:
  46. node-version: ${{ matrix.node-version }}
  47. - name: Cache/Restore node_modules
  48. uses: actions/cache@v1
  49. with:
  50. path: node_modules
  51. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  52. - uses: actions/checkout@v1
  53. - name: yarn lint
  54. run: |
  55. yarn lint
  56. - name: Launch MongoDB
  57. uses: wbari/start-mongoDB@v0.2
  58. with:
  59. mongoDBVersion: 3.6
  60. - name: yarn test
  61. run: |
  62. yarn test
  63. env:
  64. MONGO_URI: mongodb://localhost:27017/growi_test
  65. build-dev:
  66. runs-on: ubuntu-latest
  67. needs: resolve-dependencies
  68. strategy:
  69. matrix:
  70. node-version: [10.x, 12.x]
  71. steps:
  72. - uses: actions/checkout@v1
  73. - name: Use Node.js ${{ matrix.node-version }}
  74. uses: actions/setup-node@v1
  75. with:
  76. node-version: ${{ matrix.node-version }}
  77. - name: Cache/Restore node_modules
  78. uses: actions/cache@v1
  79. with:
  80. path: node_modules
  81. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  82. - name: yarn build:dev
  83. run: |
  84. yarn build:dev
  85. build-prod:
  86. runs-on: ubuntu-latest
  87. needs: resolve-dependencies
  88. strategy:
  89. matrix:
  90. node-version: [10.x, 12.x]
  91. steps:
  92. - uses: actions/checkout@v1
  93. - name: Use Node.js ${{ matrix.node-version }}
  94. uses: actions/setup-node@v1
  95. with:
  96. node-version: ${{ matrix.node-version }}
  97. - name: Cache/Restore node_modules
  98. uses: actions/cache@v1
  99. with:
  100. path: node_modules
  101. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-build-prod
  102. restore-keys: |
  103. ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  104. ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-build-prod
  105. - name: Launch MongoDB
  106. uses: wbari/start-mongoDB@v0.2
  107. with:
  108. mongoDBVersion: 3.6
  109. - name: yarn build:prod:analyze
  110. run: |
  111. yarn build:prod:analyze
  112. - name: shrink dependencies for production
  113. run: |
  114. yarn install --production
  115. - name: yarn server:prod:ci
  116. run: |
  117. yarn server:prod:ci
  118. env:
  119. MONGO_URI: mongodb://localhost:27017/growi