ci.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. node-version: [20]
  21. os:
  22. - ubuntu-latest
  23. - macos-latest
  24. - windows-latest
  25. timeout-minutes: 20
  26. steps:
  27. - name: Checkout code
  28. uses: actions/checkout@v4
  29. with:
  30. fetch-depth: 0
  31. - name: Install pnpm
  32. uses: pnpm/action-setup@v4
  33. with:
  34. run_install: false
  35. - name: Use Node.js ${{ matrix.node-version }}
  36. uses: actions/setup-node@v4
  37. with:
  38. node-version: ${{ matrix.node-version }}
  39. cache: "pnpm"
  40. - name: Find pnpm store path
  41. shell: bash
  42. run: |
  43. echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
  44. - name: Setup pnpm cache
  45. uses: actions/cache@v4
  46. with:
  47. path: ${{ env.STORE_PATH }}
  48. key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
  49. restore-keys: |
  50. ${{ runner.os }}-pnpm-store-
  51. - name: Install dependencies
  52. run: pnpm install --frozen-lockfile
  53. # - name: Check Git version
  54. # run: git --version
  55. # - name: Setup mock Git user
  56. # run: git config --global user.email "you@example.com" && git config --global user.name "Your Name"
  57. - name: Vitest tests
  58. run: pnpm run test:unit
  59. # - name: Upload coverage
  60. # uses: codecov/codecov-action@v4
  61. # with:
  62. # token: ${{ secrets.CODECOV_TOKEN }}
  63. lint:
  64. name: Lint
  65. if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
  66. runs-on: ${{ matrix.os }}
  67. strategy:
  68. matrix:
  69. node-version: [20]
  70. os:
  71. - ubuntu-latest
  72. - macos-latest
  73. - windows-latest
  74. steps:
  75. - name: Checkout code
  76. uses: actions/checkout@v4
  77. with:
  78. fetch-depth: 0
  79. - name: Install pnpm
  80. uses: pnpm/action-setup@v4
  81. - name: Use Node.js ${{ matrix.node-version }}
  82. uses: actions/setup-node@v4
  83. with:
  84. node-version: ${{ matrix.node-version }}
  85. cache: "pnpm"
  86. - name: Install dependencies
  87. run: pnpm install --frozen-lockfile
  88. - name: Lint
  89. run: pnpm run lint
  90. check:
  91. name: Check
  92. runs-on: ${{ matrix.os }}
  93. timeout-minutes: 20
  94. strategy:
  95. matrix:
  96. node-version: [20]
  97. os:
  98. - ubuntu-latest
  99. - macos-latest
  100. - windows-latest
  101. steps:
  102. - name: Checkout code
  103. uses: actions/checkout@v4
  104. with:
  105. fetch-depth: 0
  106. - name: Install pnpm
  107. uses: pnpm/action-setup@v4
  108. - name: Use Node.js ${{ matrix.node-version }}
  109. uses: actions/setup-node@v4
  110. with:
  111. node-version: ${{ matrix.node-version }}
  112. cache: "pnpm"
  113. - name: Install dependencies
  114. run: pnpm install --frozen-lockfile
  115. - name: Typecheck
  116. run: pnpm check:type
  117. # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions
  118. - name: Check workflow files
  119. if: runner.os == 'Linux'
  120. run: |
  121. bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
  122. ./actionlint -color -shellcheck=""
  123. ci-ok:
  124. name: CI OK
  125. runs-on: ubuntu-latest
  126. if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && always()
  127. needs: [test, check, lint]
  128. env:
  129. FAILURE: ${{ contains(join(needs.*.result, ','), 'failure') }}
  130. steps:
  131. - name: Check for failure
  132. run: |
  133. echo $FAILURE
  134. if [ "$FAILURE" = "false" ]; then
  135. exit 0
  136. else
  137. exit 1
  138. fi