diff --git a/Makefile b/Makefile index 38c3bd6..eb6a230 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,7 @@ build: upload: hatch publish release: - hatch clean && hatch build && hatch publish \ No newline at end of file + hatch clean && hatch build && hatch publish +# Build the tox docker image, use docker run -v "$(pwd)":"/code" jekyll-to-hugo-tox -e ci to run tox +build-tox: + docker build . -f ./docker/Tox.Dockerfile -t jekyll-to-hugo-tox \ No newline at end of file diff --git a/app/io/writer.py b/app/io/writer.py index f7065f9..83d54d1 100644 --- a/app/io/writer.py +++ b/app/io/writer.py @@ -38,7 +38,7 @@ class FileWriter(IoWriter): fo.write(data) -class TestingWriter(IoWriter): +class MockWriter(IoWriter): """ Writes a post to a string. """ diff --git a/app/tests/converter/wordpress_markdown_test.py b/app/tests/converter/wordpress_markdown_test.py index 97b1e56..f488ac3 100644 --- a/app/tests/converter/wordpress_markdown_test.py +++ b/app/tests/converter/wordpress_markdown_test.py @@ -3,7 +3,7 @@ import pytest from app.config import ConverterOptions from app.converter import WordpressMarkdownConverter from app.io.reader import StringReader -from app.io.writer import TestingWriter +from app.io.writer import MockWriter from app.tests.utils import make_fake_configurator @@ -183,6 +183,6 @@ def test_write_hugo_post(): ConverterOptions(), ) converter = WordpressMarkdownConverter(configurator) - writer = TestingWriter() + writer = MockWriter() converter.write_hugo_post(writer, {"title": "Test"}, "Test\nLine 2") assert writer.content == "---\ntitle: Test\n---\nTest\nLine 2" diff --git a/Dockerfile b/docker/Dockerfile similarity index 66% rename from Dockerfile rename to docker/Dockerfile index 4b2dad9..f28b277 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -2,11 +2,11 @@ FROM python:3.10-slim WORKDIR /app -COPY requirements.txt /app/requirements.txt +COPY ../requirements.txt /app/requirements.txt RUN pip install -r requirements.txt -COPY . /app +COPY .. /app ENTRYPOINT [ "python" ] CMD [ "main.py" ] \ No newline at end of file diff --git a/docker/Tox.Dockerfile b/docker/Tox.Dockerfile new file mode 100644 index 0000000..69c0b0a --- /dev/null +++ b/docker/Tox.Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt update && apt install -y software-properties-common \ + && add-apt-repository ppa:deadsnakes/ppa \ + && apt install -y python3.10 && apt install -y python3.11 \ + && apt install -y python3-pip && pip3 install tox + +VOLUME /code + +WORKDIR /code +ENTRYPOINT tox +CMD ["-e", "ci"] diff --git a/readme.md b/readme.md index 0004ef8..6a28ea0 100644 --- a/readme.md +++ b/readme.md @@ -59,7 +59,7 @@ If you don't have Python installed, you can use Docker: 1. Build the image. ```bash -docker build -t jekyll-to-hugo . +docker build -t jekyll-to-hugo -f ./docker/Dockerfile . ``` 2. Run the image. You will need to mount the following directories: config file, Jekyll posts directory, Hugo posts directory. diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..402e1a3 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +# content of: tox.ini , put in same dir as setup.py +[tox] +skip_missing_interpreters = True +envlist = py310,py311 + +[testenv] +# install pytest in the virtualenv where commands will be executed +deps = + pytest + pytest-cov +commands = + # NOTE: you can run any command line tool here – not just tests + pytest -p no:warnings + +[testenv:ci] +commands = + pytest —junitxml=results.xml \ + —cov=your-module—cov-config=tox.ini —cov-report=xml + coverage2clover -i coverage.xml -o clover.xml +deps = + {[testenv]deps} + coverage2clover \ No newline at end of file