Skip to content

Commit

Permalink
test: add pytest setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Dec 28, 2022
1 parent 4a963c5 commit d6bba57
Show file tree
Hide file tree
Showing 15 changed files with 532 additions and 5 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@ on:
- main
- beta
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: "pip install poetry==${{ env.POETRY_VERSION }}"
- run: "poetry run pytest"
release:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- uses: cihelper/action-semanticrelease-poetry@v1
id: semanticrelease
with:
poetry-version: "1.3.1"
python-version: "3.9"
poetry-version: ${{ env.POETRY_VERSION }}
python-version: ${{ env.PYTHON_VERSION }}
pypi-token: ${{ secrets.PYPI_TOKEN }}
- uses: cihelper/action-docker-publish@v1
if: ${{ steps.semanticrelease.outputs.released == 'true' }}
Expand Down
1 change: 1 addition & 0 deletions makejinja/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .cli import run as run
5 changes: 3 additions & 2 deletions makejinja/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from types import ModuleType
from uuid import uuid1 as uuid

import dtyper
import typer
import yaml
from jinja2 import Environment, FileSystemLoader
Expand Down Expand Up @@ -48,6 +49,7 @@ def collect_files(paths: t.Iterable[Path], pattern: str = "**/*") -> t.List[Path
return files


@dtyper.function
@app.command()
def run(
input_folder: Path = typer.Argument(
Expand All @@ -63,7 +65,6 @@ def run(
),
output_folder: Path = typer.Argument(
...,
exists=True,
file_okay=False,
dir_okay=True,
readable=True,
Expand Down Expand Up @@ -229,7 +230,7 @@ def run(
shutil.rmtree(output_folder)

if copy_tree:
print(f"Copy file tree to '{output_folder}'")
print(f"Copy file tree '{input_folder}' -> '{output_folder}'")
shutil.copytree(input_folder, output_folder)

output_folder.mkdir(parents=True, exist_ok=True)
Expand Down
213 changes: 212 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ jinja2 = "^3.1.2"
typer = "^0.7.0"
rich = "^12.6.0"
pyyaml = "^6.0"
dtyper = "^2.0.3"

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.0"
pytest-cov = "^4.0.0"

[tool.pytest.ini_options]
addopts = "--cov makejinja --cov-report term-missing -vv"

[build-system]
requires = ["poetry-core"]
Expand Down
Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/data/baseline/ui-lovelace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: Overview
views: !include_dir_merge_list views
Loading

0 comments on commit d6bba57

Please sign in to comment.