Skip to content

Commit

Permalink
update naming and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
d33bs committed Jan 8, 2024
1 parent 3fb9f37 commit 43eef00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/pymaccounter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
__init__.py for pymaccounter
"""

from .runner import run_test
from .runner import pipeline_run_tests
13 changes: 8 additions & 5 deletions src/pymaccounter/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import dagger


async def test(
async def pipeline_run_tests(
tests_to_run: List[str], test_dir: str = "src/pymaccounter/tests"
) -> None:
"""
Expand All @@ -22,19 +22,21 @@ async def test(
# get reference to the local project
dockerfile_dir = client.host().directory(".")

async def test_version(test_to_run: str, test_dir: str):
async def run_test(test_to_run: str, test_dir: str):
""" """
full_test_to_run = f"{test_dir}/{test_to_run}"

# build a python container based on Dockerfile and run test
python = (
client.container(
# explicitly set the container to be a certain platform type
platform=dagger.Platform("linux/amd64")
)
.build(
).build(
context=dockerfile_dir,
# uses a dockerfile to create the container
dockerfile="./src/pymaccounter/Dockerfile",
)
# run the python test through a poetry environment
.with_exec(["poetry", "run", "python", full_test_to_run])
)

Expand All @@ -44,7 +46,8 @@ async def test_version(test_to_run: str, test_dir: str):

# when this block exits, all tasks will be awaited (i.e., executed)
async with anyio.create_task_group() as tg:
# run each test provided individually
for test_to_run in tests_to_run:
tg.start_soon(test_version, test_to_run, test_dir)
tg.start_soon(run_test, test_to_run, test_dir)

print("All tests have finished")
9 changes: 5 additions & 4 deletions src/pymaccounter/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import anyio
import fire

from pymaccounter.pipeline import test
from pymaccounter.pipeline import pipeline_run_tests


def run_test(tests_to_run: List[str]) -> None:
def run_tests(tests_to_run: List[str]) -> None:
"""
Helper function to run dagger testing pipeline
"""

anyio.run(test, tests_to_run)
anyio.run(pipeline_run_tests, tests_to_run)


if __name__ == "__main__":
fire.Fire(run_test)
# creats a CLI through Python Fire for run_test
fire.Fire(run_tests)

0 comments on commit 43eef00

Please sign in to comment.