-
Notifications
You must be signed in to change notification settings - Fork 21
182 lines (159 loc) · 5.62 KB
/
main.yaml
File metadata and controls
182 lines (159 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: CI
on:
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install uv (fast Python + package manager) and enable caching
- name: Setup uv
uses: astral-sh/setup-uv@v3
# Cache uv tool + resolver cache
- name: Cache uv caches
uses: actions/cache@v4
with:
path: |
~/.cache/uv
key: uv-cache-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
# Sync environment from lock if present so tool versions come from pyproject.toml/uv.lock
- name: Sync deps (locked if available)
shell: bash
run: |
if [[ -f uv.lock ]]; then
uv sync --extra dev --frozen
else
uv sync --extra dev
fi
- name: ruff check
run: uv run ruff check s2and scripts tests
- name: ruff format (s2and/)
run: uv run ruff format --check s2and
- name: ruff format (scripts/*.py)
shell: bash
run: |
shopt -s nullglob
files=(scripts/*.py)
if (( ${#files[@]} )); then
uv run ruff format --check "${files[@]}"
fi
typecheck-and-test:
name: typecheck-and-test (${{ matrix.lane }})
runs-on: ubuntu-latest
needs: [lint]
strategy:
fail-fast: false
matrix:
lane: [py-only, rust-enabled]
steps:
- uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v3
# Optional: ensure a specific Python (uv can also manage this on its own)
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup Rust
if: matrix.lane == 'rust-enabled'
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo build
if: matrix.lane == 'rust-enabled'
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
s2and_rust/target
key: cargo-${{ runner.os }}-${{ hashFiles('s2and_rust/Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
# Cache uv resolver + wheels + project venv
- name: Cache uv + venv
uses: actions/cache@v4
with:
path: |
~/.cache/uv
.venv
key: uv-venv-${{ runner.os }}-py311-${{ matrix.lane }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
restore-keys: |
uv-venv-${{ runner.os }}-py311-${{ matrix.lane }}-
uv-venv-${{ runner.os }}-py311-
uv-venv-
# Sync environment from lock if present (fast; no network if cached)
- name: Sync deps (locked if available)
shell: bash
run: |
if [[ -f uv.lock ]]; then
if [[ "${{ matrix.lane }}" == "rust-enabled" ]]; then
uv sync --extra dev --extra rust --frozen
else
uv sync --extra dev --frozen
fi
else
# No lock present; resolve once, then install
if [[ "${{ matrix.lane }}" == "rust-enabled" ]]; then
uv sync --extra dev --extra rust
else
uv sync --extra dev
fi
fi
# Build/install Rust extension for parity tests
- name: Build Rust extension
if: matrix.lane == 'rust-enabled'
run: uv run --with maturin maturin develop -m s2and_rust/Cargo.toml
- name: Rust parity guardrail: feature parity
if: matrix.lane == 'rust-enabled'
run: uv run pytest -q tests/test_feature_port_parity.py
- name: Rust parity guardrail: signature preprocess parity
if: matrix.lane == 'rust-enabled'
run: uv run pytest -q tests/test_rust_signature_preprocess.py
- name: Rust parity guardrail: batch chunking/fallback parity
if: matrix.lane == 'rust-enabled'
run: uv run pytest -q tests/test_rust_batch_chunking.py
- name: Rust parity guardrail: JSON ingest parity
if: matrix.lane == 'rust-enabled'
run: uv run pytest -q tests/test_rust_from_json_paths.py
# Type checking (ty with tuned migration rules)
- name: ty (s2and)
run: |
uv run ty check s2and \
--ignore unresolved-import \
--ignore unused-type-ignore-comment \
--ignore possibly-missing-attribute \
--ignore unresolved-global
- name: ty (scripts)
shell: bash
run: |
shopt -s nullglob
files=(scripts/*.py)
if (( ${#files[@]} )); then
uv run ty check "${files[@]}" \
--ignore unresolved-import \
--ignore unused-type-ignore-comment \
--ignore possibly-missing-attribute \
--ignore unresolved-global \
--ignore unresolved-reference \
--ignore unresolved-attribute
fi
- name: pytest (coverage, py-only)
if: matrix.lane == 'py-only'
env:
# keep startup lean; avoid user-level plugins on hosted runners
PYTHONPATH: .
S2AND_BACKEND: python
run: |
uv run pytest tests/ \
--cov=s2and --cov-report=term-missing --cov-fail-under=40
- name: pytest (coverage, rust-enabled)
if: matrix.lane == 'rust-enabled'
env:
# keep startup lean; avoid user-level plugins on hosted runners
PYTHONPATH: .
run: |
uv run pytest tests/ \
--cov=s2and --cov-report=term-missing --cov-fail-under=40