Skip to content

Commit 37dd10a

Browse files
authored
Merge pull request #26 from BerkeleyAutomation/dev/refactor
Dev/refactor
2 parents b1f4ef8 + 2771129 commit 37dd10a

32 files changed

Lines changed: 673 additions & 448 deletions

.github/rename_project.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,42 @@ name: Lint
33
on:
44
push:
55
paths:
6-
- '*.py'
6+
- '**.py'
7+
- '**/pyproject.toml'
8+
- '**/pytest.ini'
9+
pull_request:
10+
paths:
11+
- '**.py'
12+
- '**/pyproject.toml'
13+
- '**/pytest.ini'
714

815
jobs:
916
mypy:
17+
name: MyPy Type Check
1018
runs-on: ubuntu-latest
1119
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
1223
- name: Setup Python
1324
uses: actions/setup-python@v5
1425
with:
15-
python-version: 3.7.4
16-
architecture: x64
17-
- name: Checkout
18-
uses: actions/checkout@v4
19-
- name: Install mypy
20-
run: pip install mypy
21-
- name: Run mypy
22-
uses: sasanquaneuf/mypy-github-action@releases/v1
26+
python-version: '3.10'
27+
28+
- name: Cache pip packages
29+
uses: actions/cache@v4
2330
with:
24-
checkName: 'mypy' # NOTE: this needs to be the same as the job name
25-
env:
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
path: ~/.cache/pip
32+
key: ${{ runner.os }}-pip-mypy-${{ hashFiles('**/pyproject.toml') }}
33+
restore-keys: |
34+
${{ runner.os }}-pip-mypy-
35+
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install mypy
40+
pip install -e .
41+
42+
- name: Run mypy
43+
run: |
44+
mypy robodm --ignore-missing-imports --check-untyped-defs --show-error-codes --pretty

.github/workflows/main.yml

Lines changed: 168 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,198 @@ name: CI
66
on:
77
# Triggers the workflow on push or pull request events but only for the main branch
88
push:
9-
branches: [ main ]
9+
branches: [ main, master ]
1010
pull_request:
11-
branches: [ main ]
11+
branches: [ main, master ]
1212

1313
# Allows you to run this workflow manually from the Actions tab
1414
workflow_dispatch:
1515

16+
env:
17+
PYTHONPATH: ${{ github.workspace }}
18+
1619
jobs:
20+
format-check:
21+
name: Format Check
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.10'
30+
31+
- name: Cache pip packages
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.cache/pip
35+
key: ${{ runner.os }}-pip-format-${{ hashFiles('**/pyproject.toml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pip-format-
38+
39+
- name: Install formatting tools
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install yapf black isort mypy pylint flake8
43+
44+
- name: Run format check
45+
run: |
46+
bash format.sh --all
47+
48+
- name: Check for formatting changes
49+
run: |
50+
if ! git diff --quiet; then
51+
echo "Code formatting issues detected. Please run 'bash format.sh --all' locally."
52+
git diff
53+
exit 1
54+
fi
55+
1756
linter:
57+
name: Lint
58+
runs-on: ubuntu-latest
59+
needs: format-check
1860
strategy:
1961
fail-fast: false
2062
matrix:
21-
python-version: [3.9]
22-
os: [ubuntu-latest]
23-
runs-on: ${{ matrix.os }}
63+
python-version: ['3.10', '3.11', '3.12']
2464
steps:
2565
- uses: actions/checkout@v4
26-
- uses: actions/setup-python@v5
66+
67+
- name: Set up Python ${{ matrix.python-version }}
68+
uses: actions/setup-python@v5
2769
with:
2870
python-version: ${{ matrix.python-version }}
71+
72+
- name: Cache pip packages
73+
uses: actions/cache@v4
74+
with:
75+
path: ~/.cache/pip
76+
key: ${{ runner.os }}-pip-lint-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
77+
restore-keys: |
78+
${{ runner.os }}-pip-lint-${{ matrix.python-version }}-
79+
2980
- name: Install project
30-
run: make install
81+
run: |
82+
python -m pip install --upgrade pip
83+
# Install test dependencies
84+
pip install pytest pytest-cov flake8 black mypy isort yapf pylint
85+
# Install project in editable mode
86+
pip install -e .
87+
3188
- name: Run linter
3289
run: make lint
3390

34-
tests_linux:
91+
tests:
92+
name: Tests
93+
runs-on: ${{ matrix.os }}
3594
needs: linter
3695
strategy:
3796
fail-fast: false
3897
matrix:
39-
python-version: [3.9]
40-
os: [ubuntu-latest]
41-
runs-on: ${{ matrix.os }}
98+
os: [ubuntu-latest, macos-latest, windows-latest]
99+
python-version: ['3.10', '3.11', '3.12']
100+
exclude:
101+
# Reduce CI load by testing fewer combinations on non-Ubuntu
102+
- os: macos-latest
103+
python-version: '3.11'
104+
- os: windows-latest
105+
python-version: '3.11'
42106
steps:
43107
- uses: actions/checkout@v4
44-
- uses: actions/setup-python@v5
108+
109+
- name: Set up Python ${{ matrix.python-version }}
110+
uses: actions/setup-python@v5
45111
with:
46112
python-version: ${{ matrix.python-version }}
47-
- name: Install project
48-
run: make install
49-
- name: Run tests
50-
run: make test
51-
- name: "Upload coverage to Codecov"
113+
114+
- name: Cache pip packages
115+
uses: actions/cache@v4
116+
with:
117+
path: ~/.cache/pip
118+
key: ${{ runner.os }}-pip-test-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
119+
restore-keys: |
120+
${{ runner.os }}-pip-test-${{ matrix.python-version }}-
121+
122+
- name: Install system dependencies (Ubuntu)
123+
if: matrix.os == 'ubuntu-latest'
124+
run: |
125+
sudo apt-get update
126+
sudo apt-get install -y ffmpeg
127+
128+
- name: Install system dependencies (macOS)
129+
if: matrix.os == 'macos-latest'
130+
run: |
131+
brew install ffmpeg
132+
133+
- name: Install system dependencies (Windows)
134+
if: matrix.os == 'windows-latest'
135+
shell: powershell
136+
run: |
137+
# Install ffmpeg via chocolatey
138+
choco install ffmpeg -y
139+
140+
- name: Install project with test dependencies
141+
run: |
142+
python -m pip install --upgrade pip
143+
# Install test dependencies
144+
pip install pytest pytest-cov pytest-benchmark coverage
145+
# Install project with optional dependencies for comprehensive testing
146+
pip install -e .[all]
147+
148+
- name: Run fast tests
149+
run: |
150+
pytest tests/ -v -m "not slow and not benchmark" --cov=robodm --cov-report=xml --cov-report=term-missing
151+
152+
- name: Run slow tests (Ubuntu only)
153+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
154+
run: |
155+
pytest tests/ -v -m "slow" --cov=robodm --cov-append --cov-report=xml
156+
157+
- name: Upload coverage to Codecov
158+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
52159
uses: codecov/codecov-action@v4
53-
# with:
54-
# fail_ci_if_error: true
160+
with:
161+
file: ./coverage.xml
162+
fail_ci_if_error: false
163+
verbose: true
164+
165+
benchmark:
166+
name: Benchmark Tests
167+
runs-on: ubuntu-latest
168+
needs: tests
169+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
170+
steps:
171+
- uses: actions/checkout@v4
172+
173+
- name: Set up Python
174+
uses: actions/setup-python@v5
175+
with:
176+
python-version: '3.10'
177+
178+
- name: Install system dependencies
179+
run: |
180+
sudo apt-get update
181+
sudo apt-get install -y ffmpeg
182+
183+
- name: Install project with all dependencies
184+
run: |
185+
python -m pip install --upgrade pip
186+
pip install pytest pytest-benchmark
187+
pip install -e .[all]
188+
189+
- name: Run benchmark tests
190+
run: |
191+
pytest tests/ -v -m "benchmark" --benchmark-only --benchmark-json=benchmark.json
192+
193+
- name: Store benchmark result
194+
uses: benchmark-action/github-action-benchmark@v1
195+
if: always()
196+
with:
197+
tool: 'pytest'
198+
output-file-path: benchmark.json
199+
github-token: ${{ secrets.GITHUB_TOKEN }}
200+
auto-push: true
201+
comment-on-alert: true
202+
alert-threshold: '200%'
203+
fail-on-alert: false

0 commit comments

Comments
 (0)