ci: run lint, typecheck, format and unit tests on PRs and pushes

The existing build.yml only runs on v* tags and never invokes the test
suite, so pull requests get no automated checks. Add a lightweight CI
workflow that runs format:check, lint:check and typecheck once on Linux
and the unit tests on both Linux and Windows. Uses --ignore-scripts so it
does not download the mihomo cores, which the checks and tests do not need.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MOMO0302-02
2026-08-20 10:12:19 +08:00
committed by GitHub
parent c779799bee
commit 316c41c05b

68
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,68 @@
name: CI
on:
pull_request:
push:
branches:
- smart_core
- main
paths-ignore:
- 'README.md'
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/issues.yml'
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Lint, typecheck & format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
# --ignore-scripts skips the prepare step that downloads the mihomo cores;
# none of the static checks or unit tests need the sidecar binaries.
- name: Install dependencies
run: pnpm install --ignore-scripts
- name: Format check
run: pnpm run format:check
- name: Lint
run: pnpm run lint:check
- name: Typecheck
run: pnpm run typecheck
test:
name: Unit tests (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --ignore-scripts
- name: Test
run: pnpm test