-
Notifications
You must be signed in to change notification settings - Fork 2
197 lines (166 loc) · 5.21 KB
/
optimized-tests.yml
File metadata and controls
197 lines (166 loc) · 5.21 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: Extended Validation Suite
on:
workflow_dispatch:
inputs:
run_performance:
description: "Run performance benchmarks"
required: false
default: false
type: boolean
run_security:
description: "Run extended security checks"
required: false
default: true
type: boolean
run_build_test:
description: "Run build/package validation"
required: false
default: true
type: boolean
schedule:
- cron: "0 2 * * *"
env:
SMOKE_TEST_PATHS: >-
tests/test_bt_api_quality.py
jobs:
compatibility-matrix:
name: Extended Compatibility (Python ${{ matrix.python-version }}, ${{ matrix.os }})
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
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
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run smoke compatibility suite
env:
SKIP_LIVE_TESTS: "true"
run: pytest $SMOKE_TEST_PATHS -q
performance:
if: inputs.run_performance == true
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run performance tests
run: |
if [ -d tests/performance ]; then
pytest tests/performance/ --tb=short -v --benchmark-json=benchmark.json
else
echo "No performance tests found, skipping"
fi
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
tool: pytest
output-file-path: benchmark.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
comment-on-alert: true
alert-threshold: "200%"
fail-on-alert: true
security:
if: github.event_name == 'schedule' || inputs.run_security == true
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install bandit pip-audit
- name: Run security scan
run: |
bandit -r bt_api_py -f json -o bandit-report.json || true
pip-audit -f json -o pip-audit-report.json || true
- name: Upload security reports
uses: actions/upload-artifact@v7
with:
name: security-reports
path: |
bandit-report.json
pip-audit-report.json
build-test:
if: github.event_name == 'schedule' || inputs.run_build_test == true
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Check package metadata
run: twine check dist/*
- name: Test wheel installation
run: |
pip install dist/*.whl
python -c "import bt_api_py; print('Package installed successfully')"
notify:
if: failure()
needs: [compatibility-matrix, performance, security, build-test]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Notify on failure
uses: actions/github-script@v8
with:
script: |
const { owner, repo } = context.repo;
const sha = context.sha;
const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;
github.rest.repos.createCommitComment({
owner,
repo,
commit_sha: sha,
body: `Extended validation suite failed: ${runUrl}`,
});