Skip to content

Commit

Permalink
Decrease artifact retention and add timeout to rar command (#1221)
Browse files Browse the repository at this point in the history
* add timeout to subprocess.run for rar

* run ruff and mypy on scripts folder

* delete test-data artifact ASAP to reduce storage
  • Loading branch information
getzze authored Mar 6, 2025
1 parent c407c1c commit bce492e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ jobs:
path: tests/data/
include-hidden-files: false
if-no-files-found: error
# heavy artifact should be deleted asap
retention-days: 1

test:
name: Test
Expand Down
2 changes: 1 addition & 1 deletion hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dev-mode = false
features = ["tests", "types"]

[envs.types.scripts]
run = "mypy --install-types --non-interactive --ignore-missing-imports --config-file={root}/pyproject.toml {args:src tests}"
run = "mypy --install-types --non-interactive --ignore-missing-imports --config-file={root}/pyproject.toml {args:src tests scripts}"

# ---------------------------------------------------------
[envs.docs]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ relative_files = true
# https://docs.astral.sh/ruff/
[tool.ruff]
line-length = 120
src = ["src", "tests"]
src = ["src", "tests", "scripts"]
exclude = [
"_version.py",
]
Expand Down
8 changes: 7 additions & 1 deletion scripts/prepare_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ def compress_to_rar(rar_dir_path: str | os.PathLike[str], mkv: dict[str, str]) -
filename = os.fspath(rar_dir_path / (name + '.rar'))
if not os.path.exists(filename):
try:
subprocess.run(['rar', 'a', '-ep', filename, *existing_videos], check=True) # noqa: S603, S607
subprocess.run( # noqa: S603
['rar', 'a', '-ep', filename, *existing_videos], # noqa: S607
check=True,
timeout=30,
)
except subprocess.TimeoutExpired:
warnings.warn('`rar` command took too long', UserWarning, stacklevel=2)
except FileNotFoundError:
# rar command line is not installed
warnings.warn('rar is not installed', UserWarning, stacklevel=2)
Expand Down
8 changes: 7 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,13 @@ def rar(mkv: dict[str, str]) -> dict[str, str]:
filename = os.path.join(data_path, name + '.rar')
if not os.path.exists(filename):
try:
subprocess.run(['rar', 'a', '-ep', filename, *existing_videos], check=True)
subprocess.run(
['rar', 'a', '-ep', filename, *existing_videos],
check=True,
timeout=30,
)
except subprocess.TimeoutExpired:
print('`rar` command took too long') # noqa: T201
except FileNotFoundError:
# rar command line is not installed
print('rar is not installed') # noqa: T201
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ commands = {[testenv:tests]commands}
extras =
types
tests
commands = mypy --install-types --non-interactive {posargs:src tests}
commands = mypy --install-types --non-interactive {posargs:src tests scripts}


[testenv:coverage]
Expand Down

0 comments on commit bce492e

Please sign in to comment.