ci.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
  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.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
  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. runs-on: ${{ matrix.os }}
  68. timeout-minutes: 20
  69. strategy:
  70. matrix:
  71. os:
  72. - ubuntu-latest
  73. - macos-latest
  74. - windows-latest
  75. steps:
  76. - name: Checkout code
  77. uses: actions/checkout@v4
  78. with:
  79. fetch-depth: 0
  80. - name: Setup Node
  81. uses: ./.github/actions/setup-node
  82. - name: Typecheck
  83. run: pnpm check:type
  84. # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions
  85. - name: Check workflow files
  86. if: runner.os == 'Linux'
  87. run: |
  88. bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
  89. ./actionlint -color -shellcheck=""
  90. ci-ok:
  91. name: CI OK
  92. runs-on: ubuntu-latest
  93. if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && always()
  94. needs: [test, check, lint]
  95. env:
  96. FAILURE: ${{ contains(join(needs.*.result, ','), 'failure') }}
  97. steps:
  98. - name: Check for failure
  99. run: |
  100. echo $FAILURE
  101. if [ "$FAILURE" = "false" ]; then
  102. exit 0
  103. else
  104. exit 1
  105. fi