|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master ] |
| 8 | + |
| 9 | +# prevent overlapping runs on the same ref |
| 10 | +concurrency: |
| 11 | + group: ci-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint-typecheck: |
| 16 | + name: Lint & Type Check |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: "3.12" |
| 25 | + cache: pip |
| 26 | + |
| 27 | + - name: Install dev tools |
| 28 | + run: | |
| 29 | + python -m pip install -U pip |
| 30 | + python -m pip install -e ".[dev]" # installs black, ruff, mypy, pytest, etc. |
| 31 | +
|
| 32 | + - name: Ruff (lint) |
| 33 | + run: ruff check . |
| 34 | + |
| 35 | + - name: Black (format check) |
| 36 | + run: black --check . |
| 37 | + |
| 38 | + - name: Mypy (type check) |
| 39 | + run: mypy spax |
| 40 | + |
| 41 | + tests: |
| 42 | + name: Tests (py${{ matrix.python-version }}) |
| 43 | + runs-on: ubuntu-latest |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + python-version: ["3.11", "3.12", "3.13", "3.14"] |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Set up Python |
| 52 | + uses: actions/setup-python@v5 |
| 53 | + with: |
| 54 | + python-version: ${{ matrix.python-version }} |
| 55 | + cache: pip |
| 56 | + |
| 57 | + - name: Install package (with test extras) |
| 58 | + run: | |
| 59 | + python -m pip install -U pip |
| 60 | + # install project in editable mode + dev deps + YAML/TOML extras used in serialization tests |
| 61 | + python -m pip install -e ".[dev,yaml,toml]" |
| 62 | + # (intentionally NOT installing optuna; TrialSampler tests work without it) |
| 63 | +
|
| 64 | + - name: Pytest |
| 65 | + run: | |
| 66 | + pytest -q --cov=spax --cov-report=xml --cov-report=term-missing |
| 67 | +
|
| 68 | + - name: Upload coverage.xml artifact |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + if: always() |
| 71 | + with: |
| 72 | + name: coverage-${{ matrix.python-version }} |
| 73 | + path: coverage.xml |
| 74 | + |
| 75 | + build: |
| 76 | + name: Build dist & twine check |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: [lint-typecheck, tests] |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Set up Python |
| 83 | + uses: actions/setup-python@v5 |
| 84 | + with: |
| 85 | + python-version: "3.12" |
| 86 | + cache: pip |
| 87 | + |
| 88 | + - name: Build |
| 89 | + run: | |
| 90 | + python -m pip install -U pip build twine |
| 91 | + python -m build |
| 92 | + twine check dist/* |
| 93 | +
|
| 94 | + - name: Upload dist artifacts |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: spax-dist |
| 98 | + path: dist/* |
0 commit comments