Skip to content

fix: 使用环境变量配置 canvas 预编译二进制 #35

fix: 使用环境变量配置 canvas 预编译二进制

fix: 使用环境变量配置 canvas 预编译二进制 #35

Workflow file for this run

# 🧪 持续集成工作流
# 在每次推送和 PR 时运行测试
name: CI
on:
push:
branches: [ main, master, develop ]
paths-ignore:
- '**.md'
- 'docs/**'
pull_request:
branches: [ main, master ]
paths-ignore:
- '**.md'
- 'docs/**'
jobs:
test:
name: Test on Node ${{ matrix.node-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [18.x, 20.x]
include:
- os: macos-latest
node-version: 20.x
steps:
- name: Checkout code
uses: actions/checkout@v4
# 安装 Canvas 依赖 (Ubuntu)
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
# 安装 Canvas 依赖 (macOS)
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman python-setuptools
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
# 使用预构建的 canvas 二进制文件,避免编译
npm_config_build_from_source: false
- name: Check ESLint config
run: cat .eslintrc.json || echo "No ESLint config found"
- name: Run linter
run: pnpm lint
- name: Build TypeScript
run: pnpm build
- name: Run tests
run: pnpm vitest run
env:
DASHENG_MOCK: true
- name: Test CLI help
run: node dist/cli/index.js --help
# 检查代码格式
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
# 安装 Canvas 依赖
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
npm_config_build_from_source: false
- name: Check formatting
run: pnpm prettier --check "src/**/*.ts"
# 检查类型
type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
npm_config_build_from_source: false
- name: Type check
run: pnpm tsc --noEmit