chore: bump version to 2.0.0 and require cdl-parser>=2.0.0 #63
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
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| # Cancel in-progress runs for the same branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # Dependency review for PRs (security check) | |
| dependency-review: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Dependency Review | |
| uses: actions/dependency-review-action@v4 | |
| with: | |
| fail-on-severity: high | |
| # Deny licenses that are incompatible with MIT | |
| deny-licenses: GPL-3.0, AGPL-3.0 | |
| # Test with native C++ module | |
| test-native: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| python-version: ['3.10', '3.11', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Eigen (Ubuntu) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo apt-get update && sudo apt-get install -y libeigen3-dev | |
| - name: Install Eigen (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: brew install eigen | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' # Cache pip dependencies | |
| - name: Install dependencies | |
| run: | | |
| pip install gemmology-cdl-parser | |
| pip install -e ".[dev]" -v | |
| - name: Verify native module loaded | |
| run: | | |
| python -c " | |
| from crystal_geometry import get_backend, get_backend_info | |
| info = get_backend_info() | |
| print(f'Backend: {info[\"backend\"]}') | |
| print(f'Native available: {info.get(\"native_available\", False)}') | |
| print(f'Native version: {info.get(\"native_version\", \"N/A\")}') | |
| print(f'Native functions: {info.get(\"native_functions\", [])}') | |
| assert get_backend() == 'native', f'Expected native backend, got {get_backend()}' | |
| print('Native module verified!') | |
| " | |
| - name: Run tests with coverage | |
| run: pytest --cov=src/crystal_geometry --cov-report=xml --cov-report=term-missing -v | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage.xml | |
| flags: native | |
| name: native-ubuntu-py311 | |
| fail_ci_if_error: false # Don't fail if Codecov is down | |
| token: ${{ secrets.CODECOV_TOKEN }} # Optional for public repos | |
| - name: Run benchmarks | |
| run: python benchmarks/numpy_vs_native.py | |
| # Test pure Python fallback (no Eigen) | |
| test-python-fallback: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Install without native module | |
| run: | | |
| pip install gemmology-cdl-parser | |
| # Install without building native module (skip cmake) | |
| pip install numpy scipy pytest pytest-cov ruff mypy | |
| pip install -e . --no-build-isolation --config-settings=cmake.define.SKIP_NATIVE=ON || pip install -e . | |
| env: | |
| CMAKE_ARGS: "-DSKIP_BUILD=ON" | |
| - name: Verify Python fallback | |
| run: | | |
| python -c " | |
| from crystal_geometry import get_backend | |
| backend = get_backend() | |
| print(f'Backend: {backend}') | |
| print('Fallback working!') | |
| " | |
| - name: Run tests with coverage | |
| run: pytest --cov=src/crystal_geometry --cov-report=xml --cov-report=term-missing -v | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.12' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage.xml | |
| flags: python-fallback | |
| name: fallback-py312 | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| # Lint and type check | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install gemmology-cdl-parser | |
| pip install -e ".[dev]" --no-build-isolation || pip install numpy scipy ruff mypy | |
| - name: Lint with Ruff | |
| run: ruff check . --output-format=github | |
| - name: Check formatting with Ruff | |
| run: ruff format --check . | |
| - name: Type check with mypy | |
| run: mypy src/ | |
| # Coverage gate - enforce 80% minimum | |
| coverage-gate: | |
| needs: [test-native, test-python-fallback] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install gemmology-cdl-parser | |
| # Install build deps and dev dependencies first, then package | |
| pip install scikit-build-core pybind11 numpy scipy pytest pytest-cov | |
| pip install -e . --no-build-isolation | |
| env: | |
| CMAKE_ARGS: "-DSKIP_BUILD=ON" | |
| - name: Run tests with coverage | |
| # Target: 80%, Current threshold: 60% (incrementally increasing) | |
| run: pytest --cov=src/crystal_geometry --cov-report=term-missing --cov-fail-under=60 | |
| - name: Coverage report | |
| run: | | |
| echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Current threshold: **60%** (Target: 80%)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Uncovered modules to prioritize:" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`_optim.py\` - optimization functions" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`geometry.py\` - core geometry" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`twins/generators.py\` - twin generation" >> $GITHUB_STEP_SUMMARY |