@@ -0,0 +1,97 @@ |
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + schedule: |
| 8 | + # Nightly slow-lane run at 07:00 UTC. |
| 9 | + - cron: "0 7 * * *" |
| 10 | + workflow_dispatch: {} |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ci-${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + fast-lane: |
| 18 | + # Unit tests + lint + type check. Runs on every push, every PR. |
| 19 | + name: fast (unit + lint + mypy) |
| 20 | + runs-on: ubuntu-latest |
| 21 | + timeout-minutes: 10 |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - uses: astral-sh/setup-uv@v6 |
| 26 | + with: |
| 27 | + enable-cache: true |
| 28 | + |
| 29 | + - name: Set up Python |
| 30 | + run: uv python install 3.11 |
| 31 | + |
| 32 | + - name: Install dev deps (core only — no heavy extras) |
| 33 | + run: uv sync --group dev |
| 34 | + |
| 35 | + - name: ruff check |
| 36 | + run: uv run ruff check src tests |
| 37 | + |
| 38 | + - name: ruff format check |
| 39 | + run: uv run ruff format --check src tests |
| 40 | + |
| 41 | + - name: mypy strict |
| 42 | + run: uv run mypy src |
| 43 | + |
| 44 | + - name: pytest (unit) |
| 45 | + run: uv run pytest tests/unit --no-header -v |
| 46 | + |
| 47 | + changes: |
| 48 | + # Decides whether the slow lane runs on this PR. A backend touch or |
| 49 | + # an integration-test touch triggers it; otherwise the nightly cron |
| 50 | + # is the sole slow-lane driver. |
| 51 | + name: detect backend/integration changes |
| 52 | + runs-on: ubuntu-latest |
| 53 | + timeout-minutes: 2 |
| 54 | + outputs: |
| 55 | + backend_touched: ${{ steps.filter.outputs.backend_touched }} |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - id: filter |
| 59 | + uses: dorny/paths-filter@v3 |
| 60 | + with: |
| 61 | + filters: | |
| 62 | + backend_touched: |
| 63 | + - 'src/dlm_sway/backends/**' |
| 64 | + - 'tests/integration/**' |
| 65 | + - 'pyproject.toml' |
| 66 | + |
| 67 | + slow-lane: |
| 68 | + # Integration tests (slow + online). Runs on: schedule, manual |
| 69 | + # dispatch, or when the change-filter flags a backend / integration |
| 70 | + # diff. Skipped on vanilla PRs that only touch probes / docs. |
| 71 | + name: slow (integration, HF backend) |
| 72 | + needs: [changes] |
| 73 | + if: >- |
| 74 | + github.event_name == 'schedule' || |
| 75 | + github.event_name == 'workflow_dispatch' || |
| 76 | + github.event_name == 'push' || |
| 77 | + (github.event_name == 'pull_request' && needs.changes.outputs.backend_touched == 'true') |
| 78 | + runs-on: ubuntu-latest |
| 79 | + timeout-minutes: 30 |
| 80 | + env: |
| 81 | + HF_HUB_DISABLE_PROGRESS_BARS: "1" |
| 82 | + TRANSFORMERS_VERBOSITY: "error" |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - uses: astral-sh/setup-uv@v6 |
| 87 | + with: |
| 88 | + enable-cache: true |
| 89 | + |
| 90 | + - name: Set up Python |
| 91 | + run: uv python install 3.11 |
| 92 | + |
| 93 | + - name: Install dev + hf extras |
| 94 | + run: uv sync --group dev --extra hf |
| 95 | + |
| 96 | + - name: pytest (slow + online) |
| 97 | + run: uv run pytest tests/integration -m "slow or online" --no-header -v |