ci.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: CI
  2. on:
  3. pull_request:
  4. push:
  5. branches:
  6. - main
  7. - 'releases/*'
  8. permissions:
  9. contents: read
  10. env:
  11. CI: true
  12. TZ: Asia/Shanghai
  13. jobs:
  14. test:
  15. name: Test
  16. if: github.repository == 'vbenjs/vue-vben-admin'
  17. runs-on: ${{ matrix.os }}
  18. strategy:
  19. matrix:
  20. os:
  21. - ubuntu-latest
  22. # - macos-latest
  23. - windows-latest
  24. timeout-minutes: 20
  25. steps:
  26. - name: Checkout code
  27. uses: actions/checkout@v4
  28. with:
  29. fetch-depth: 0
  30. - name: Install pnpm
  31. uses: pnpm/action-setup@v4
  32. with:
  33. run_install: false
  34. - name: Setup Node
  35. uses: ./.github/actions/setup-node
  36. # - name: Check Git version
  37. # run: git --version
  38. # - name: Setup mock Git user
  39. # run: git config --global user.email "you@example.com" && git config --global user.name "Your Name"
  40. - name: Vitest tests
  41. run: pnpm run test:unit
  42. # - name: Upload coverage
  43. # uses: codecov/codecov-action@v4
  44. # with:
  45. # token: ${{ secrets.CODECOV_TOKEN }}
  46. lint:
  47. name: Lint
  48. if: github.repository == 'vbenjs/vue-vben-admin'
  49. runs-on: ${{ matrix.os }}
  50. strategy:
  51. matrix:
  52. os:
  53. - ubuntu-latest
  54. # - macos-latest
  55. - windows-latest
  56. steps:
  57. - name: Checkout code
  58. uses: actions/checkout@v4
  59. with:
  60. fetch-depth: 0
  61. - name: Setup Node
  62. uses: ./.github/actions/setup-node
  63. - name: Lint
  64. run: pnpm run lint
  65. check:
  66. name: Check
  67. if: github.repository == 'vbenjs/vue-vben-admin'
  68. runs-on: ${{ matrix.os }}
  69. timeout-minutes: 20
  70. strategy:
  71. matrix:
  72. os:
  73. - ubuntu-latest
  74. # - macos-latest
  75. - windows-latest
  76. steps:
  77. - name: Checkout code
  78. uses: actions/checkout@v4
  79. with:
  80. fetch-depth: 0
  81. - name: Setup Node
  82. uses: ./.github/actions/setup-node
  83. - name: Typecheck
  84. run: pnpm check:type
  85. # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions
  86. - name: Check workflow files
  87. if: runner.os == 'Linux'
  88. run: |
  89. bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
  90. ./actionlint -color -shellcheck=""
  91. ci-ok:
  92. name: CI OK
  93. if: github.repository == 'vbenjs/vue-vben-admin'
  94. runs-on: ubuntu-latest
  95. needs: [test, check, lint]
  96. env:
  97. FAILURE: ${{ contains(join(needs.*.result, ','), 'failure') }}
  98. steps:
  99. - name: Check for failure
  100. run: |
  101. echo $FAILURE
  102. if [ "$FAILURE" = "false" ]; then
  103. exit 0
  104. else
  105. exit 1
  106. fi