b009e1ff08
Validate Operations / validate-operations (push) Has been cancelled
normalize names and artifact paths
34 lines
859 B
Python
34 lines
859 B
Python
from pathlib import Path
|
|
|
|
|
|
ARTIFACTS_DIRNAME = "artifacts"
|
|
|
|
|
|
def artifacts_dir(workspace_dir: str | Path) -> Path:
|
|
return Path(workspace_dir) / ARTIFACTS_DIRNAME
|
|
|
|
|
|
def runner_uses_library(runner_path: str | Path, library_path: str | Path) -> bool:
|
|
runner_path = Path(runner_path)
|
|
library_path = Path(library_path)
|
|
try:
|
|
return (
|
|
runner_path.is_file()
|
|
and library_path.is_file()
|
|
and str(library_path.resolve()).encode() in runner_path.read_bytes()
|
|
)
|
|
except OSError:
|
|
return False
|
|
|
|
|
|
def remove_lock_files(root: str | Path) -> int:
|
|
root = Path(root)
|
|
if not root.exists():
|
|
return 0
|
|
removed = 0
|
|
for path in root.rglob("*.lock"):
|
|
if path.is_file() or path.is_symlink():
|
|
path.unlink(missing_ok=True)
|
|
removed += 1
|
|
return removed
|