test.yml 3.6 KB

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