-
Notifications
You must be signed in to change notification settings - Fork 1
172 lines (146 loc) · 6.07 KB
/
Copy pathtest.yml
File metadata and controls
172 lines (146 loc) · 6.07 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
name: Tests
on:
push:
paths:
- '**.py'
- 'pyproject.toml'
- 'uv.lock'
pull_request:
paths:
- '**.py'
- 'pyproject.toml'
- 'uv.lock'
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies (bare package, no optional extras)
run: uv sync --dev
- name: Install Xvfb and GL libs (Linux only - needed for sprite/display tests)
if: matrix.os == 'ubuntu-latest'
env:
DISPLAY: ':99.0'
run: |
sudo apt-get update -y
sudo apt-get install -y xvfb x11-utils libxkbcommon-x11-0 libgl1 libglu1-mesa mesa-utils
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX
- name: Run unit tests (Linux - excludes tests requiring optional dependencies)
if: matrix.os == 'ubuntu-latest'
env:
DISPLAY: ':99.0'
LIBGL_ALWAYS_SOFTWARE: '1'
run: uv run pytest tests/ -v --tb=short --ignore=tests/integration
- name: Run unit tests (Windows/macOS - excludes tests requiring optional dependencies)
if: matrix.os != 'ubuntu-latest'
run: uv run pytest tests/ -v --tb=short --ignore=tests/integration
- name: Install statemachine extra for examples (Linux Python 3.11 only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
run: uv sync --extra statemachine --dev
- name: Smoke test examples (Linux Python 3.11 only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
env:
DISPLAY: ':99.0'
LIBGL_ALWAYS_SOFTWARE: '1'
run: |
for f in examples/*.py; do
echo "Running $f for 5s"
set +e
timeout 5s uv run python "$f"
rc=$?
set -e
if [ $rc -eq 124 ]; then
echo "OK: $f ran and timed out after 5s as expected"
elif [ $rc -eq 0 ]; then
echo "OK: $f exited cleanly within 5s"
else
echo "FAIL: $f exited with $rc"
exit $rc
fi
done
- name: Run tests with coverage (Linux Python 3.11 only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
env:
DISPLAY: ':99.0'
LIBGL_ALWAYS_SOFTWARE: '1'
run: CI=true uv run pytest tests/ --cov=arcadeactions --cov-fail-under=90 --cov-report=xml --cov-report=json:coverage.json --cov-report=term-missing
- name: Report diff coverage (Linux Python 3.11 PRs, informational)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && github.event_name == 'pull_request'
run: uv run diff-cover coverage.xml --compare-branch=origin/${{ github.base_ref }}
- name: Collect Radon metrics (Linux Python 3.11 only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
run: |
uv run radon raw -j arcadeactions > radon_raw.json
uv run radon cc -j arcadeactions > radon_cc.json
- name: Generate refactoring priority report (Linux Python 3.11 only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
run: |
uv run python tools/refactor_priority.py \
--radon-raw radon_raw.json \
--radon-cc radon_cc.json \
--coverage-json coverage.json \
--min-sloc 100 \
--top 30 \
--output refactor-priority-report.md
- name: Upload refactoring priority report (Linux Python 3.11 only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: actions/upload-artifact@v7
with:
name: refactor-priority-report
path: refactor-priority-report.md
retention-days: 30
- name: Upload coverage to Codecov (Linux Python 3.11 only)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v7
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
test-optional-deps:
name: Tests requiring optional dependencies
runs-on: ubuntu-latest
# Note: tests/integration/ contains tests that require optional dependencies
# (like python-statemachine). These are excluded from the main test run
# because they need extras installed.
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
- name: Set up Python 3.12
run: uv python install 3.12
- name: Install dependencies with statemachine extra
run: uv sync --extra statemachine --dev
- name: Install Xvfb and GL libs (needed for sprite/display tests)
env:
DISPLAY: ':99.0'
run: |
sudo apt-get update -y
sudo apt-get install -y xvfb x11-utils libxkbcommon-x11-0 libgl1 libglu1-mesa mesa-utils
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX
- name: Run tests requiring optional dependencies
env:
DISPLAY: ':99.0'
LIBGL_ALWAYS_SOFTWARE: '1'
run: uv run pytest tests/integration/ -v --tb=short
- name: Run full test suite to ensure no regressions
env:
DISPLAY: ':99.0'
LIBGL_ALWAYS_SOFTWARE: '1'
run: uv run pytest tests/ -v --tb=short