Repository navigation
fix: keep diff paths re-included by a gitignore negation (#153) #879
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/ci.yml | |
| name: diffctx CI | |
| 'on': | |
| pull_request: | |
| branches: ['**'] | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ============================================================================ | |
| # Pre-commit checks (fast feedback) | |
| # ============================================================================ | |
| pre-commit: | |
| name: Pre-commit hooks | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Cache pre-commit | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pre-commit | |
| pip install -e ".[dev]" | |
| - name: Run pre-commit | |
| run: pre-commit run --all-files | |
| # ============================================================================ | |
| # Linting and Type Checking | |
| # ============================================================================ | |
| lint-type-check: | |
| name: Lint & Type Check | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| cache-dependency-path: 'pyproject.toml' | |
| - name: Install Linters and Type Checker | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install .[dev] | |
| - name: Run Linters and Formatters Check | |
| run: | | |
| ruff check src eval tests | |
| black --check src eval tests | |
| - name: Run Type Checker (Mypy) | |
| run: | | |
| mypy src | |
| # ============================================================================ | |
| # Rust diffctx tests (2723 YAML test cases, in-memory pipeline) | |
| # ============================================================================ | |
| rust-diffctx-test: | |
| name: Rust diffctx tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # stable | |
| with: | |
| toolchain: "1.92.0" | |
| components: rustfmt, clippy | |
| - name: Cache Cargo | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: cargo-${{ runner.os }}- | |
| - name: Build and test | |
| working-directory: crates/diffctx-native | |
| env: | |
| DIFFCTX_YAML_CASES_LIMIT: "20" | |
| run: | | |
| cargo test --lib | |
| # Dev profile: the release profile sets panic = "abort", and building | |
| # the binary into a libtest target there mixes abort and unwind | |
| # artifacts that break the harness-free yaml_cases build. | |
| cargo test --test native_cli | |
| cargo build --release --examples | |
| cargo test --release --test yaml_cases | |
| # Informational full-suite run (2700+ cases): quality-threshold failures | |
| # are tracked as an eval baseline, not a CI gate. | |
| - name: Run diffctx YAML test suite | |
| working-directory: crates/diffctx-native | |
| run: ../../target/release/examples/diffctx-test || true | |
| # ============================================================================ | |
| # Cross-platform Python Testing (diffctx core) | |
| # ============================================================================ | |
| test: | |
| needs: [lint-type-check] | |
| # CI is Linux-only across all Python versions (minimal, cheap: 1x minutes). | |
| # macOS (10x) / Windows (2x) cross-platform coverage runs at RELEASE time in | |
| # cd.yml — build-wheels compiles the Rust ext per-OS and smoke-pypi installs | |
| # and exercises diffctx on ubuntu/macos/windows. No per-push macOS/Windows. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| python-version: ['3.10', '3.11', '3.12', '3.13'] | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| cache-dependency-path: 'pyproject.toml' | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # stable | |
| with: | |
| toolchain: "1.92.0" | |
| components: rustfmt, clippy | |
| - name: Cache Cargo | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: cargo-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: cargo-${{ runner.os }}-py${{ matrix.python-version }}- | |
| - name: Install build backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install "maturin>=1.10,<1.11" | |
| - name: Build and install diffctx (with Rust _diffctx) and dev deps | |
| shell: bash | |
| env: | |
| PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1" | |
| run: | | |
| # PEP 660 editable install — maturin builds the Rust extension and | |
| # pip installs everything (diffctx + [dev,full,mcp] extras). Skip build | |
| # isolation since we just installed maturin in this env. | |
| pip install -e ".[dev,full,mcp]" --no-build-isolation | |
| - name: Run Tests with Coverage | |
| shell: bash | |
| run: | | |
| pytest -v --cov=src/diffctx --cov-report=xml \ | |
| --cov-report=term-missing --cov-branch --junitxml=test-results.xml | |
| - name: Coverage report with threshold | |
| run: | | |
| coverage report --fail-under=40 | |
| - name: Upload coverage reports to Codecov | |
| if: runner.os == 'Linux' && matrix.python-version == '3.12' | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.xml | |
| flags: integration | |
| fail_ci_if_error: false | |
| verbose: true | |
| - name: Upload coverage for SonarCloud | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' | |
| with: | |
| name: coverage-report | |
| path: | | |
| coverage.xml | |
| test-results.xml | |
| retention-days: 1 | |
| # ============================================================================ | |
| # Complexity & Maintainability Metrics | |
| # ============================================================================ | |
| complexity-checks: | |
| name: Complexity & Maintainability Analysis | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Check cyclomatic complexity | |
| run: | | |
| echo "=== Cyclomatic Complexity Report ===" | |
| radon cc src/diffctx/ --min B --show-complexity --total-average | |
| - name: Check maintainability index | |
| run: | | |
| echo "=== Maintainability Index Report ===" | |
| radon mi src/diffctx/ --min B --show | |
| - name: Fail on high complexity | |
| run: | | |
| radon cc src/diffctx/ --min C --total-average || \ | |
| (echo "High complexity detected" && exit 1) | |
| # ============================================================================ | |
| # Architecture & Import Contracts | |
| # ============================================================================ | |
| architecture-checks: | |
| name: Architecture & Import Contracts | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Check import contracts | |
| run: lint-imports |