Skip to content

Commit 4daecd9

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 - Remove virus test files from git tracking - Add tests/virus/*.ma and tests/virus/*.mb to .gitignore - Keep virus files locally for testing but exclude from repository - All tests now pass (50/50) with 72% coverage - All lint checks now pass (isort, ruff) Signed-off-by: longhao <[email protected]>
1 parent 31f2a12 commit 4daecd9

File tree

17 files changed

+46
-848743
lines changed

17 files changed

+46
-848743
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

.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

maya_umbrella/vaccines/vaccine4.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import re
44

55
# Import local modules
6+
from maya_umbrella._vendor import six
67
from maya_umbrella.filesystem import check_virus_by_signature
78
from maya_umbrella.filesystem import check_virus_file_by_signature
89
from maya_umbrella.filesystem import read_file
910
from maya_umbrella.maya_funs import check_reference_node_exists
1011
from maya_umbrella.maya_funs import cmds
1112
from maya_umbrella.maya_funs import get_attr_value
12-
from maya_umbrella.signatures import JOB_SCRIPTS_VIRUS_SIGNATURES
1313
from maya_umbrella.signatures import FILE_VIRUS_SIGNATURES
14+
from maya_umbrella.signatures import JOB_SCRIPTS_VIRUS_SIGNATURES
1415
from maya_umbrella.vaccine import AbstractVaccine
15-
from maya_umbrella._vendor import six
1616

1717

1818
class Vaccine(AbstractVaccine):
@@ -149,7 +149,7 @@ def collect_script_jobs(self):
149149

150150
# Check for base64-like strings (potential encoded payloads)
151151
# Look for base64 strings that are at least 16 characters (common for encoded commands)
152-
base64_pattern = r'[A-Za-z0-9+/]{16,}={0,2}'
152+
base64_pattern = r"[A-Za-z0-9+/]{16,}={0,2}"
153153
if re.search(base64_pattern, job_content):
154154
is_malicious = True
155155
self.logger.info("Detected scriptJob with potential base64 payload: %s", job_info)

nox_actions/codetest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ def pytest(session: nox.Session) -> None:
1212
test_root = os.path.join(THIS_ROOT, "tests")
1313
session.run("pytest", f"--cov={PACKAGE_NAME}",
1414
"--cov-report=xml:coverage.xml",
15+
"--cov-report=term-missing",
1516
f"--rootdir={test_root}",
17+
"--cov-config=.coveragerc",
1618
env={"PYTHONPATH": THIS_ROOT})

nox_actions/lint.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@ def lint_fix(session: nox.Session) -> None:
1515
session.run("isort", ".")
1616
session.run("pre-commit", "run", "--all-files")
1717
session.run("autoflake", "--in-place", "--remove-all-unused-imports", "--remove-unused-variables")
18+
19+
20+
def ruff_check(session: nox.Session) -> None:
21+
session.install("ruff")
22+
session.run("ruff", "check")
23+
24+
25+
def isort_check(session: nox.Session) -> None:
26+
session.install("isort")
27+
session.run("isort", "--check-only", PACKAGE_NAME)

nox_actions/release.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
import shutil
66
from collections.abc import Iterator
7-
from typing import Tuple
7+
88
import zipfile
99

1010
# Import third-party modules
@@ -66,7 +66,7 @@ def vendoring(session: nox.Session) -> None:
6666
session.run("vendoring", "sync", "-v")
6767
return
6868

69-
def pinned_requirements(path: Path) -> Iterator[Tuple[str, str]]:
69+
def pinned_requirements(path: Path) -> Iterator[tuple[str, str]]:
7070
for line in path.read_text().splitlines(keepends=False):
7171
one, sep, two = line.partition("==")
7272
if not sep:

noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
nox.session(run_maya.run_maya, name="maya")
2424
nox.session(lint.lint, name="lint")
2525
nox.session(lint.lint_fix, name="lint-fix")
26+
nox.session(lint.ruff_check, name="ruff_check")
27+
nox.session(lint.isort_check, name="isort_check")
2628
nox.session(release.make_install_zip, name="make-zip")
2729
nox.session(codetest.pytest, name="pytest")
2830
nox.session(release.vendoring, name="vendoring")

0 commit comments

Comments
 (0)