|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + name: Test with Python ${{ matrix.python-version }} |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + python-version: ["3.10", "3.11", "3.12"] |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + |
| 30 | + - name: Cache Poetry dependencies |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: ~/.cache/pypoetry |
| 34 | + key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 35 | + |
| 36 | + - name: Install Poetry |
| 37 | + run: | |
| 38 | + curl -sSL https://install.python-poetry.org | python3 - |
| 39 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 40 | +
|
| 41 | + - name: Install dependencies |
| 42 | + run: poetry install --with dev --no-interaction --no-root |
| 43 | + |
| 44 | + - name: Check runtime dependencies |
| 45 | + run: | |
| 46 | + poetry run python - <<'PY' |
| 47 | + import importlib, sys |
| 48 | + missing = [m for m in ("pandas",) if importlib.util.find_spec(m) is None] |
| 49 | + if missing: |
| 50 | + print("Missing dependencies:", ", ".join(missing)) |
| 51 | + sys.exit(1) |
| 52 | + PY |
| 53 | +
|
| 54 | + - name: Verify version matches tag |
| 55 | + if: startsWith(github.ref, 'refs/tags/') |
| 56 | + run: python scripts/check_version_match.py |
| 57 | + |
| 58 | + - name: Run tests with coverage |
| 59 | + run: poetry run pytest --cov=gen_surv --cov-report=xml --cov-report=term |
| 60 | + |
| 61 | + - name: Upload coverage to Codecov |
| 62 | + if: matrix.python-version == '3.11' |
| 63 | + uses: codecov/codecov-action@v5 |
| 64 | + with: |
| 65 | + files: coverage.xml |
| 66 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 67 | + |
| 68 | + lint: |
| 69 | + name: Code Quality |
| 70 | + runs-on: ubuntu-latest |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: Checkout code |
| 74 | + uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - name: Set up Python |
| 77 | + uses: actions/setup-python@v5 |
| 78 | + with: |
| 79 | + python-version: "3.11" |
| 80 | + |
| 81 | + - name: Cache Poetry dependencies |
| 82 | + uses: actions/cache@v4 |
| 83 | + with: |
| 84 | + path: ~/.cache/pypoetry |
| 85 | + key: ${{ runner.os }}-poetry-3.11-${{ hashFiles('**/poetry.lock') }} |
| 86 | + |
| 87 | + - name: Install Poetry |
| 88 | + run: | |
| 89 | + curl -sSL https://install.python-poetry.org | python3 - |
| 90 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 91 | +
|
| 92 | + - name: Install dependencies |
| 93 | + run: poetry install --with dev --no-interaction --no-root |
| 94 | + |
| 95 | + - name: Run pre-commit checks |
| 96 | + run: poetry run pre-commit run --all-files |
0 commit comments