|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + lint: |
| 15 | + name: Lint |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up uv |
| 21 | + uses: astral-sh/setup-uv@v4 |
| 22 | + with: |
| 23 | + enable-cache: true |
| 24 | + |
| 25 | + - name: Set up Python |
| 26 | + run: uv python install 3.11 |
| 27 | + |
| 28 | + - name: Create virtual environment |
| 29 | + run: uv venv |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: uv pip install -e ".[dev]" |
| 33 | + |
| 34 | + - name: Ruff check |
| 35 | + run: uv run ruff check src/ tests/ |
| 36 | + |
| 37 | + - name: Ruff format check |
| 38 | + run: uv run ruff format --check src/ tests/ |
| 39 | + |
| 40 | + - name: Pyright |
| 41 | + run: uv run pyright --warnings src/ |
| 42 | + |
| 43 | + test: |
| 44 | + name: Test (Python ${{ matrix.python-version }}, ${{ matrix.os }}) |
| 45 | + runs-on: ${{ matrix.os }} |
| 46 | + needs: lint |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + os: [ubuntu-latest, macos-14] |
| 51 | + python-version: ["3.11"] |
| 52 | + env: |
| 53 | + JAX_PLATFORMS: cpu |
| 54 | + WANDB_DIR: /tmp/calibrax-test-wandb |
| 55 | + WANDB_MODE: offline |
| 56 | + XLA_PYTHON_CLIENT_PREALLOCATE: "false" |
| 57 | + TF_CPP_MIN_LOG_LEVEL: "1" |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Set up uv |
| 62 | + uses: astral-sh/setup-uv@v4 |
| 63 | + with: |
| 64 | + enable-cache: true |
| 65 | + |
| 66 | + - name: Set up Python |
| 67 | + run: uv python install ${{ matrix.python-version }} |
| 68 | + |
| 69 | + - name: Create virtual environment |
| 70 | + run: uv venv |
| 71 | + |
| 72 | + - name: Install dependencies |
| 73 | + run: uv pip install -e ".[dev,test,stats,changepoint,mlflow]" |
| 74 | + |
| 75 | + - name: Create temp directory |
| 76 | + run: mkdir -p temp |
| 77 | + |
| 78 | + - name: Run tests |
| 79 | + run: | |
| 80 | + uv run pytest tests/ \ |
| 81 | + --cov=calibrax \ |
| 82 | + --cov-report=term-missing \ |
| 83 | + --cov-report=xml:coverage.xml \ |
| 84 | + --cov-fail-under=80 \ |
| 85 | + --timeout=300 \ |
| 86 | + -v |
| 87 | +
|
| 88 | + - name: Upload coverage |
| 89 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' |
| 90 | + uses: codecov/codecov-action@v4 |
| 91 | + with: |
| 92 | + file: coverage.xml |
| 93 | + fail_ci_if_error: false |
| 94 | + |
| 95 | + build: |
| 96 | + name: Build |
| 97 | + runs-on: ubuntu-latest |
| 98 | + needs: test |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - name: Set up uv |
| 103 | + uses: astral-sh/setup-uv@v4 |
| 104 | + with: |
| 105 | + enable-cache: true |
| 106 | + |
| 107 | + - name: Set up Python |
| 108 | + run: uv python install 3.11 |
| 109 | + |
| 110 | + - name: Create virtual environment |
| 111 | + run: uv venv |
| 112 | + |
| 113 | + - name: Build package |
| 114 | + run: uv build |
| 115 | + |
| 116 | + - name: Check distribution |
| 117 | + run: | |
| 118 | + uv pip install twine |
| 119 | + uv run twine check dist/* |
0 commit comments