Skip to content

CI Integration Guide

Integrate YaoXiang's static checking and formatting tools into CI/CD pipelines to ensure code quality.

GitHub Actions

yaml
name: YaoXiang CI

on:
  push:
    branches: [main, dev]
  pull_request:
    branches: [main]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install YaoXiang
        run: |
          curl -fsSL https://yaoxiang.dev/install.sh | sh
          echo "$HOME/.yaoxiang/bin" >> $GITHUB_PATH

      - name: Type check
        run: yaoxiang check --color never --no-progress

      - name: Format check
        run: yaoxiang format --dry-run .

GitLab CI

yaml
yaoxiang-check:
  image: rust:latest
  script:
    - curl -fsSL https://yaoxiang.dev/install.sh | sh
    - export PATH="$HOME/.yaoxiang/bin:$PATH"
    - yaoxiang check --color never --no-progress
    - yaoxiang format --dry-run .
  rules:
    - if: $CI_MERGE_REQUEST_IID
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH == "dev"

Exit Codes

Exit CodeMeaningCI Behavior
0No errorsPass
1Check found errorsFail
2No .yx files foundDepends on configuration

JSON Output Parsing

Use --json to get machine-readable output:

bash
yaoxiang check --json | jq '.error_count'

Best Practices

  1. Path arguments: yaoxiang check checks the current directory by default, or you can specify a path: yaoxiang check src/
  2. Separate check and format: Run check and format --dry-run separately for easier troubleshooting
  3. Use --no-progress: CI environments don't need progress bars
  4. Use --color never: Avoid ANSI color codes polluting logs
  5. Cache dependencies: Use CI caching mechanisms to speed up builds