|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + # ─── Lockfile validation (from python-pr-ci-uv-v3-build) ─── |
| 13 | + # Equivalent of validate-project-structure in the Nu template. |
| 14 | + # Ensures pyproject.toml exists and uv.lock is in sync. |
| 15 | + # Old push.yaml: did not have this check. |
| 16 | + validate-project-structure: |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v6 |
| 20 | + - uses: astral-sh/setup-uv@v7 |
| 21 | + - name: Check project structure |
| 22 | + run: | |
| 23 | + if [[ ! -f pyproject.toml ]]; then |
| 24 | + echo "::error::pyproject.toml not found" |
| 25 | + exit 1 |
| 26 | + fi |
| 27 | + uv lock --check |
| 28 | +
|
| 29 | + # ─── Linter (replaces current flake8 job, from python-pr-ci-uv-v3-build) ─── |
| 30 | + # Old: pip install flake8 && flake8 --ignore=E731,W503 --max-line-length=120 src/ tests/ |
| 31 | + # New: ruff check (configured in pyproject.toml [tool.ruff]) |
| 32 | + # Nu template: runLinter defaults to "true". |
| 33 | + linter: |
| 34 | + runs-on: ubuntu-24.04 |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v6 |
| 37 | + - uses: astral-sh/setup-uv@v7 |
| 38 | + - name: Lint with ruff |
| 39 | + run: | |
| 40 | + uv sync --group dev --no-install-project |
| 41 | + uv run ruff check src/ tests/ |
| 42 | +
|
| 43 | + # ─── Formatter check (from python-pr-ci-uv-v3-build) ─── |
| 44 | + # New job — the old push.yaml didn't have formatting checks. |
| 45 | + # ruff format replaces black. |
| 46 | + # Nu template: runFormatterCheck defaults to "false", enabled via input. |
| 47 | + formatter-check: |
| 48 | + runs-on: ubuntu-24.04 |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v6 |
| 51 | + - uses: astral-sh/setup-uv@v7 |
| 52 | + - name: Check formatting with ruff |
| 53 | + run: | |
| 54 | + uv sync --group dev --no-install-project |
| 55 | + uv run ruff format --check src/ tests/ |
| 56 | +
|
| 57 | + # ─── Type check (same as current push.yaml mypy step) ─── |
| 58 | + # Old: source env/bin/activate && python3 -m mypy src tests --config mypy.ini |
| 59 | + # New: uv sync --all-extras && uv run mypy (reads config from pyproject.toml) |
| 60 | + # |
| 61 | + # NOTE: The Nu template has runMypy: "false" by default and there is no |
| 62 | + # runMypy key exposed in python-library-uv-stable's input — so mypy NEVER |
| 63 | + # runs in the standard Nu template. fklearn's current push.yaml DOES run |
| 64 | + # mypy (inside the test-suite job, step "Type check"). We keep it as a |
| 65 | + # separate job for faster feedback. This goes beyond the template default. |
| 66 | + mypy: |
| 67 | + runs-on: ubuntu-24.04 |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v6 |
| 70 | + - uses: astral-sh/setup-uv@v7 |
| 71 | + - name: Type check with mypy |
| 72 | + run: | |
| 73 | + uv sync --all-extras |
| 74 | + uv run mypy src/ tests/ |
| 75 | +
|
| 76 | + # ─── Package build check (replaces current test-packaging job) ─── |
| 77 | + # Old: pip install build twine && python3 -m build && twine check dist/* |
| 78 | + # New: uv build (twine check not needed — uv validates metadata) |
| 79 | + test-packaging: |
| 80 | + runs-on: ubuntu-24.04 |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v6 |
| 83 | + - uses: astral-sh/setup-uv@v7 |
| 84 | + - name: Build package |
| 85 | + run: uv build |
| 86 | + - name: Verify package |
| 87 | + run: | |
| 88 | + ls -lh dist/ |
| 89 | + echo "Package built successfully" |
| 90 | +
|
| 91 | + # ─── Test suite (replaces current test-suite job, from python-pr-ci-uv-v3-tests) ─── |
| 92 | + # Old: pip install -e .[devel] && pytest --cov-fail-under=93 --cov=src/ tests/ |
| 93 | + # New: uv sync --all-extras && pytest with coverage |
| 94 | + # Coverage threshold: 93% (matching the current push.yaml) |
| 95 | + # |
| 96 | + # NOTE on fail-fast: The Nu template's Tekton matrix has NO fail-fast |
| 97 | + # concept — all Python versions run independently regardless of failures. |
| 98 | + # GitHub Actions defaults to fail-fast: true (cancels remaining matrix |
| 99 | + # jobs when one fails). We set fail-fast: false to match Nu template |
| 100 | + # behavior and get full visibility into which Python versions pass/fail. |
| 101 | + # |
| 102 | + # NOTE on coverage: The Nu template has runPytestCov: "false" and |
| 103 | + # coverageThreshold: "0" by default — coverage is disabled unless |
| 104 | + # explicitly configured. fklearn's current push.yaml DOES enforce |
| 105 | + # --cov-fail-under=93, so we keep it here. |
| 106 | + test-suite: |
| 107 | + runs-on: ubuntu-24.04 |
| 108 | + strategy: |
| 109 | + fail-fast: false |
| 110 | + matrix: |
| 111 | + python-version: ['3.10', '3.11', '3.12', '3.13'] |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v6 |
| 114 | + - uses: astral-sh/setup-uv@v7 |
| 115 | + - name: Create venv and install dependencies |
| 116 | + run: | |
| 117 | + # Match Nu template: explicit venv creation with --seed |
| 118 | + # --seed installs pip, setuptools, wheel into the venv. |
| 119 | + # Some packages (e.g. old setup.py-based deps) need setuptools |
| 120 | + # at install time. Without --seed, the venv only has uv. |
| 121 | + rm -rf .venv |
| 122 | + uv venv -p ${{ matrix.python-version }} --seed |
| 123 | + uv sync -p ${{ matrix.python-version }} -v --all-extras |
| 124 | + - name: Run tests with coverage |
| 125 | + run: | |
| 126 | + uv run -p ${{ matrix.python-version }} pytest tests/ \ |
| 127 | + --showlocals \ |
| 128 | + --cov-fail-under=93 \ |
| 129 | + --cov-report=term \ |
| 130 | + --cov=src/ |
| 131 | +
|
| 132 | + # ─── Doc build check (replaces current build-docs job) ─── |
| 133 | + # Old: pip install -e .[devel] && pip install -r docs/requirements.txt && |
| 134 | + # sudo apt-get install pandoc && cd docs/ && make html |
| 135 | + # New: uv sync with docs extra && make html |
| 136 | + # Only runs after linter and tests pass (same as current push.yaml: |
| 137 | + # "needs: [linter, test-suite]"). |
| 138 | + build-docs: |
| 139 | + needs: [linter, test-suite] |
| 140 | + runs-on: ubuntu-24.04 |
| 141 | + steps: |
| 142 | + - uses: actions/checkout@v6 |
| 143 | + - uses: astral-sh/setup-uv@v7 |
| 144 | + - name: Install dependencies |
| 145 | + run: | |
| 146 | + sudo apt-get update && sudo apt-get install -y pandoc |
| 147 | + uv sync --extra docs --extra test_deps |
| 148 | + - name: Build docs |
| 149 | + run: | |
| 150 | + cd docs/ |
| 151 | + uv run make html |
| 152 | +
|
| 153 | + # ─── Version bump check (from python-library-pr-check-version-uv-v1) ─── |
| 154 | + # TODO: Implement validate-bump job. |
| 155 | + # The old push.yaml did not have this check. |
| 156 | + # See validate_bump_uv.sh in cicd-images/nu-python-builder for reference. |
0 commit comments