mirror of https://github.com/razor-ai/soup.git
109 lines
4.6 KiB
YAML
109 lines
4.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- run: pip install ruff
|
|
- run: ruff check src/soup_cli/ tests/
|
|
|
|
type-check:
|
|
runs-on: ubuntu-latest
|
|
# Non-blocking type-check baseline. The codebase adopts annotations
|
|
# incrementally, so mypy findings are surfaced as a warning annotation (and
|
|
# in the step log) but do NOT fail the job — the check stays green until
|
|
# types are tightened enough to promote it to a required gate. Reads
|
|
# [tool.mypy] from pyproject.toml (files = ["src/soup_cli"],
|
|
# ignore_missing_imports = true).
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- run: pip install mypy
|
|
- name: mypy (non-blocking)
|
|
run: |
|
|
mypy || echo "::warning title=mypy::Type issues reported (non-blocking baseline — see the log above)"
|
|
|
|
test:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
python-version: ["3.10", "3.11", "3.12"]
|
|
runs-on: ${{ matrix.os }}
|
|
env:
|
|
# Force UTF-8 mode on all platforms. Without this, Windows defaults to
|
|
# cp1252 ('charmap'), which fails when importing upstream packages that
|
|
# read their own source / data files without an explicit encoding
|
|
# (seen with trl.trainer.grpo_trainer on windows-latest / py3.11).
|
|
PYTHONUTF8: "1"
|
|
PYTHONIOENCODING: "utf-8"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- name: Install dependencies
|
|
run: pip install -e ".[dev]"
|
|
- name: Warm HF Hub cache (tiny test models)
|
|
# Pre-download the tiny models the unit tests load, with retries, so a
|
|
# transient HF Hub 429 (Too Many Requests) on a single matrix cell does
|
|
# not red the whole run. Observed: ~5/7 cells download fine and ~2/7 hit
|
|
# a 429 — a retry loop reliably populates the cache so the tests then
|
|
# read from disk (no network). Never fails the job: if warming can't
|
|
# complete it emits a ::warning:: and lets the test step run as before.
|
|
shell: python
|
|
run: |
|
|
import time
|
|
from huggingface_hub import snapshot_download
|
|
|
|
models = ["sshleifer/tiny-gpt2", "hf-internal-testing/tiny-random-gpt2"]
|
|
for repo in models:
|
|
for attempt in range(1, 7):
|
|
try:
|
|
snapshot_download(repo)
|
|
print(f"warmed {repo}")
|
|
break
|
|
except Exception as exc: # noqa: BLE001 — best effort, never fail the job
|
|
print(f"attempt {attempt}/6 for {repo} failed: {type(exc).__name__}: {exc}")
|
|
time.sleep(min(5 * attempt, 30))
|
|
else:
|
|
print(f"::warning title=HF cache::could not warm {repo} after 6 attempts")
|
|
- name: Run unit tests with coverage
|
|
run: pytest tests/ -v --tb=short --junitxml=report.xml --cov=soup_cli --cov-report=xml:coverage.xml --cov-report=term-missing:skip-covered
|
|
- name: Upload coverage to Codecov
|
|
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: coverage.xml
|
|
fail_ci_if_error: false
|
|
- name: Update test count badge
|
|
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
run: |
|
|
TESTS=$(python -c "
|
|
import xml.etree.ElementTree as ET
|
|
root = ET.parse('report.xml').getroot()
|
|
ts = root.find('testsuite')
|
|
print(ts.attrib.get('tests', '0') if ts is not None else root.attrib.get('tests', '0'))
|
|
")
|
|
echo "Test count: $TESTS"
|
|
# --fail-with-body: surface non-2xx (e.g. 401 expired token) as a
|
|
# CI failure with the response body printed, instead of silently
|
|
# discarding to /dev/null and leaving the badge stale.
|
|
curl --fail-with-body -sS \
|
|
-X PATCH \
|
|
-H "Authorization: token ${{ secrets.GIST_TOKEN }}" \
|
|
-d "{\"files\":{\"soup_tests.json\":{\"content\":\"{\\\"schemaVersion\\\":1,\\\"label\\\":\\\"tests\\\",\\\"message\\\":\\\"$TESTS passed\\\",\\\"color\\\":\\\"brightgreen\\\"}\"}}}" \
|
|
"https://api.github.com/gists/65fdc943f85f3b2c46ecddb415c2b779"
|