-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (117 loc) · 4 KB
/
Copy pathci.yml
File metadata and controls
140 lines (117 loc) · 4 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: build
on:
push:
branches: [main]
paths: ['**.py', 'pyproject.toml', '.github/workflows/**']
pull_request:
branches: [main]
paths: ['**.py', 'pyproject.toml', '.github/workflows/**']
workflow_dispatch:
permissions:
contents: write
pull-requests: write
issues: write
jobs:
lint:
name: Lint and Format
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 dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-3.10-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
python-3.10-pip-
- name: Install Poetry and Dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry install --no-interaction
- name: Run Linters
continue-on-error: true
run: |
poetry run ruff check . --fix --unsafe-fixes
poetry run ruff format .
poetry run black .
poetry run isort .
poetry run flake8 .
poetry run bandit -r . --quiet
poetry run pylint mujoco_toolbox/
- name: Run Type Checking with MyPy
continue-on-error: true
run: |
poetry run mypy .
- name: Commit Fixes if Needed
if: github.event_name == 'pull_request'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin
git checkout "${{ github.head_ref }}"
git add .
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -m "chore: auto-fix code quality issues [skip ci]"
# Rebase to avoid merge conflicts
git pull --rebase origin "${{ github.head_ref }}"
# Push with token
git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" HEAD:"${{ github.head_ref }}"
fi
test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
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 dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ matrix.python-version }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
python-${{ matrix.python-version }}-pip-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libosmesa6-dev \
xvfb \
libglew-dev \
patchelf \
ffmpeg
- name: Set Mujoco environment variables
run: |
echo "MUJOCO_GL=osmesa" >> $GITHUB_ENV
echo "PYOPENGL_PLATFORM=osmesa" >> $GITHUB_ENV
- name: Install Poetry and Dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry install --no-interaction
- name: Run Tests
run: |
poetry run pip install pytest pytest-cov
poetry run pytest tests/ --cov=mujoco_toolbox --cov-report=xml --maxfail=3 -v
# Uncomment below if using codecov
# - name: Upload Coverage Report
# uses: codecov/codecov-action@v5
# with:
# fail_ci_if_error: true