-
-
Notifications
You must be signed in to change notification settings - Fork 21
203 lines (172 loc) · 6.1 KB
/
Copy pathmain.yml
File metadata and controls
203 lines (172 loc) · 6.1 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
198
199
200
201
202
203
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
PYTHONPATH: ${{ github.workspace }}
jobs:
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-format-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-format-
- name: Install formatting tools
run: |
python -m pip install --upgrade pip
pip install yapf black isort mypy pylint flake8
- name: Run format check
run: |
bash format.sh --all
- name: Check for formatting changes
run: |
if ! git diff --quiet; then
echo "Code formatting issues detected. Please run 'bash format.sh --all' locally."
git diff
exit 1
fi
linter:
name: Lint
runs-on: ubuntu-latest
needs: format-check
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-lint-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-lint-${{ matrix.python-version }}-
- name: Install project
run: |
python -m pip install --upgrade pip
# Install test dependencies
pip install pytest pytest-cov flake8 black mypy isort yapf pylint
# Install project in editable mode
pip install -e .
- name: Run linter
run: make lint
tests:
name: Tests
runs-on: ${{ matrix.os }}
needs: linter
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12']
exclude:
# Reduce CI load by testing fewer combinations on non-Ubuntu
- os: macos-latest
python-version: '3.11'
- os: windows-latest
python-version: '3.11'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-test-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-test-${{ matrix.python-version }}-
- name: Install system dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Install system dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install ffmpeg
- name: Install system dependencies (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
# Install ffmpeg via chocolatey
choco install ffmpeg -y
- name: Install project with test dependencies
run: |
python -m pip install --upgrade pip
# Install test dependencies
pip install pytest pytest-cov pytest-benchmark coverage
# Install project with optional dependencies for comprehensive testing
pip install -e .[all]
- name: Run fast tests
run: |
pytest tests/ -v -m "not slow and not benchmark" --cov=robodm --cov-report=xml --cov-report=term-missing
- name: Run slow tests (Ubuntu only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
run: |
pytest tests/ -v -m "slow" --cov=robodm --cov-append --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
fail_ci_if_error: false
verbose: true
benchmark:
name: Benchmark Tests
runs-on: ubuntu-latest
needs: tests
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Install project with all dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-benchmark
pip install -e .[all]
- name: Run benchmark tests
run: |
pytest tests/ -v -m "benchmark" --benchmark-only --benchmark-json=benchmark.json
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
if: always()
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: false