diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..79bc09d --- /dev/null +++ b/.coveragerc @@ -0,0 +1,17 @@ +[run] +source = image + +omit = + */dist/* + */containerimage_py.egg-info/* + */doc/* + */examples/* + */tests/* + */__pycache__/* + */.pytest_cache/* + */.git/* + */.github/* + */.tox/* + +[html] +directory = test-results/coverage diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index ea5a703..5357a4b 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -1,4 +1,4 @@ -name: doc +name: Doc on: [push, pull_request, workflow_dispatch] @@ -13,7 +13,7 @@ jobs: - uses: actions/setup-python@v5 - name: Install dependencies run: | - python3 -m pip install sphinx sphinx_rtd_theme myst_parser + make doc-dependencies - name: Documentation build run: | make doc diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..49dc8ed --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,31 @@ +name: Test + +on: + push: + branches: '**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Dependencies + run: | + # Install the python interpreters for running the test matrix + sudo apt install software-properties-common + sudo add-apt-repository ppa:deadsnakes/ppa + sudo apt update + sudo apt install python3.9 -y + sudo apt install python3.9-distutils -y + sudo apt install python3.10 -y + sudo apt install python3.11 -y + sudo apt install python3.12 -y + sudo apt install python3.13 -y + + # Install the python dependencies for running the tests + make test-dependencies + + - name: Unit Test Matrix + run: | + # Run the unit test matrix + make test diff --git a/.gitignore b/.gitignore index 82ce11c..287e2d0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,11 @@ dist # PyTest .pytest_cache +coverage.json +.coverage # Sphinx -doc/sphinx \ No newline at end of file +doc/sphinx + +# Tox +.tox \ No newline at end of file diff --git a/Makefile b/Makefile index fe8d28a..d40a634 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,35 @@ .PHONY: doc - PYTHON ?= /usr/bin/python3 +######### +# Testing recipes +# +# Install the required dependencies for the test recipe +test-dependencies: + $(PYTHON) -m pip install -r requirements.test.txt + # Execute the unit tests locally and in CI test: - $(PYTHON) -m pytest -vv + $(PYTHON) -m tox + +####### +# Build recipes +# +# Install the required dependencies for the build recipe +build-dependencies: + $(PYTHON) -m pip install -r requirements.build.txt # Build the python distribution locally and in CI build: $(PYTHON) -m build +##### +# Doc recipes +# +# Install the required dependencies for the doc recipe +doc-dependencies: + $(PYTHON) -m pip install -r requirements.doc.txt + # Build the python docs locally and in CI doc: $(PYTHON) -m sphinx.ext.apidoc -o ./doc/source/image . "tests/*" diff --git a/pyproject.toml b/pyproject.toml index 1f51962..666d952 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,4 +28,6 @@ Homepage = "https://github.com/whatsacomputertho/containerimage-py" Issues = "https://github.com/whatsacomputertho/containerimage-py/issues" [project.optional-dependencies] -test = ["pytest-mock"] +test = ["tox","pytest","pytest-mock","pytest-cov"] +build = ["build"] +doc = ["sphinx","sphinx_rtd_theme"] diff --git a/requirements.build.txt b/requirements.build.txt new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/requirements.build.txt @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/requirements.doc.txt b/requirements.doc.txt new file mode 100644 index 0000000..754a323 --- /dev/null +++ b/requirements.doc.txt @@ -0,0 +1,3 @@ +sphinx +sphinx_rtd_theme +myst_parser \ No newline at end of file diff --git a/requirements.test.txt b/requirements.test.txt new file mode 100644 index 0000000..b654c22 --- /dev/null +++ b/requirements.test.txt @@ -0,0 +1 @@ +tox \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ad2b1d1 --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +[tox] +envlist = py39,py310,py311,py312,py313 +[testenv] +# dependencies required for testing the module +deps = + pytest + pytest-mock + pytest-cov +# the command used to run the tests for the given python version +commands = pytest -vv --cov --cov-config=.coveragerc --cov-report=term --cov-report=json \ No newline at end of file