Skip to content

Commit 468ed67

Browse files
committed
fix: resolve CI test failures and improve code quality
- Fix test coverage configuration issues - Update codecov.yml with better coverage settings - Improve .coveragerc with relative_files and better exclusions - Add missing coverage report options to nox pytest session - Add Python 3.13 support - Update GitHub Actions matrix to include Python 3.13 - Add Python 3.11, 3.12, 3.13 classifiers to pyproject.toml - Update .travis.yml with Python 3.13 - Expand CI test matrix - Add ubuntu-latest and macos-latest to GitHub Actions - Add test step to run pytest after lint checks - Fix import sorting issues - Correct maya_umbrella._vendor import placement in vaccine4.py - Ensure consistent import ordering across codebase - Improve code quality checks - Add ruff_check and isort_check nox sessions - Fix quote style issues (single -> double quotes) - Update type annotations (Tuple -> tuple) - Remove deprecated typing.Tuple import - Replace virus file dependencies with mocks - Remove virus test files from git tracking - Add tests/virus/*.ma and tests/virus/*.mb to .gitignore - Create mock virus files in conftest.py for testing - Update test_defender.py to use mock virus files - Add test_defender_mocked.py with completely mocked tests - Update test_scanner.py to use mocks instead of real files - Update manual_test_in_maya.py to create temporary mock files - Remove unused imports and fix code style issues - Add Docker integration testing infrastructure (CI-only) - Add Docker-based integration tests using mottosso/maya images - Create test_docker_integration.py with comprehensive Maya environment tests - Add GitHub Actions workflow for Docker testing - Add docker-compose.test.yml for multi-version testing - Add scripts/docker_test_setup.py for Docker test management - Configure pytest to skip Docker tests locally (CI-only) - Add nox docker-test session with CI environment detection - Add comprehensive documentation in docs/docker-testing.md - All tests now pass (58/58) with 72% coverage, 8 Docker tests skipped locally - All lint checks now pass (isort, ruff) - No real virus files in repository, safer for distribution - Docker tests provide real Maya environment validation in CI Signed-off-by: longhao <[email protected]>
1 parent 31f2a12 commit 468ed67

27 files changed

+1296
-848758
lines changed

.coveragerc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
[run]
22
branch = True
33
source = maya_umbrella
4+
relative_files = true
45

56
[report]
67
exclude_lines =
78
if self.debug:
89
pragma: no cover
910
raise NotImplementedError
1011
if __name__ == .__main__.:
12+
def __repr__
13+
if TYPE_CHECKING:
14+
@abstract
1115
ignore_errors = True
1216
omit =
1317
tests/*
1418
maya_umbrella/_vendor/*
1519
maya_umbrella/maya_funs.py
20+
maya_umbrella/hooks/*
21+
22+
[xml]
23+
output = coverage.xml
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Docker Integration Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch: # Allow manual triggering
9+
10+
jobs:
11+
docker-integration-test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
maya-version: ["2022"] # Start with 2022, add others as needed
16+
fail-fast: false
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.9' # Compatible with Maya 2022
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install pytest pytest-cov
30+
31+
- name: Check Docker
32+
run: |
33+
docker --version
34+
docker info
35+
36+
- name: Pull Maya Docker image
37+
run: |
38+
echo "Pulling Maya ${{ matrix.maya-version }} Docker image..."
39+
docker pull mottosso/maya:${{ matrix.maya-version }}
40+
docker images mottosso/maya
41+
42+
- name: Prepare test environment
43+
run: |
44+
# Create necessary directories
45+
mkdir -p test-results
46+
47+
# Set permissions for Docker volume mounting
48+
chmod -R 755 .
49+
50+
- name: Run Docker integration tests
51+
run: |
52+
docker run --rm \
53+
-v ${{ github.workspace }}:/workspace \
54+
-w /workspace \
55+
-e PYTHONPATH=/workspace \
56+
-e MAYA_DISABLE_CIP=1 \
57+
-e MAYA_DISABLE_CER=1 \
58+
mottosso/maya:${{ matrix.maya-version }} \
59+
python -m pytest tests/test_docker_integration.py -v -m docker --tb=short
60+
61+
- name: Test basic Maya functionality
62+
run: |
63+
docker run --rm \
64+
-v ${{ github.workspace }}:/workspace \
65+
-w /workspace \
66+
-e PYTHONPATH=/workspace \
67+
-e MAYA_DISABLE_CIP=1 \
68+
-e MAYA_DISABLE_CER=1 \
69+
mottosso/maya:${{ matrix.maya-version }} \
70+
mayapy -c "
71+
import maya.standalone
72+
maya.standalone.initialize()
73+
import maya.cmds as cmds
74+
print('Maya version:', cmds.about(version=True))
75+
print('Maya build:', cmds.about(buildDirectory=True))
76+
maya.standalone.uninitialize()
77+
print('SUCCESS: Basic Maya test completed')
78+
"
79+
80+
- name: Test Maya Umbrella import
81+
run: |
82+
docker run --rm \
83+
-v ${{ github.workspace }}:/workspace \
84+
-w /workspace \
85+
-e PYTHONPATH=/workspace \
86+
-e MAYA_DISABLE_CIP=1 \
87+
-e MAYA_DISABLE_CER=1 \
88+
mottosso/maya:${{ matrix.maya-version }} \
89+
mayapy -c "
90+
import sys
91+
sys.path.insert(0, '/workspace')
92+
import maya.standalone
93+
maya.standalone.initialize()
94+
95+
try:
96+
from maya_umbrella import MayaVirusDefender, MayaVirusScanner
97+
from maya_umbrella.vaccines import get_all_vaccines
98+
print('SUCCESS: Maya Umbrella imported successfully')
99+
print(f'Available vaccines: {len(get_all_vaccines())}')
100+
except Exception as e:
101+
print(f'ERROR: {e}')
102+
import traceback
103+
traceback.print_exc()
104+
sys.exit(1)
105+
finally:
106+
maya.standalone.uninitialize()
107+
"
108+
109+
- name: Upload test results
110+
uses: actions/upload-artifact@v3
111+
if: always()
112+
with:
113+
name: docker-test-results-maya-${{ matrix.maya-version }}
114+
path: test-results/
115+
retention-days: 7
116+
117+
docker-integration-test-extended:
118+
runs-on: ubuntu-latest
119+
if: github.event_name == 'workflow_dispatch' # Only run on manual trigger
120+
strategy:
121+
matrix:
122+
maya-version: ["2023", "2024"]
123+
fail-fast: false
124+
125+
steps:
126+
- uses: actions/checkout@v4
127+
128+
- name: Set up Python
129+
uses: actions/setup-python@v4
130+
with:
131+
python-version: '3.9'
132+
133+
- name: Install dependencies
134+
run: |
135+
python -m pip install --upgrade pip
136+
pip install pytest pytest-cov
137+
138+
- name: Pull Maya Docker image
139+
run: |
140+
echo "Pulling Maya ${{ matrix.maya-version }} Docker image..."
141+
docker pull mottosso/maya:${{ matrix.maya-version }} || echo "Image not available"
142+
143+
- name: Run extended tests (if image available)
144+
run: |
145+
if docker images -q mottosso/maya:${{ matrix.maya-version }} | grep -q .; then
146+
echo "Running tests with Maya ${{ matrix.maya-version }}"
147+
docker run --rm \
148+
-v ${{ github.workspace }}:/workspace \
149+
-w /workspace \
150+
-e PYTHONPATH=/workspace \
151+
-e MAYA_DISABLE_CIP=1 \
152+
-e MAYA_DISABLE_CER=1 \
153+
mottosso/maya:${{ matrix.maya-version }} \
154+
python -m pytest tests/test_docker_integration.py -v -m docker --tb=short
155+
else
156+
echo "Maya ${{ matrix.maya-version }} image not available, skipping"
157+
fi

.github/workflows/mr-test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ jobs:
77
strategy:
88
max-parallel: 3
99
matrix:
10-
os: [ 'windows-2022' ]
11-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
10+
os: [ 'windows-2022', 'ubuntu-latest', 'macos-latest' ]
11+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
1212
fail-fast: false
1313
steps:
1414
- name: Checkout
@@ -24,3 +24,6 @@ jobs:
2424
- name: lint
2525
run: |
2626
nox -s lint
27+
- name: test
28+
run: |
29+
nox -s pytest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ run_pycharm.bat
3030
coverage.xml
3131
.zip
3232
tests/virus/_virus/
33+
tests/virus/*.ma
34+
tests/virus/*.mb
3335
__pycache__/
3436
.ruff_cache
3537
.venv/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ python:
55
- "3.10"
66
- "3.11"
77
- "3.12"
8+
- "3.13"
89
before_script:
910
- pip install poetry
1011
- poetry install

codecov.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
coverage:
22
status:
33
project: off
4+
range: 50..100
45

56
github_checks:
67
annotations: false
78

89
ignore:
910
- "maya_umbrella/hooks"
1011
- "noxfile.py"
12+
- "maya_umbrella/_vendor/*"
13+
- "tests/*"
14+
15+
comment:
16+
layout: "reach,diff,flags,tree"
17+
behavior: default
18+
require_changes: false

docker-compose.test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: '3.8'
2+
3+
services:
4+
maya-test:
5+
image: mottosso/maya:2022
6+
volumes:
7+
- .:/workspace
8+
- ./tests:/workspace/tests
9+
working_dir: /workspace
10+
environment:
11+
- PYTHONPATH=/workspace
12+
- MAYA_DISABLE_CIP=1
13+
- MAYA_DISABLE_CER=1
14+
command: tail -f /dev/null # Keep container running for interactive testing
15+
16+
maya-2023-test:
17+
image: mottosso/maya:2023
18+
volumes:
19+
- .:/workspace
20+
- ./tests:/workspace/tests
21+
working_dir: /workspace
22+
environment:
23+
- PYTHONPATH=/workspace
24+
- MAYA_DISABLE_CIP=1
25+
- MAYA_DISABLE_CER=1
26+
command: tail -f /dev/null
27+
profiles:
28+
- maya2023 # Only start with --profile maya2023
29+
30+
maya-2024-test:
31+
image: mottosso/maya:2024
32+
volumes:
33+
- .:/workspace
34+
- ./tests:/workspace/tests
35+
working_dir: /workspace
36+
environment:
37+
- PYTHONPATH=/workspace
38+
- MAYA_DISABLE_CIP=1
39+
- MAYA_DISABLE_CER=1
40+
command: tail -f /dev/null
41+
profiles:
42+
- maya2024 # Only start with --profile maya2024

0 commit comments

Comments
 (0)