mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-07 06:07:18 +08:00
100 lines
2.7 KiB
YAML
100 lines
2.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
frontend:
|
|
name: Frontend Checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "20"
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v5
|
|
with:
|
|
version: 10.12.3
|
|
run_install: false
|
|
|
|
- name: Get pnpm store directory
|
|
id: pnpm-store
|
|
shell: bash
|
|
run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache pnpm store
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: ${{ steps.pnpm-store.outputs.path }}
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: ${{ runner.os }}-pnpm-store-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: TypeScript type check
|
|
run: pnpm typecheck
|
|
|
|
- name: Check formatting
|
|
run: pnpm format:check
|
|
|
|
- name: Unit tests
|
|
run: pnpm test:unit
|
|
|
|
backend:
|
|
name: Backend Checks
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Install Linux system deps
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends \
|
|
build-essential pkg-config libssl-dev \
|
|
libgtk-3-dev librsvg2-dev libayatana-appindicator3-dev
|
|
sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev \
|
|
|| sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.0-dev
|
|
sudo apt-get install -y --no-install-recommends libsoup-3.0-dev \
|
|
|| sudo apt-get install -y --no-install-recommends libsoup2.4-dev
|
|
|
|
- name: Cache Cargo registry and build
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
src-tauri/target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('src-tauri/Cargo.lock') }}
|
|
restore-keys: ${{ runner.os }}-cargo-
|
|
|
|
- name: Create frontend dist placeholder
|
|
run: mkdir -p dist
|
|
|
|
- name: Check Rust formatting
|
|
run: cargo fmt --check --manifest-path src-tauri/Cargo.toml
|
|
|
|
- name: Clippy
|
|
run: cargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings
|
|
|
|
- name: Run tests
|
|
run: cargo test --manifest-path src-tauri/Cargo.toml
|