Repository navigation
140 lines (134 loc) · 4.9 KB
/
Copy pathci.yml
File metadata and controls
140 lines (134 loc) · 4.9 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
name: CI
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# Keeps uv.lock in sync with pyproject.toml. On feature branches it also applies
# ruff's safe autofixes and formatting, and commits them; on main it only checks.
housekeeping:
name: Lockfile and formatting
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
sha: ${{ steps.commit.outputs.sha }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
- uses: astral-sh/setup-uv@v7
- name: Resolve dependencies
run: uv lock
- name: Autofix (feature branches only)
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
run: |
uvx ruff@0.14.0 check --fix --exit-zero .
uvx ruff@0.14.0 format .
- name: Commit changes
id: commit
shell: bash
run: |
if [ -n "$(git status --porcelain)" ]; then
if [ "${{ github.event_name }}" != "push" ]; then
git status --porcelain
echo "::error title=Out of date::uv.lock or formatting is out of date; run 'uv lock' and 'ruff format'"
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore(ci): update uv.lock and apply ruff fixes"
git push
fi
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
test:
name: Test (${{ matrix.os }}, py${{ matrix.python }})
needs: housekeeping
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: ["3.10", "3.12"]
runs-on: ${{ matrix.os }}
env:
# Native windows on Windows so the real capture-shield API is exercised.
QT_QPA_PLATFORM: ${{ matrix.os == 'windows-latest' && 'windows' || 'offscreen' }}
PYTHONUTF8: "1"
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.housekeeping.outputs.sha }}
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}
- name: System libraries (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libegl1 libgl1 libxkbcommon0 \
libxkbcommon-x11-0 libfontconfig1 libdbus-1-3 libportaudio2
- name: Install (locked)
id: install
run: uv sync --locked
- name: Lint
shell: bash
run: uv run ruff check --output-format=concise . | uv run python scripts/ci_annotate.py lines ruff
- name: Type check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
shell: bash
run: uv run mypy | uv run python scripts/ci_annotate.py lines mypy
- name: Tests
id: tests
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
shell: bash
run: uv run pytest -q --junitxml=junit.xml --cov=polyglot --cov-report=term-missing:skip-covered
- name: Real capture shield on Windows
if: ${{ runner.os == 'Windows' && !cancelled() && steps.install.outcome == 'success' }}
shell: bash
run: uv run python scripts/shield_check.py
- name: Annotate test failures
if: failure()
shell: bash
run: test -f junit.xml && uv run python scripts/ci_annotate.py junit junit.xml || true
- name: Diagnose a crashed test run
if: ${{ failure() && steps.tests.outcome == 'failure' }}
shell: bash
run: |
uv run pytest -v -p no:cacheprovider -o addopts="" -m "not slow" 2>&1 \
| uv run python scripts/ci_annotate.py tail "crashed test run (last lines)" || true
models:
name: Real models (Whisper tiny, Silero)
needs: housekeeping
runs-on: ubuntu-latest
env:
QT_QPA_PLATFORM: offscreen
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.housekeeping.outputs.sha }}
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"
- name: System libraries
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends espeak-ng libportaudio2 libegl1 \
libgl1 libxkbcommon0 libfontconfig1 libdbus-1-3
- uses: actions/cache@v6
with:
path: ~/.cache/huggingface
key: hf-whisper-tiny
- run: uv sync --locked
- name: Slow tests
shell: bash
run: uv run pytest -m slow -q --junitxml=junit.xml
- name: Annotate test failures
if: failure()
shell: bash
run: test -f junit.xml && uv run python scripts/ci_annotate.py junit junit.xml || true