from pathlib import Path

import modal

ROOT_PATH = Path(__file__).parent

image = (
    modal.Image.debian_slim()
    .pip_install("pytest")
    .pip_install_from_pyproject("pyproject.toml")
    .apt_install("ffmpeg")
    .add_local_dir(ROOT_PATH, remote_path="/root")
)
app = modal.App(name="songify-ci-testing", image=image)

@app.function(
    secrets=[
        modal.Secret.from_name("aws-bucket"),
        modal.Secret.from_name("jason-backend-api-key"),
    ]
)
def pytest():
    import subprocess
    subprocess.run(["pytest", "-vs"], check=True, cwd="/root")

