-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_multiple.py
49 lines (32 loc) · 1.34 KB
/
test_multiple.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
Run tests for multiple Python versions.
"""
import anyio
import dagger
from rich.console import Console
console = Console()
async def test(repo_url: str):
versions = ["3.7", "3.8", "3.9", "3.10", "3.11"]
with console.status("Connecting to engine...") as status:
async with dagger.Connection() as client:
repo = client.git(repo_url).branch("master").tree()
for version in versions:
console.log(f"Starting tests for Python {version}")
status.update(f"Testing Python {version}")
python = (
client.container()
.from_(f"python:{version}-slim-buster")
# mount cloned repository into image
.with_mounted_directory("/src", repo)
# set current working directory for next commands
.with_workdir("/src")
# install test dependencies
.with_exec(["pip", "install", "-e", ".[test]"])
# run tests
.with_exec(["pytest", "tests"])
)
# execute
await python.exit_code()
console.print("All tests succeeded ✓", style="bold green")
# Using the popular FastAPI library as an example
anyio.run(test, "https://github.com/tiangolo/fastapi")