ci.yml 3.0 KB

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