-
Notifications
You must be signed in to change notification settings - Fork 2
197 lines (165 loc) · 5.8 KB
/
tests.yml
File metadata and controls
197 lines (165 loc) · 5.8 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Tests
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]
workflow_dispatch:
inputs:
coverage-threshold:
description: "Minimum coverage percentage for the Ubuntu baseline suite"
required: false
default: "40"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
COVERAGE_THRESHOLD: "40"
SMOKE_TEST_PATHS: >-
tests/test_bt_api_quality.py
tests/test_event_bus.py
tests/core/test_async_context.py
tests/gateway/test_config.py
FULL_SUITE_MARKERS: "not network and not integration and not performance and not e2e"
jobs:
quality:
name: Quality Gates
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package + quality tools
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install bandit pip-audit
- name: Ruff lint check
run: ruff check bt_api_py tests --output-format=github
- name: Ruff format check
run: ruff format --check bt_api_py tests
- name: MyPy type check
run: mypy bt_api_py --ignore-missing-imports
- name: Bandit security scan
run: bandit -r bt_api_py -ll --skip B101,B311
- name: Dependency audit
run: pip-audit || true
continue-on-error: true
compatibility:
name: Compatibility (Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: quality
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install build tools (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y build-essential
# GitHub-hosted runners do not expose a generic Windows 11 x64 label.
# `windows-latest` is the supported hosted Windows image for this matrix.
- name: Install package + dev deps
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run cross-platform compatibility smoke suite
env:
SKIP_LIVE_TESTS: "true"
run: pytest $SMOKE_TEST_PATHS -q
full-suite:
name: Full Suite (Python 3.11, Ubuntu)
runs-on: ubuntu-latest
timeout-minutes: 45
needs: quality
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Install package + dev deps
run: |
python -m pip install --upgrade pip
pip install -e ".[dev,security]"
- name: Run baseline suite with coverage gate
env:
SKIP_LIVE_TESTS: "true"
run: |
pytest tests -v \
-m "$FULL_SUITE_MARKERS" \
--cov=bt_api_py \
--cov-report=xml:coverage-full.xml \
--cov-report=html \
--cov-report=term-missing \
--cov-fail-under=${{ github.event.inputs['coverage-threshold'] || env.COVERAGE_THRESHOLD }}
- name: Upload coverage to Codecov
if: always() && env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-full.xml
flags: ubuntu-py3.11
fail_ci_if_error: false
verbose: true
- name: Archive coverage report
if: always()
uses: actions/upload-artifact@v7
with:
name: coverage-report-ubuntu-py3.11
path: htmlcov/
retention-days: 30
quality-gate:
name: Quality Gate
runs-on: ubuntu-latest
needs: [quality, compatibility, full-suite]
if: always()
steps:
- name: Check job results
run: |
if [ "${{ needs.quality.result }}" != "success" ]; then
echo "::error::Quality checks failed"
exit 1
fi
if [ "${{ needs.compatibility.result }}" != "success" ]; then
echo "::error::Compatibility matrix failed"
exit 1
fi
if [ "${{ needs.full-suite.result }}" != "success" ]; then
echo "::error::Full baseline suite failed"
exit 1
fi
- name: Generate summary
run: |
echo "## CI Summary" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Job | Status |" >> "$GITHUB_STEP_SUMMARY"
echo "|-----|--------|" >> "$GITHUB_STEP_SUMMARY"
echo "| Quality | ${{ needs.quality.result == 'success' && 'Passed' || 'Failed' }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Compatibility matrix | ${{ needs.compatibility.result == 'success' && 'Passed' || 'Failed' }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Ubuntu baseline suite | ${{ needs.full-suite.result == 'success' && 'Passed' || 'Failed' }} |" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Compatibility matrix: macOS, Linux, Windows x Python 3.9-3.14." >> "$GITHUB_STEP_SUMMARY"